I do this often. Check out www.barello.net/Papers (motion control), www.barello.net/ARC (look at sample code & projects), and www.barello.net/Robots. The Schmitt trigger inputs on all AVR's conditions the raw opto output. Depending upon speed of the count you can either poll or use interrupts. If the count rate (edge rate) is less than 5k/second or so, I would poll: set up a 10khz timer interrupt that examines the inputs and increments a counter with each transition (low->high, high->low). Greater than 10k edges/sec I would use one of the edge sensitive interrupts (INT0, 1, ACD, ICP) and then switch edge sense within you handler (e.g. after a positive edge, switch to negative, and so forth). Then in your main loop, examine and clear the counter periodically to get velocity. Using the hardware counter would have very low software overhead and would be best for count rates >100k/sec, but there is only one of those in the AVR so I have never used it (I always handle two channels of two lines/encoder so I need four interrupts). Cheers! -----Original Message----- From: Ridho Alpha [mailto:pendekar_ridho@yahoo.com] Sent: Sunday, January 09, 2005 9:03 AM To: AVR-Chat@yahoogroups.com Subject: [QUARANTINE][AVR-Chat] asking about encoder..external interrupts or counter??? hello i use AVR for motor control, I use ATMEGA16. i ask for encoder which is made just from optocoupler "U" model.the output is pulses. What do you think how i can read the counter???counting process.the best solution?? Using External Interrupt?? Using Counter??? please give a clue.... thank you __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com Yahoo! Groups Sponsor ADVERTISEMENT Yahoo! Groups Links To visit your group on the web, go to: http://groups.yahoo.com/group/AVR-Chat/ To unsubscribe from this group, send an email to: AVR-Chat-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
Message
RE: [QUARANTINE][AVR-Chat] asking about encoder..external interrupts or counter???
2005-01-09 by Larry Barello
Attachments
- No local attachments were found for this message.