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.

[AVR] pulse generator with variable frequency.

Status
Not open for further replies.

hell_son

Newbie level 2
Joined
Oct 14, 2014
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
16
Hello to everyone, i'm a student from greece and i need some help for my project.
My project is to make (with atmega16) a pulse generator based on spwm method not only for 50hz but with variable frequency 0-200Hz.
I am thinking to use ADC converter and a potensiometer to change the frequency and then
with timer0 making the SPWM just writing : pulse width = sine (time) * MaxPulseWidth
My problem is that i am confused with connecting all these informations together.
I would appreciate any help or guidance,
nick
 

Hi Nick. Are you trying to produce a pulse, or a sine wave? Are you converting the PWM output back to analog with a filter?

You have two basic controls on a PWM: frequency and duty cycle. Generally with a micro you control these by setting the clock source and frequency, total PWM cycle period (or timer overflow counter in clock cycles), and the output compare value which determines the duty cycle. Your clock source should be high enough to give you the resolution and smallest PWM % increment you need, but then it is usually left fixed. So then you would control the output frequency with the timer overflow, and the pulse width/duty cycle with the output compare. Or if you filter the output, the duty cycle will control the analog output voltage. So your equation is good to produce a sine wave, you just need to figure out what values to write, and to which registers, for your particular device.
 

Hello ARQuattr, i want to produce a sine wave and in the output i will filter it. But the frequency of the sine wave should be variable 0-200Hz. In my equation "pulse width = sine (time) * MaxPulseWidth", were time=2*π*f*T ( f: 0...200Hz, T: step value). But frequency f won't change everytime in the code but in the begining just once ( for example 100HZ and then will remain constant). Is my equation right?
 

I have a problem like your problem. I want to produce a squre pulse with 200-400 Hz frequency, But by changing TCNT2 The frequency does not change. Did you solve your problem?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top