Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Another way to generate precise sine waves?

Status
Not open for further replies.

carbonzit

Active Member
Prompted by this thread by Mr RB asking for help designing a precision 1kHz sine-wave generator, I looked around and came across this chip, the AD5165 digital potentiometer from Analog Devices (datasheet here). It gives you 256 linear resistance steps (I think the standard resistance is 100KΩ).

So wouldn't it be possible to use this to generate the steps of a sine wave, driven by a PIC with a 256-step table in memory? It uses a 3-wire interface, which I have no experience whatsoever with, so I don't know how hard it would be to get a PIC to talk to it, but it seems do-able.

The maximum bandwidth of the chip is ~50kHz, but since Mr RB wants just a 1kHz wave, that shouldn't be a problem.

So if one were to use this method, how would the results compare with using a D-to-A converter?
 
So if one were to use this method, how would the results compare with using a D-to-A converter?
Sounds like you're proposing to use it as a DAC. There are plenty of 8bit DACs that would be just as suitable, but I believe the original thread was attempting to create it with readily available parts only - no extra exotics aside from the uC. You'd still need a filter after the DAC as the quantisation levels produce distinct steps (& therefore high frequency components and decreases the SNR).
 
Carbonzit the linear resistance from the IC will give voltage steps, which is basically the same type of output as any typical DAC that makes stepped voltage output. That will be slightly better than PWM as it has less ripple and also better as it can be done faster.

There is still a speed problem with most PICs, to generate a 20kHz sine (for instance) with a PIC 16F at 20MHz xtal (5 MIPS) gives only 250 PIC instructions for the whole sine cycle. Then to get a nice sine you need many samples per cycle, say 50 samples so you only get 5 pic instructions to sequence and output each sample. It can be done "hardcoded" for some fixed frequencies but there are still many issues.

If you really want to buy a special chip to make sine outputs there are DDS chips like the AD9552 and older dedicated sig gen chips like the MAX038.
 
Last edited:
One of my assignments in college was to create a perfect sine at 1khz. They don't specify amplitude.... The trick was to design a 1khz square wave oscillator using an op amp and RC circiut.... Then in the feed back place two diodes back to back to limit amplification +/- the breakdown of the diodes is logarithmic, thus a perfect 1.2v sine is created
 
One of my assignments in college was to create a perfect sine at 1khz. They don't specify amplitude.... The trick was to design a 1khz square wave oscillator using an op amp and RC circiut.... Then in the feed back place two diodes back to back to limit amplification +/- the breakdown of the diodes is logarithmic, thus a perfect 1.2v sine is created
Can you draw a schematic? Log and sine are a little unrelated in my mind.
 
One of my assignments in college was to create a perfect sine at 1khz. They don't specify amplitude.... The trick was to design a 1khz square wave oscillator using an op amp and RC circiut.... Then in the feed back place two diodes back to back to limit amplification +/- the breakdown of the diodes is logarithmic, thus a perfect 1.2v sine is created

I think you don't understand what 'perfect' means :D

Such a design will give a high distortion 'approximation' of a sinewave, not 'perfect' do any means - but if accuracy of the wave isn't important, then it's perfectly fine for many jobs.

I'm also somewhat distressed that a college would even ask for a 'perfect' sinewave, anyone with any degree of electronics knowledge would ask for a sinewave with distortion under x% - and never 'perfect'.
 
I'll have to dig it out... It's with all my Uni stuff... It doesn't matter about its logarithmic properties as long as it is not linear..

Nigel! The distortion will occur if you try to make a sine wave from weinbridge or collpits, They design in a mosfet to add non linearity. I couldn't believe the results. As you said "near perfect"..
 
Last edited:
I'll have to dig it out... It's with all my Uni stuff... It doesn't matter about its logarithmic properties as long as it is not linear..

Nigel! The distortion will occur if you try to make a sine wave from weinbridge or collpits, They design in a mosfet to add non linearity. I couldn't believe the results. As you said "near perfect"..

What was the measured distortion?.
 
I'll have to dig it out... It's with all my Uni stuff... It doesn't matter about its logarithmic properties as long as it is not linear..
The logarithmic properties do matter if you are concerned about distortion. Just because it's non-linear doesn't mean it will make a good sinewave.

Edit: There are circuits that generate reasonable good (but not perfect) sinewaves using a combination of diodes and resistors in the feedback loop of an op amp. They use numerous diodes in parallel but with a different value of resistor in series with each diode. You thus get sort of a piece-wise linear approximation of a sinewave with perhaps 1% or so distortion. I believe some of the function generator chips use such an approach.
 
Last edited:
Nigel! I don't remember the distortion results... I will find them and show all. All I can remember at this point was generating a sine using various components...ie fet's, diode's, LDR's etc.. to see the varying distortion. The simple diode came out on top.. IN4002 are the ones I used....I doubt very much if they were within 1-2%... The fact of the matter is, this was another way to generate (Quite, Near) sine waves.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top