NEX Robotics
Fire Bird V Software Manual
5.3.2 PWM generation using Timer
PWM using Timer n
All 16 bit timers are identical in nature. We are using timer 5 for PWM as input pins of the motor
driver IC L293D are connected to PL3 (OC5A) and PL4 (OC5B).
For robot velocity control Timer 5 is used in 8 bit fast PWM generation mode. In the non
inverting compare output mode.
The counter counts from BOTTOM to MAX and again restarts from BOTTOM. In non-inverting
compare output mode, the output compare (OC5X) is cleared on the compare match between
TCNT5 and OCR5X, and set at BOTTOM. Where X is A, B or C. In inverting compare output
mode output (OC5X) is set on compare match and cleared at BOTTOM.
Figure 5.2: Time diagram for fast PWM mode
In 8 bit fast PWM mode the counter is incremented until the counter value matches either fixed
value of 0x00FF hex and then value is rolled over again to 0. In the non-inverting PWM mode
output on the output compare pins (OC5A, OC5B and OC5C in this case) is logic 0 when
counter starts at 0. When counter value is matched with OCRnx (in this case OCR5AL,
OCR5BL and OCR5CL output at the output at the corresponding compare pins (OC5A, OC5B
and OC5C in this case) becomes logic 1. It stays at logic 1 till counter rolls over from 0xFF to 0.
At the roll over value of these OCRnx pins is set to logic 0. To change the duty cycle of the
PWM form 0 to 100% duty cycle in the 8 bit fast PWM generation mode value of OCRnx can be
set between 0 to 255 (0x00 to 0xFF).
www.nex-robotics.com
82
Need help?
Do you have a question about the Fire Bird V ATMEGA2560 and is the answer not in the manual?