On Mon, May 23, 2005 at 08:26:26PM -0400, wbounce wrote:
> Over the weekend I reviewing my PWM setting on the bot I am working
> on. And I saw in the data sheet that you need to be sure that the
> new OCR3A or OCR3B need to be higher TCNT. How you you handle this?
> I seem to have a problem with 1 motor erratically reving to full
> speed. Could this be my problem?
Not sure if that is your problem or not, but one way to do it would be
to "schedule" the assignment and then actually do it on timer overlow
since you know the timer starts out as zero at that time. I.e.,
something like this:
...
new_ocr3a = new_pwm;
...
SIGNAL(SIG_OVERFLOW3)
{
if (OCR3A != new_ocr3a) {
OCR3A = new_ocr3a;
}
}
... or something like that.
Something else you might look at - have you tried using "glitch free"
phase correct PWM mode, like waveform generation modes 1, 2, and 3
(I'm assuming you are using your ATmega128) which are dual slope PWM
modes? This mode is somewhat more tolerant to changing the OCRx
registers with regard to their output waveform. Note that with
everything else being equal, the PWM frequency will be 1/2 of that of
one of the single-slope modes (fast PWM). But with three modes to
choose from, 1, 2, and 3, you can trade off resolution for frequency
as needed.
-Brian
--
Brian Dean
BDMICRO - ATmega128 Based MAVRIC Controllers
http://www.bdmicro.com/Message
Re: [AVR-Chat] PWM question
2005-05-24 by Brian Dean
Attachments
- No local attachments were found for this message.