Electronic – PLD, FPGA or microcontroller for PWM decode

programmable-logicpwm

I need to handle PWM output from a single channel of an R/C receiver. I want to count the width of the pulse roughly in 4ms increments, and based on different widths take action by switching LEDs (20-40 mA) on and off.

I know how to do this using an Arduino but would like to know if it is possible to do the same thing using a simpler (and cheaper) programmable device such as a CPLD or small-scale FPGA. Basically I need to time the pulse edges and manage the on-off states of outputs. If the outputs can sink the LED current so I don't need to add transistors, that would be a plus. Ideally I'd like to be able to handle steady state as well as flashing.

There seem to be a lot of parts that can generate PWM (i.e. motor drivers) but not as many examples of PWM decode, apart from Arduino examples. Which device(s) would you use to solve this problem?

Best Answer

With 4ms timing a micro-controller will be fine. Use an arduino for the least complex and time consuming method of reading your 4ms pulse. I'm not sure how the timers work but here is some info: http://playground.arduino.cc/Code/Timer1

I know the stm32f4 nucleo boards have 32 bit timer on a few of the pins if you really need the accuracy. Compilers are harder to find for those boards but I think that they have one for the nucleo's now that is free. You will spend more time finding\getting familiar with the tools.

If you really want to use an FPGA, the MAX10's from altera are one of the best bets. you can get a dev board and a programmer for 100$ And the tools will work for free (quartus prime web edition) as long as you don't want to put anything fancy on the board like an arm core (you can still run their paid IP but you have to be tethered to their software). You will probably spend 20 hours minimum getting familiar with the tools if you have never worked with an HDL before. Another option is lattice that has a usb stick with a CPLD on it, but I can't vouch for their tools