120kHz sinewave

This forum is for posts that might be considered off-topic but that may be useful or interesting to members. Examples include posts about electronics or programming in general, other microcontrollers or interesting devices, useful websites, etc.
Post Reply
dlh
Posts: 395
Joined: 15 December 2006, 12:12 PM
Location: ~Cincinnati

120kHz sinewave

Post by dlh »

I need to generate a 120kHz signal and would like it to be as sine-like as possible. Are PWM outputs a square wave or sine wave or something else? If square, how can I massage it to resemble a sine wave?
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: 120kHz sinewave

Post by dkinzer »

dlh wrote:Are PWM outputs a square wave or sine wave or something else?
PWM is a digital signal and hence a good approximation of a square wave.
dlh wrote:If square, how can I massage it to resemble a sine wave?
An ideal square wave is actually an infinite sum of sine waves. The lowest frequency in the infinite series is the same as the frequency of the square wave, i.e. the fundamental frequency. The remaining frequencies in the series are multiples of the fundamental frequency. Consequently, you can convert a square wave to a sine wave approximation by filtering out some of the higher frequencies.

That said, filtering may not produce the signal that you want. For example, if you want frequency modulation (higher and lower frequencies about a center frequency) then PWM isn' t going to be useful by itself.

Note that you can synthesize a sine wave by using a DAC to produce analog voltages at various points along the sine curve. That is, by changing the DAC output to the right value at the right time the resulting waveform will resemble a sine wave of a certain frequency. The number of "points" that you use to synthesize the sine wave depends on how "pure" the sinewave needs to be.

Recalling that PWM output can be filtered to produce an analog voltage proportional to the duty cycle suggests that PWM could be used as a component of sinewave synthesis. This is the basic technique that is used by the ZBasic System Library routine FreqOut(). (However, hardware PWM is not used. Instead, a form of software-generated PWM is used thus allowing FreqOut() on any pin.)
- Don Kinzer
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

120kHz sinewave

Post by twesthoff »

Dave,
How pure does the sine wave have to be?

Are you going to modulate it in any way? AM/FM etc.

Tom W

On 12/23/2012 2:37 PM, General wrote:
I need to generate a 120kHz signal and would like it to be as sine-like as possible. Are PWM outputs a square wave or sine wave or something else? If square, how can I massage it to resemble a sine wave?



davehouston.org



dlh
Posts: 395
Joined: 15 December 2006, 12:12 PM
Location: ~Cincinnati

Post by dlh »

I was fairly sure it was a square wave but didn't recall that it has only higher harmonics - too long since school. I was vaguely aware of the DAC method. And, I'm aware of some programmable ICs which output a sine wave.

This is for an X10 application. A power engineer has designed a powerline carrier amplifier and we're trying to minimize the parts count to use it in a powerline modem but don't want to put all those harmonics on the powerline. We want a fairly pure sine wave and will not be modulating it, merely gating it.

I found an Atmel appnote, AVR131, explaining how to filter the PWM output.
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Post by stevech »

can't use a TW523?
or serial port to/from CM11?
These are already UL approved. Doing that for you new product can be costly, as you probably know.
This one is from other than X10 Inc.
http://jvde.us/xtb/XTB-523_description.htm
re UL tests: http://jvde.us/xtb/xtb_UL.htm


failing that, a 4 to 8 bit D/A is easily done with an I/O port's bits and an R-2R resistor ladder.

If you couple to the AC mains with a transformer, it may roll-off the square wave from an I/O bit toggled at 120KHz - and that can be done with a timer so no CPU time is needed to generate this carrier. Then just enable/disable the timer to create the modulated carrier (on/off keyed carrier). Same scheme as used for an infrared remote's carrier.

I have schematics for most of the X10 devices, and all the transmitting ones use a ferrite core transformer - and some use a third winding with a parallel LC circuit - not sure why. Related to using the same transformer for receiving and transmitting.
dlh
Posts: 395
Joined: 15 December 2006, 12:12 PM
Location: ~Cincinnati

Post by dlh »

Stevech,

I'm thoroughly familiar with all of the X10 PLC transmitters and also aware that all but the TM751 and CM15A have been discontinued. The latter was unavailable for most of the past year - it recently started shipping again but is already out of stock.

This is for a DIY project so UL doesn't apply but the engineer works in the power industry so I'm confident it could pass if he wants to turn it into a product.

I've decided to go with an IC that will supply a 120kHz sine wave.

I'm also familiar with what Jeff Volp has done. None of his devices are UL approved (he requires a signed waiver) and they delay reporting powerline activity so it's impossible to avoid collisions.

Do you have any idea what the FCC limits are for the amplitude of the 120kHz? I see limits for 150kHz and up in the Part 15 regs but not for 120kHz.

BTW, that winding with the parallel circuit is the tank for a free-running oscillator that supplies the 120kHz - the RR501 (and maybe CM11A) was the only one that used PWM from the PIC.
DocJC
Posts: 112
Joined: 16 March 2006, 6:23 AM
Location: Cleveland, OH
Contact:

Post by DocJC »

A thought or two:

One easy way to generate the 120 kHz signal is with a DS1077 chip, programmed/controlled by a micro. This generates a square wave, which one then feeds through a LPF to get the fundamental 120 KHz sin wave, as Don mentioned above. Once programmed the chip will operate without uC intervention, which may be helpful. This is essentially a one chip, easy to use, oscillator, and easier than building your own analog hardware oscillator.

Of course if one is going to just generate a square wave and filter it, then one ought to just consider doing it with a uC Timer/Clock module, especially if one will have a micro in the system anyway.

One could use a DDS to generate the sin wave, using a micro, also. Google Jesper DDS or Jesper Mini DDS and have a look. Very impressive. Jesper has his DDS generating signals up to 200 kHz, even 300 kHz.

When I wrote a DDS to learn more about the technique I had a very lengthy ISR routine and therefore maxed out my ISR rate at 100 KHz, for a Maximum output frequency of 50KHz, (with two samples / period, which therefore needed a good LPF on the output, also). My program had lots of room for improvement, but Jesper shows that 120 kHz is certainly doable, even with an AVRTiny as a dedicated signal generator for the project.

JC
Post Reply