6 years, 8 months ago.

Multiple PWM inputs

Hi,

I'd like to use several PWM signals from an R/C control, to control motors and servos via a LPC1768.

is it possible to accurately measure multiple PWM in signals? Or do I need to filter them and do analogue measurements?

1 Answer

6 years, 8 months ago.

Most micro's will have the ability to setup certain pins with a capture feature which will automatically record a time stamp based on a rising or falling signal edge. But I don't think the mbed api implements this - you would have to dig into the lower HAL layers but the functions are probably there. You would be limited to using pins that can act as inputs for the capture module - bit it could still be 10 or more channels depending on the micro. This would give the most precise results.

If the signal is slow enough (say less than say 10 kHz) you can probably just use InterruptIn on the pin and manually log a timestamp inside the interrupt routine. The function, us_ticker_read(), should work. Use an circular buffer and keep track of say, the last 10 timestamps and do an average to get a nice smooth result. Remember to use volatile keyword for any variables accessed in the ISR. You could keep track of dozens of pins this way - any pin that works with InterruptIn.

Accepted Answer

Thank you. I saw a similar solution in the arduino forum. I'm looking at signals between 11 and 25kHz from a digital R/C receiver. I hope it can be done 'a simple way'

Goal is to use accellerator, motor rpm and drive axle speed to automatically control a built in 3-speed gearbox (Tamiya semi truck)

posted by Marout Yasuo Sluijter-Borms 14 Aug 2017