Decode Servo PWM Signals
2005-04-25 by Joel Haasnoot
Yahoo Groups archive
Index last updated: 2026-04-28 22:41 UTC
Thread
2005-04-25 by Joel Haasnoot
Hi I would like to decode PWM signals, for servos, such as those on model pr rc airplanes. Does anybody have any experience, hints, tips, code, google keywords or anything of the like? Joel
2005-04-26 by Dennis Clark
I handled it as an interrupt based on a 10us timer rollover. At 10us tics a 1ms to 2ms (+ or - a bit) can be handled as an 8 bit number from 100 to 200. Perhaps not that greatest resolution, but adequate to my needs. You could set the timer to give you a 5us interrupt for twice that resolution, but you might have to code it in assembler, depending upon your compiler. I found that gcc did an ATROCIOUS optimization job, YMMV. I read 2 channels in a 4 step state machine. You might do better to use a couple of the IO lines that have interrupts tied to them and use the hardware to time it - You'd have to change the IRQ sense upon each upward transition. DLC Joel Haasnoot wrote: > > Hi > I would like to decode PWM signals, for servos, such as those on model > pr rc airplanes. Does anybody have any experience, hints, tips, code, > google keywords or anything of the like? > > Joel > > > > > > > Yahoo! Groups Links > > > > > > > -- --------------------------------------------------------------------- * Dennis Clark dlc@frii.com http://www.techtoystoday.com * * "Programming and Customizing the OOPic Microcontroller" Mcgraw-Hill * ---------------------------------------------------------------------
2005-04-26 by Dave Hylands
Hi Joel, > Hi > I would like to decode PWM signals, for servos, such as those on model > pr rc airplanes. Does anybody have any experience, hints, tips, code, > google keywords or anything of the like? I have some code that works for an ATMega8. I modified it from some code from the OSMC project. You can find it here: http://www.DaveHylands.com/Software/Pulse-Stretcher/Pulse-Stretcher.zip It uses a timer setup to run at 8 uSec/tick, and generates an interrupt on each edge of the pulse. It can count upto 256 8 uSec ticks or 2048 msec. If you know that the pulses have a minimum width of 0.5 msec, then you can measure 0.5msec to 2.5msec with 8usec resolution (you would treat low values as wrapped). -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/
2005-04-26 by Peter Gargano
I'm after a high side (source) low impedance driver for driving multiplexed LEDs. I'm after something like this (Allegro 6810) http://www.allegromicro.com/sf/6810/ .. but, a lower cost lower voltage source driver for 8 or more bits. I'm planning on using someone's source driver with the ST 16C596 constant current sink driver .. http://www.st.com/stonline/books/ascii/docs/10154.htm Which has a fairly good price (but 12 week lead time!). Just to complete the picture, I'm currently using the TI TPIC6c595 sink driver .. http://focus.ti.com/docs/prod/folders/print/tpic6c595.html .. and the Toshiba TB62710 constant current source driver. So clearly, I'm moving from common cathode to common anode LEDs, and haven't quite completed the picture. Peter .
2005-04-26 by Paul Maddox
Peter, > I'm after a high side (source) low impedance driver for driving > multiplexed LEDs. I'm after something like this (Allegro 6810) > > http://www.allegromicro.com/sf/6810/ > > .. but, a lower cost lower voltage source driver for 8 or more bits. how about the good old 74HC595? serial->parallel latch? http://www.semiconductors.philips.com/pip/74HC595.html > I'm planning on using someone's source driver with the ST 16C596 > constant current sink driver .. > http://www.st.com/stonline/books/ascii/docs/10154.htm nice. > Which has a fairly good price (but 12 week lead time!). shame about the lead time, nice chip otherwise, very handy. paul
2005-04-26 by Peter Gargano
Paul Maddox wrote: > how about the good old 74HC595? serial->parallel latch? > > http://www.semiconductors.philips.com/pip/74HC595.html Paul, From the on-line datasheet for the 74HC595BQ (above) we find Output Drive Capability: +/- 7.8 mA on parallel output That's OK for a low brightness display, but it doesn't have the drive capability if run within its specs. Peter te.
2005-04-26 by Robert Adsett
At 12:30 AM 4/27/05 +1000, Peter Gargano wrote: >Paul Maddox wrote: > > how about the good old 74HC595? serial->parallel latch? > > > > http://www.semiconductors.philips.com/pip/74HC595.html > >Paul, > > From the on-line datasheet for the 74HC595BQ (above) we find > > Output Drive Capability: > +/- 7.8 mA on parallel output > >That's OK for a low brightness display, but it doesn't have the drive >capability if run within its specs. You can always add a bss123 to the output line to get the drive capability (cheap and small). Rated for 170mA you should be able to get 50 or 60mA through it w/o a problem. Robert " 'Freedom' has no meaning of itself. There are always restrictions, be they legal, genetic, or physical. If you don't believe me, try to chew a radio signal. " -- Kelvin Throop, III http://www.aeolusdevelopment.com/
2005-04-26 by Dennis Clark
Have you considered something like the Phillips PCA9531/2/3 chips? They are I2C based LED drivers where you can control the brightness via PWM, or, slow the clock down and control the blink rate. I've seen units with 4, 8 and 16 LEDs supported. Check them out. DLC Peter Gargano wrote: > Paul Maddox wrote: > >>how about the good old 74HC595? serial->parallel latch? >> >>http://www.semiconductors.philips.com/pip/74HC595.html > > > Paul, > > From the on-line datasheet for the 74HC595BQ (above) we find > > Output Drive Capability: > +/- 7.8 mA on parallel output > > That's OK for a low brightness display, but it doesn't have the drive > capability if run within its specs. > > Peter -- --------------------------------------- Dennis Clark TTT Enterprises ---------------------------------------
2005-04-26 by Russell Shaw
Robert Adsett wrote: > At 12:30 AM 4/27/05 +1000, Peter Gargano wrote: > > >>Paul Maddox wrote: >> >>>how about the good old 74HC595? serial->parallel latch? >>> >>>http://www.semiconductors.philips.com/pip/74HC595.html >> >>Paul, >> >> From the on-line datasheet for the 74HC595BQ (above) we find >> >> Output Drive Capability: >> +/- 7.8 mA on parallel output >> >>That's OK for a low brightness display, but it doesn't have the drive >>capability if run within its specs. > > You can always add a bss123 to the output line to get the drive capability > (cheap and small). Rated for 170mA you should be able to get 50 or 60mA > through it w/o a problem. Allegro has a few drivers. I use a A6275: http://www.allegromicro.com/ic/leddriver.asp
2005-04-27 by Brian Dean
On Tue, Apr 26, 2005 at 12:25:58AM +0300, Joel Haasnoot wrote:
> I would like to decode PWM signals, for servos, such as those on
> model pr rc airplanes. Does anybody have any experience, hints,
> tips, code, google keywords or anything of the like?
For high resolution pulse width measurement, use the Input Capture
function. Most AVRs have at least one available. Basically you set
the pin to detect whichever transition you are looking for and when it
happens, the timer value of when it occured is latched into a register
and a flag is set letting you know it happened. You can optionally
have this trigger an interrupt as well. You then look at the input
capture register to get your pulse width:
1) wait for rising edge
3) set timer value to 0
2) set input capture edge detect to "falling edge"
4) wait for capture event
5) pulse width = input capture register
If the pulse width can exceed the max timer value, then you need to
account for timer roll-over. Do this with the timer overflow
interrupt to extend the range of the timer.
The input capture feature can give you pulse width measurement
accuracy down to near the timer resolution, which can be as few as
62.5 nanoseconds when using a 16 MHz clock.
The beauty of this is that most of the work is done by hardware so you
don't have to poll the input line to determine when it changes state.
Your program can be off doing other things and you will be notified by
flag or IRQ when the pulsed ended happened.
-Brian
--
Brian Dean
BDMICRO - ATmega128 Based MAVRIC Controllers
http://www.bdmicro.com/2005-05-07 by wbounce
I am working on adding 2 wheel encoders to my robot. I am thinking of using either PORTE5, PORTE6 or PORTE7 but I am wondering if this will conflict with my PWM which I have on PORTE3 and PORTE4 (PWM output A and B of timer3) PORTE5 - External interupt 5 input or output compare and PWM output compare C for timer counter 3 PORTE6 - External interupt 6 input or timer counter 3 clock input PORTE7 - External interrupt 7 input or timer counter 3 clock input capture trigger If I use these will they cause problems with my PWM?
2005-05-07 by Larry Barello
PWM is a hardware function. interrupts shouldn't bother the PWM generator. However, you can not share PWM output with INT input, of course... Depending upon your encoders & the tick rate you might be better off polling than using interrupts. It just depends.
-----Original Message----- From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com]On Behalf Of wbounce Sent: Friday, May 06, 2005 8:01 PM To: AVR-Chat@yahoogroups.com Subject: [AVR-Chat] Which pin to us for interupt? I am working on adding 2 wheel encoders to my robot. I am thinking of using either PORTE5, PORTE6 or PORTE7 but I am wondering if this will conflict with my PWM which I have on PORTE3 and PORTE4 (PWM output A and B of timer3) PORTE5 - External interupt 5 input or output compare and PWM output compare C for timer counter 3 PORTE6 - External interupt 6 input or timer counter 3 clock input PORTE7 - External interrupt 7 input or timer counter 3 clock input capture trigger If I use these will they cause problems with my PWM? Yahoo! Groups Links