Looking for Feedback on PWM to Digital IO Converter

Hi folks,

First post here, I am also pretty new to the Ardunio and electronics in general so please forgive me if I sound like an idiot.

For the past couple days I have been looking for a way to convert a PWM signal from a R/C receiver (Spektrum AR6210-X) to a signal that can be read by a digital pin on the Arduino. Before everyone flips out and points me to the zillion posts related to that, that let me explain in a little more detail: The Spektrim DX6i transmitter has a few channels that are hooked up to various switches (e.g. GEAR / FLAPS), the remaining channels are connected to the various gimbals depending on how the transmitter is configured.

I’ve current got my Arduino reading the signals for the gimbal controlled channels using the technique described on the http://rcarduino.blogspot.com rcarduino blog, so that’s working great. However I wasn’t really sure what to do about reading the “switched” channels for GEAR/FLAPS. One approach would be read the pulses in and determine the value based on that. But it seemed like a waste of interrupt pin, and I would rather not slow down the Ardunino using pulseIn. I also thought it would be cool to build a circuit to “convert” the PWM to a simple HIGH/LOW signal that can be read by a digital pin simply to learn some stuff.

So continuing on, after hooking the receiver up to the scope I was able to determine that the receiver us sending out ~22KHz PWM signal with a duty cycle ranging from 5-10%. In other words, when the GEAR switch on the transmitter in the “off position”, the receiver sends out a pulse of about 1100us on the gear channel. When the GEAR switch is in the “on posistion” it receiver sends out a pulse of about 1900us. The goal would so set a digital pin HIGH when the pulse is 1900us and low when its 1100us. I guess the small duty cycle range is because these receivers are designed to drive servos.

With such a low range in duty cycle I was a bit stumped on what to do. And after a bunch of reading, I’ve built and tested a circuit and appears to do just what I want. The approach I’m using an RC filter connected to an op amp as a comparator. The idea is to convert the PWM signal to a voltage (about 250mV at 1900us - AKA ON, and about 160mV at 1100us - AKA off). I’m then feeding that into an op amp comparator using a voltage divider to get 200mV to feed in as a reference voltage. When the signal is high, this drives the comparator high and outputs ~3.5V from the output pin which is enough to send the ardunio pin high. The 330M Ohm resistor is supposed to be a “Schmitt Trigger” to ensure that the transition from on to off is cleaner.

I’ve attached the circuit diagram to this post, and I would love some feed back on it.

Some questions I’d love to have answered:

  • Is this is a terrible idea? How reliable will this circuit be? If the receiver is driven from a battery, will how will the battery voltage affect output of the RC filter as the battery drains. I’ve only tested with a 5V regulated wall wart.

  • Why is the op amp only driving 3.5V instead of the 5V from the power supply? I’ve read that this has something to do with the fact that when the op amp is saturated it can only drive 80% of the power supply voltage. I’m not really sure if this is true, or why it would be the case.

Thanks for your feedback.

As I started to read your post I was thinking "RC filter with op-amp comparator" but I see you got that far, as well as the Schmitt Trigger, so, so far so good.

I don't see why it would not be reliable myself, although other ideas spring to mind. For one, just the filter and then read the results on an analog port, preferably asynchronously.

Or, use pin change interrupts to detect the pulses.

Why is the op amp only driving 3.5V instead of the 5V from the power supply?

According to the datasheet, that is exactly what you expect from it. It isn't a rail-to-rail op-amp. Won't matter in this case.

Output Voltage?High Limit for Vcc=5V: Typical: 3.5V