Discussion forum for the BasicX family of microcontroller chips.
Vex: R/C signal generator - Tom Becker - Jun 3 14:15:06 2007
For some time, I've been intending to assemble a joystick and
processor to generate a standard R/C ~1.5mS/50Hz PWM stream. I did
not need the RF link of a transmitter-receiver pair; I just wanted
the receiver modulation output, in effect, a signal that can be easily
read with the InputCapture function.
As it happens, the Vex 6-channel R/C transmitter makes its transmitter
modulation available on a tether connector, and two shorted pins on
the same mutes the transmitter RF. Ordinarily, this would be an
expensive solution, but the Vex transmitter/receiver pair has been
dumped in quantity, apparently, and are available at All Electronics
(search for JS-6) (US$30) http://www.allelectronics.com and
American Scientific ($25)
http://www.sciplus.com/singleItem.cfm?terms=13223 .
Servo Magazine has a current article that mentions these, too. The
joysticks, alone, are worth the money. FYI.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Vex: R/C signal generator - Tom Becker - Jun 4 20:26:26 2007
FWIW, the R/C channel pulses produced by the Vex are not standard;
they are 25% short. Center stick is, conventionally, 1.5mS and the
channel extremes are typically 1.0mS and 2.0mS. The Vex produces
1.125mS when centered, ranging from ~0.7mS to ~1.5mS.
Multiplying the Vex channel pulse width (from InputCapture) by
4/3=1.333 will yield a signal that centers a conventional servo.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Vex: R/C signal generator - Tom Becker - Jun 6 21:25:04 2007
Here's some code for the Vex. It takes a pulse frame of six channels
from either the Vex receiver or the Vex transmitter tether port, both
open-collector, via BX-24 pin 12, the InputCapture pin. This code
repeatedly converts six pertinent periods to a normalized -1.0 to +1.0
range. Six channels, four analog joystick axes and two pushbutton
digital, appear in variable sChannel().
One could take a channel's data and drive a servo using PulseOut, but
both InputCapture and PulseOut use Timer1 so they could not occur
concurrently, and more than one servo would be more problematic. I like
the notion of using this as an internal variable controller - wired or
R/C wireless - to steer algorithm values by joystick, instead of an
incomplete R/C servo system.
For $25, I expect this will be a useful toy.
Tom
' Vex R/C data for BX-24
' 20070604 GTBecker
const pinRC_Stream_In as byte = 12 ' InputCapture pin, uses
Timer1
dim uiRCPulsePeriods(1 to 12) as new unsignedinteger, _
sChannel(1 to 6) as single
const sNormal as single = 1.333 ' Vex pulse is 25% shorter than
standard
Sub Main()
dim b as byte
Call PutPin(pinRC_Stream_In, bxInputPullup) ' open collector
pullup
do
call WaitForSync ' ~55Hz frame
call InputCapture(uiRCPulsePeriods, 12, 1) ' 12 periods from
6 channel pulses, rising start
for b = 1 to 6 ' normalize low pulse periods to -1.0 to +1.0
sChannel(b) = (csng(uiRCPulsePeriods(b * 2) ) * sNormal /
7372800.0 - 0.0015) / 0.0005
next
debug.print fmt(sChannel(1), 3) &" " ; ' show 6 channel
values
debug.print fmt(sChannel(2), 3) &" " ;
debug.print fmt(sChannel(3), 3) &" " ;
debug.print fmt(sChannel(4), 3) &" " ;
debug.print fmt(sChannel(5), 3) &" " ;
debug.print fmt(sChannel(6), 3)
loop
end sub
sub WaitForSync()
dim lT0 as long
lT0 = register.rtctick
do
if cbool(getpin(pinRC_Stream_In)) then ' restart timeout if
pulse high
lT0 = register.rtctick
end if
loop until register.rtctick - lT0 > 1 ' wait until > two ticks
(~4mS) low
end sub

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )
Re: Vex: R/C signal generator - Tom Becker - Jul 10 13:33:51 2007
I was incorrect about the Vex standard pulse widths, which I said were
25% short; I had not included the high period of the pulse cycle to
determine the channel value. In fact, both the high and low periods
of each channel should be summed, essentially measuring rising-edge to
rising-edge instead of falling-edge to rising-edge, like:
for b = 1 to 6 ' normalize low pulse periods to -1.0 to +1.0
sChannel(b) = (csng(uiRCPulsePeriods(b * 2) + uiRCPulsePeriods(b * 2 -
1)) / 7372800.0 - 0.0015) / 0.0005
next
This removes the need for normalization.
Tom

(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )