![]() |
![]() Portable Two Way Radio Frequency Counter 10Hz 26GHz US $57.95
|
![]() IBQ101 50MHz 26GHz Frequency Counter for Two Way Radio US $42.00
|
![]() Portable Frequency Counter for Two Way Radio US $29.95
|
![]() FC 1 Portable Frequency Counter for Two way Ham Radio US $28.80
|
![]() GOOIT GY560 Frequency Counter for Two Way Radio US $12.70
|
![]() GOOIT GY560 Portable Frequency Counter Two Way Radio US $12.70
|

How to vary sine wave frequency generated with PWM from Microcontroller.?
I am currently working for speed control of AC motor Using V/f and natural PWM method.
I am using ATmega16 MCU for that purpose. I have successfully created sine wave of 50 Hz by varying duty cycle of PWM from 0 to 100% using look-up table and keeping timer1 in 8-bit phase correct PWM mode.
Now, I can't get idea about to vary that sine wave frequency.
In my project I am keeping two push buttons for varying frequency at least of 1 Hz resolution.
someone suggested me to use that timer1 as external counter mode, connect it to VCO and use DAC to control VCO. But that isn't seems a practical idea.
Direct Digital Sysnthesis
This is a long winded explination of DDS but basically you totalize a value in an 3 byte accumulator using a value from the look up table that will determine amplitude for that portion of the sine wave. The upper byte of the accumulator is used to generate the PWM this totalizer it is never reset but is allowed to constantly over flow. This maintains a phase relationship as segments of a circle are added to the totalizer (more later on) Another totalizer is used for frequency and each pass through the code a value is added to it. This totalizer is used to detemine what phase value from the lookup table will be added to the totalizer. How many segments or fraction of a segment is added. What this does is compute a location on a digital phase wheel which is used to process a portion or a sine wave.
Later on you can do some cool arbitrary waveform generation by mixing multiple sinewave values in the totalizer and generate a waveform that is a mixture of the waveforms. By using different lookup tables you can also mix sine , triangle and square waves. The lookups define the shape of the wave and processing a totalized value computes the phase
http://www.analog.com/library/analogdialogue/archives/38-08/dds.html
http://zone.ni.com/devzone/cda/tut/p/id/5516
Lets assume for a moment that your lookup table has 16 entries of PWM settings that define your sinewave shape. The frequency of the sine wave is therefore determined by how fast you readout those points. Now for a moment think how a generator spinning a copper wire in a magnetic field creates a voltage that is in the form of a sine wave. The point here is that as a wire moves in a circle in the generator from 0 to 360 degrees these correspond to distinct points on the sine wave . The sinewave starts at zero amplitud at zero degrees rises to a positive peak at 90 degrees and returns to zero at 180 degrees where it continnues on for the rest of the cycle. illustrated in this link.
http://www.visionlearning.com/library/module_viewer.php?mid=131
what you'll get from this link is y = ASin(k*x) where A controls amplitude and (k determines frequency as a multiple of n)
This is the basis of Direct Digital Systhesis of a sine wave where you will mathematically determine the y value in the above formula and do a DAC via PWM of that value.
Pitfall:
Your code will execute in some minimum time to make one pass. This minimum time will define a limit of max frequency for which a true sine wave can be generated. You cannot synthesisize a sine wave with all of its points at a speed faster than what your uC can process.. Each pass through the loop that reads a lookup value and processes the pwm is genrating a portion of the sine wave with is a position on a circle. Each pass generates a segment
You will also have a limit on the response time of the PWM frequency to generate am output. You can get a faster response time by using a digital potentiometer in a voltage divider. An I2C command changes the resistance in 256 distinct steps. You may be able to get better frequency performance if high frequency is an issue.


US $57.95




