milliseconds in duration. That said, all we have to do is wait
for a low-going pulse that is longer than a servo position
pulse; this will let us know we’ve found the sync pulse.
pulseTmr = 0
DO WHILE PPM = 0
IF pulseTmr < 400 THEN WAIT_SYNC
The subroutine called WAIT_SYNC takes care of this.
The routine starts by clearing a timer variable (pulse Tmr)
and then dropping into a loop that monitors the PPM
input for being low. As long as this input stays low, the
timer will be incremented every 10 microseconds. Note
that timing doesn’t have to be super precise here; all we’re
looking for is a low pulse that couldn’t be a position value.
When the PPM line goes high, loop terminates and
the timer value is checked; if we find a pulse greater
than about four milliseconds, we know that we have sync
and we can return to the caller. If we happen to catch a
position pulse, the routine will run again.
On start-up, we’ll clear the servo outputs and then
check the mode input jumper. As RA.1 has the internal
pull-up enabled, we’ll see a “1” on RA.1 when in standard
servo mode, or a “0” when in what I’m calling “servo
plus” mode. Let’s look at standard mode first.
SvoPort = %00000000
IF MJumper = 0 THEN Servo_Plus
‘ Standard servo control
svoPntr = %0000_0001
SvoPort = svoPntr
svoPntr = svoPntr << 1
LOOP UNTIL svoPntr = %0100_0000
■ FIGURE 2. VEX Decoder Schematic.
May 2008 17