Full Version : Improved Motor Control (AVR)
avr >>MOTORS SERVOS & PWM >>Improved Motor Control (AVR)


AVR_Admin- 04-29-2006
AVR microcontroller makes improved motor controller
Edited by Bill Travis

This circuit provides a novel method of reading the pulse train using an Atmel AVR processor, from a typical radio-controlled receiver, and to determine the velocity of a motor. To capture the pulse train from a typical receiver, you need an external interrupt that triggers based on a rising and a falling edge. Three timers are also necessary: one 16-bit, free-running timer to determine the period of the input pulse and two 8-bit timers configured as PWMs (pulse-width modulators) for driving the motor in both forward and reverse. Finally, two digital outputs act in concert with the PWMs to move the motor. You can find all these features in an AVR microcontroller. Assuming that you use a typical transmitter and receiver, such as a pair from Futaba (www.futaba.com), the range of pulse width, tPH, should vary from 1 to 2 msec for full reverse and full forward, respectively. If the Timer 1 clock-source frequency is 500 kHz, the number of counts possible between full reverse and full forward is 500, beginning at 500 for a pulse width of 1 msec and ending at 1000 for a pulse width of 2 msec. A pulse width of 1.5 msec identifies no-input or full-stop conditions. Listing 1 provides an example of this motion-control application.

Subtract 494 ($1EE) from the value of Timer 1, captured after the falling edge of the pulse, assuming that the pulse is positive-going and that, at the rising edge of the pulse, the value of the counter resets. The range of values between full reverse and full forward becomes 6 to 506 ($6 to $1FA). Forward motion is $101 to $1FA, with $101 providing the least forward motion and $1FA providing the most forward motion. Reverse motion ranges from $FF to $6, with $FF providing the least amount of reverse motion and $6 providing the most amount of reverse motion. If negated, the reverse range becomes $01 to $FA. If you use the lower byte of the adjusted Timer 1 value directly to set the output comparison registers OCR0 or OCR2 of Timer 0 or Timer 2, you can use as much as 98% of the range of input values to the PWM. You can choose which PWM-configured timer to use based either on where the value occurs in the range or on the upper byte. Note that when the upper byte is 1, the direction is forward; when the upper byte is 0, the direction is reverse. Click here to download the C-based Listing 1.

Link to Site: http://www.edn.com/article/CA250814.html


Forumer™ is Voted #1 Free Forum Hosting provider
Build your own community today with the largest message board hosting company.