Sine wave generation

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi team,

I need to generate a sine wave of 625Hz, the purpose is of cable identification. I have done some research narrow it down to this two. What's the pro and con of each one, and which one do you think is better for my application.

  1. DDS -> PWN (look up table, 50 points??) -> LP filter
  2. Square Wave on 625Hz -> LP to filter out 3, 5, 7 hormonic etc...

I am not very good with analog, so keep this in mind. Keep to know your thoughts/feedbacks/critiques
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Why does it have to be sine wave?
I am not sure, that's the spec I was given. I am guessing it's a transformer isolated output, the input side of the transformer need to be constantly changing for the transformer to work the best?
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
What MCU are you using?
Does it have DAC or PWM output?
I haven't chosen one yet. But one without DAC would be cheaper I assume. That's why I am thinking of using PWM as DAC. But I am OK with a one with DAC if it make sense.
 

atferrari

Joined Jan 6, 2004
4,764
I haven't chosen one yet. But one without DAC would be cheaper I assume. That's why I am thinking of using PWM as DAC. But I am OK with a one with DAC if it make sense.
Some 18F micros have DAC peripherals. I do not see difference in cost because they have it added.
Look up table I used with good results working with a 16F84A.
 

Deleted member 115935

Joined Dec 31, 1969
0
I would suggest ,
the questing to ask is

a) how accurate does the frequency need to be
b) how pure dose the frequency need to be

My guess is as this is an audio tone,
its to be heard by humans, so does not need to be to accurate,
and it does not need to be to pure,

as such , just about any method of generation is good enough,

Now if the tone needs to be detected by a circuit,
as in DTMF tone detection , then things need to be a lot more accurate.
 

DickCappels

Joined Aug 21, 2008
10,153
If your controller is fast enough (not much of a problem these days) you can try this (straight from Google).
Generating Sine Wave using PWM
  1. Create a look-up table for the sine wave.
  2. Configure the Timer block to generate periodic interrupts.
  3. Configure the PWM block.
  4. Vary the PWM duty cycle during each timer interrupt.
  5. Use a low pass filter.

Also, you can use a DAC such as an R-2R DAC shown below with a look-up table:
1626255330642.png
 

MrChips

Joined Oct 2, 2009
30,708
Generating a low distortion 625Hz sine wave is not difficult for an MCU.
Choose your MCU first to meet your application requirements and then we can suggest ways to generate the sine wave.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
I would suggest ,
the questing to ask is

a) how accurate does the frequency need to be
b) how pure dose the frequency need to be

My guess is as this is an audio tone,
its to be heard by humans, so does not need to be to accurate,
and it does not need to be to pure,

as such , just about any method of generation is good enough,

Now if the tone needs to be detected by a circuit,
as in DTMF tone detection , then things need to be a lot more accurate.
Yes, the tone needs to be detected by a circuit. Not sure it's the same sense as you intended. It's for cable identification, so there will be a receiver to detect the tone. But it's only one tone to detect.

Regardless, the accurate will be limited by the crystal I used, which I am happy with. In term of how pure, I guess out of the two method I mention in my OP. The purer one will be prefer.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Generating a low distortion 625Hz sine wave is not difficult for an MCU.
Choose your MCU first to meet your application requirements and then we can suggest ways to generate the sine wave.
My choice of MCU is not important (that's what I think anyway), all I need is just on/off (normal operation/deep sleep with power cut off to driver etc), and be able to pulse to the tone and battery monitoring.

So any MCU with 12 IOs (including ADC, PWM, at least one timer with interrupt, at least one gpio with interrupt, 64MHz with a pic for 50 points PWM if using DDS, a few spare IOs just in case)
 

Ian0

Joined Aug 7, 2020
9,667
Divide a 12.8MHz down to 6250Hz*, then run this circuit (the 5 stage version)
https://www.tinaja.com/glib/rad_elec/digital_sinewaves_11_76.pdf
maybe if the transformer has a bit of leakage inductance, a cap across the secondary will make the necessary filter to deal with the remaining risiduals of the squarewaves which start at 5625Hz.

*This looks like the ideal job for a 74HC4060, but unfortunately it needs the 11th output which is missing, and no-one seems to make a 6.4MHz or 25.6MHz crystal, so it needs an extra divide-by-2 or a separate oscillator and a 74HC4040
 

AnalogKid

Joined Aug 1, 2013
10,986
Note that any digital technique (and all of the ones mentioned here so far) requires an output circuit of some flavor, either as an output buffer for a D/A's relatively high output impedance, a lowpass filter, a current booster, a gain stage, or or or ... usually, one opamp is enough to do whatever. Given that, the same one opamp can be the entire oscillator.

Since the fidelity and amplitude stability requirements are not nearly as strict as in the audio or instrumentation worlds, I suggest a 1-opamp phase shift oscillator circuit. If you ever get any requirements details on the output amplitude, output impedance, output signal current, load impedance, etc., they probably can be met with the other half of a cheap and rugged duap opamp such as the LM358.

An alternative ito use the capacitor voltage of a 555 astable circuit as an approximate sine wave, and filter that with the above mentioned single opamp. With a 1% capacitor and 0.1% resistor, a 555 has surprisingly good frequency stability.

ak

Yes, it hurt.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Please choose your MCU.
This one should work, pic16f15243

Assuming 8bit PWM, 100 points per sine wave. Should be able to generate a 16us interrupt, that's 128 instruction max per interrupt. This is should be enough to update the pwm. If not fast enough, I guess I can do a 50 points per sine wave, or use a stm32
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Note that any digital technique (and all of the ones mentioned here so far) requires an output circuit of some flavor, either as an output buffer for a D/A's relatively high output impedance, a lowpass filter, a current booster, a gain stage, or or or ... usually, one opamp is enough to do whatever. Given that, the same one opamp can be the entire oscillator.

Since the fidelity and amplitude stability requirements are not nearly as strict as in the audio or instrumentation worlds, I suggest a 1-opamp phase shift oscillator circuit. If you ever get any requirements details on the output amplitude, output impedance, output signal current, load impedance, etc., they probably can be met with the other half of a cheap and rugged duap opamp such as the LM358.

An alternative ito use the capacitor voltage of a 555 astable circuit as an approximate sine wave, and filter that with the above mentioned single opamp. With a 1% capacitor and 0.1% resistor, a 555 has surprisingly good frequency stability.

ak

Yes, it hurt.
The reason I want to use a MCU to generate the sine wave is I need a MCU already, might as well use it to generate the wave. Also I was under the assumption that if I generate the waveform from a MCU, the frequency is more accurate and as I will be using a crystal.

And yes, the sine wave will feed to an amplifier. Then to a transformer. The final output of a transformer need to deliver 5W. I haven't got to this part however.
 
Top