Radio Control Servo Driver

This page describes how to generate the servo pulse that an RC receiver generates to drive a servo - so that thye flight computer can control a servo directly.

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 you will need to provide a separate 6v battery with a common ground connection - I don't encourage sharing the servo's supply with the flight computer's. The white wire is the signal wire, it can be driven by an output bit on one of the ports and needs a 4k7 pullup resistor:

The driver software is here. When you call it you pass the width of the pulse you want to generate in R1:R0 - it's measured in 11/12 uS (12th the cpu clock frequency) - 0x3c0 seems to give one limit and 0x630 roughly the other (note that the whole RC system is rather analog - people use trim pots to zero servos - you will have to do this yourself in software). The output routine generates a single servo pule everytime you call it - it used timer #0 to generate it and leaves the timer idle when it's done. You must call the routine every 20mS or so - you can use the internal interrupt driven millisecond counter to do this:

	mov	tcountl, #20		; 20mS
	< go off and do something usefull>
l1:	mov	a, tcount		; wait for completion
	cjne	a, #0, l1