Subscribe to EDN
RSS
Reprints/License
Print
Email

AVR microcontroller makes improved motor controller

Edited by Bill Travis

Anthony Di Tommaso, Cranberry Township, PA, and George Simonoff, Petersburg, OH -- EDN, October 17, 2002

The circuit in Figure 1 provides a novel method of reading the pulse train using an Atmel (www.atmel.com) 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.

Is this the best Design Idea in this issue? Select at www.edn.com.

RSS
Reprints/License
Print
Email
Talkback
Canon Resource Center

Featured Company


Most Recent Resources

Advertisement
Related Content

No related content found.

  • 0 rated items found.
Advertisement

KNOWLEDGE CENTER

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
Engineering Careers
Jobs sponsored by
Advertisement
About EDN   |   Site Map   |   Contact Us   |   Subscription   |   RSS
© 2012 UBM Electronics. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other UBM Canon sites

UBM Canon | Design News | Test & Measurement World | Packaging Digest | EDN | Qmed | Pharmalive | Appliance Magazine | Plastics Today | Powder Bulk Solids | Canon Trade Shows