Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Smoothing a rectified sine wave DDS

Status
Not open for further replies.

victoramas

Junior Member level 1
Joined
Jun 19, 2006
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,478
I produce a rectified sine wave 1Vpp 100Hz using a PIC + DAC 12bits.
I would like to smooth the line by applying a filter.
What filter do you suggest?

100HZ.png
 

Hi,

What do you mean with "smooth"? Describe it.
You mean something like a reconstruction filter?

The problem will be that the edges will be round. How "round" do you like it?

Klaus
 

"What do you mean with "smooth"? Describe it."

Right now I can see the stairs on oscilloscope on certain parts of the sine-wave. I can measure up tp 30mV height for one step.
I would like to have it 1mV.
I use a look-up table with only 100 entries. I could probably go up to 175 entries, but not more.
I am limited by I2C speed, which I can run up to 1.9MHz, and by the PIC speed, now at 32MHz.
I guess I must switch to an SPI DAC and go to 10MHz or higher bus speed.


"You mean something like a reconstruction filter?"
Yes, that is what I mean.

"The problem will be that the edges will be round. How "round" do you like it?"
There is no problem with that as long as the rectified sine-wave will touch the 0V for at least 1 or 2 LSB. I use later another PIC to detect 0V, that is an essential step.
No other requirement.

I was thinking that stable with 500 ro 1000 entries would do the job, but then a faster microelectronic is needed. Then instead of loo-up table I may use a trigonometric function, but I want to use a small PIC in the range PIC10F-PIC16F. I do not want to use a PIc18F-PIC24F or dsPIC.

If I want to use lookup table + PWM + filter instead of DAC and supposing I can get a high resolution PWM, 15 bits or more (www.microchip.com/ApplicationNoteAN14769426) is it any chance for a smoother signal waveform?
 

Hi,

What about another approach?

Change the table to get differential curve of the current curve.
It's similar to take the difference from one step to the next, but you should multiply them to get best fit in DAC range.

Mathematically it's a cos function from 0 to Pi...repeating.

Feed this data the same way as yo do now to the DAC.

***
Now add an integrating Opamp circuit to the output of the DAC.
Use a high value resistor across the integrating capacitor to stabilize DC bias.
The output of this integrator should be a more clean rectified sine. Without the nasty steps.
The problem is that you need to stabilize to DC shift signal.

Klaus
 

I will consider your recommendation and instead of going from 0 to PI, I will go only to PI/2 as in example below:
Code:
#include <16F1825.h> 
#fuses NOFCMEN ,NOIESO, NOCLKOUT, BROWNOUT, NOCPD, NOPROTECT, NOMCLR, NOPUT, NOWDT, INTRC_IO 
#fuses NOLVP, NODEBUG, BORV19, NOSTVREN, PLL, NOWRT 
#use delay(clock=32M) 
#use I2C(MASTER, scl=PIN_C0, sda=PIN_C1, FORCE_HW, FAST=1900000) 

CONST unsigned long SINE_WAVE[85] = { 0, 15, 30, 45, 60, 76, 91, 106, 121, 136, 150, 165, 180, 195, 210, 224, 239, 253, 267, 282, 296, 310, 324, 338, 351, 365, 379, 392, 405, 418, 431, 444, 457, 469, 481, 494, 506, 517, 529, 540, 552, 563, 574, 584, 595, 605, 615, 625, 635, 644, 654, 663, 671, 680, 688, 696, 704, 712, 719, 726, 733, 740, 746, 752, 758, 764, 769, 774, 779, 783, 788, 792, 795, 799, 802, 805, 808, 810, 812, 814, 816, 817, 818, 818, 819 }; 

void dac_i2c(unsigned int16 sample){     
   i2c_start();                          // Start
   i2c_write(0b11001000);                // Device address
   i2c_write(0b1000000);                 // Internal Device address   
   i2c_write((sample & 0xFF0) >> 4);     // Upper data bits (D11.D10.D9.D8.D7.D6.D5.D4)
   i2c_write((sample & 0xF) << 4);       // Lower data bits (D3.D2.D1.D0)
   i2c_stop();                           // Stop
   } 

void main() { 
setup_adc(ADC_OFF); 
unsigned long int i=0; 
disable_interrupts(GLOBAL); 
   while(TRUE){ 
      while (i< 84){ 
         i++; 
         delay_cycles (33); 
         dac_i2c(SINE_WAVE[i]); 
      } 
      while (i>0){ 
         i--; 
         delay_cycles (33); 
         dac_i2c(SINE_WAVE[i]); 
      }      
   } 
}

My initial DAC was I2C MCP4725 12 bits and I will investigate a faster one SPI MCP4921 12 bits, thinking that higher speeds let me to enlarge the look-up table and then the step size of DAC is smaller and maybe I do not need a filter at all.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top