Posted: Wed May 06, 2015 3:41 pm Post subject: Different frequencies
Hi
I am using Atmega32, having OC1A and OC1B I want to generate 1khz at one channal while 100hz at other channal. 1kHz will be used to drive an voltage doubler for high side mosfet drive and 100hz for controlling pwm.
my question is it possible to do it with the said UC.
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Sat May 09, 2015 2:43 am Post subject:
The Bascom samples show how to use a timer to generate any frequency, and certainly 1 Khz is possible. 100Hz is also possible to generate simultaeously on another output.
But its not so easy to generate a precise frequency and use the AVR hardware for PWM also. The big steps in the clock prescalers mean you can get for instance about 120 Hz at 8 Mhz clock frequency and still use PWM. Usually this does not matter for PWM, its pretty arbitrary what frequency you use , but it does depend on what your application needs. _________________ Adrian Jansen
Computer language is a framework for creativity
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
Posted: Mon May 11, 2015 12:06 am Post subject:
If you really MUST have the PWM frequency set precisely to 100Hz, then you need to use the Phase and Frequency Correct PWM mode, as described in the Atmel AtMega32 manual page 101. There are some limitations on the available resolution in this mode, depending also on the processor clock speed.
Read that first, and see if it will meet your needs.
If on the other hand you just selected 100Hz because it sounds like a nice number, then choose a frequency which can be generated using 256 counts ( at a suitable prescaler setting ) at your processor clock speed. Then many of the available PWM modes as built into Bascom will work. _________________ Adrian Jansen
Computer language is a framework for creativity
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum