Radio Control Input Driver

This page describes how to sample the servo pulse from an RC receiver to get a 16-bit number that is proportional to the width of the servo pulse (ie the value returned depends on the stick position on the transmitter).

Radio control servos are sent a signal from the receiver that consists of a single pulse who's width varies from ~1mS to ~2mS depending on the stick position. This signal is repeated every 20mS. The servo connections are through 3 wires, buy an extender and cut off the end, the black wire is ground, the red wire is 6v (cut this and tape it we will not be using it - make sure it can't short anything), the white wire is the signal wire, it needs to be driven through a resistor with a protection diode such as an 1N4001 to the flight computer's 5v power rail (the end with the band goes to 5v):

The one real pain in putting this together is that the software needs to use one of the internal timers (#0) so that it's timing is not effected by interrupts - this means that we have to us a particular external pin P3.2 which on the Rev 1.0 flight computer is connected to the pyro driver that does not come out on the main connector (and is often used as a soft safe/arm) - to use it you must either remove the transistor/resistor pair T1/R3 (the ones furthest from the bottom, closest to the 80C32) or cut the trace that leads to them (it's connected to the R3 pad closest to the transistor, there's another trace parallel and to the left of it, be carefull not to cut that one. The pad of R3 closest to the transistor can be connected to an unused 80C32 Px.x pin with a wire if you want to use it.

P3.2 is pin 12 on the 80C32, there is an uncommitted pad connected to it right beside it, there is a 5V pad for the diode 6 pads below it, there is a free GND pad near pin 1 of the 80C32.

The driver software is here I'll eventually add it into the ROM through the utility interface and provide a hook you can call to get at it. Each time you call it it waits for the rising edge of the servo pulse and uses the timer #0 to count how long the pulse is, it returns a value with the msb in R1 and the lsb in R0 in units of 11/12 of a microsecond (1/12 of the chip's crystal frequency), this seems to return a range of values from roughly 0x3c0 for short pulses to 0x630 for long pulses (on my RC gear your's may vary). Calling this routine can take up to 20mS before a pulse goes by - if no pulse is or too long a pulse is seen then it returns 0. The timing numbers returned here are in ~microsecond units - this is way too accurate for the signal we are measuring - you should expect the lower bits of the returned value to dance around in the noise.