Connect Radio Control transmiter (Futaba/Hitec using Trainer cable) to BS2
migudono
Posts: 14
Hi masters ...
My problem: I'm trying tro connect a RC Radio Control (using Trainer cable Futaba or Hitec) to BS2.
Using PULSIN command looks like capture some channels others looks like fixed or erratic
Any Idea to resolve this problem? (thaks for your help)
The code >>>>>>>>>>>>>>>>>>
' {$STAMP BS2e}
' {$PBASIC 2.5}
'
Ch1 PIN 8 ' TRAINER CABLE CONNECTED ALMOST DIRECTLY TO THIS PIN (RESISTENCE 2OO OHM)
cuenta VAR Byte
drive VAR Word(8) ' ( I HOPE READ 8 CHANNELS FROM THE RADIO CABLE)
begin:
DO
FOR cuenta = 0 TO 7
PULSIN Ch1 , 1 , drive(cuenta)
NEXT
FOR cuenta = 0 TO 7
DEBUG DEC drive(cuenta) , TAB
NEXT
DEBUG CR
PAUSE 100
LOOP
My problem: I'm trying tro connect a RC Radio Control (using Trainer cable Futaba or Hitec) to BS2.
Using PULSIN command looks like capture some channels others looks like fixed or erratic
Any Idea to resolve this problem? (thaks for your help)
The code >>>>>>>>>>>>>>>>>>
' {$STAMP BS2e}
' {$PBASIC 2.5}
'
Ch1 PIN 8 ' TRAINER CABLE CONNECTED ALMOST DIRECTLY TO THIS PIN (RESISTENCE 2OO OHM)
cuenta VAR Byte
drive VAR Word(8) ' ( I HOPE READ 8 CHANNELS FROM THE RADIO CABLE)
begin:
DO
FOR cuenta = 0 TO 7
PULSIN Ch1 , 1 , drive(cuenta)
NEXT
FOR cuenta = 0 TO 7
DEBUG DEC drive(cuenta) , TAB
NEXT
DEBUG CR
PAUSE 100
LOOP
Comments
I think the time between pulses is too short to catch them all.
I have an old program to do something like this on a Propeller. Looking at the notes inside the program, it looks like the timing is different than the normal servo pulse. My program suggests instead of pulses being between 1000us and 2000us, they're between 600us and 1600us. Does that sound right? I don't remember how much time there is between the pulses. I'm pretty sure it's much less than 20ms.
So one guess is the BS2 isn't fast enough to catch the beginning of the next pulse in the series but I'm not sure about this. One problem I do see with your program is there isn't a way for the program to tell which channel is which. I suppose if the BS2 were turned on before the transmitter, then it might be able to start out synchronized with the pulses but I suspect your debug statement will throw the program out of sync rather quickly.
I'm not sure how to remedy the problem if your program is loosing sync.
I'm inclined to think you're asking the BS2 to do more than it's capable of (though I'm not sure about this).
BTW, The Propeller is a great match for all sorts of RC and servo projects. The Prop can easily capture the input pulses from a bunch of different inputs from a RC receiver and the Propeller can drive up to 32 servos without additional components. The Propeller wouldn't have any trouble capturing the input from a trainer signal (I've done this myself).
I'm not sure if you're aware of how trainer cables work with RC gear. The trainer cable transmits each of the TX's channels as pulses one after another. So rather than being able to use a separate pin to receive the various channels, the order the pulses are sent designate which channel is which.
To capture a trainer signal, I think one would need to monitor the line to make sure it has been low for a set amount of time (I don't recall how long the line is idle, I'm betting a couple milliseconds). Once this idle zone has been detected, then the first high pulse can be assumed to be for the first channel. The subsequent channels could also be captured. I'm starting to think this would be possible with a BS2.
I think the code in post #1 should be pretty close to what would work. I think there needs to be a way of measuring a low pulse and comparing the low pulse to some set value before the first FOR/NEXT loop executes.
It's pretty much the same as the original code but with a pulsin checking for a long low time. I don't know if I have the constant "MINIMUM_LOW" set to a correct value. I'm also not sure of the "IF THEN GOTO" syntax.
Is a pulsein of 1000 2ms with a BS2e? I assumed it was so keep that in mind.
I must comment about the spead of BS2 to read the signal....When I change the code from
PULSIN Ch1 , 1 , drive(cuenta) to PULSIN Ch1 , 0 , drive(cuenta) ...the value readed is the same for all channel ...I can supose the readed value is separation between channels ...but it's only a supposition
another strange thing ....the code look like don't need sincronization....but read some channel in consistent way
Well, thaks for your help
In fact, the code attached to your post was the base to begin my own code, but your code have 2 input pin, one for each channel,
The trainner cable I thing he needs only one pin , the signal have all channels
Thank for your help
I think you're probably right about the channel separations all being the same. What if you tried increasing the number of channels read to 9 or 10? I'd be interested to see if one of the separations is longer than the others. This would be a temporary change just to learn more about the signal.
Does the "PULSIN pin, 1, variable" statement wait for a low to high transition? I bet it does. In which case the first high pulse will be entirely missed by the code in post #5.
I still think there's a way to do this with a BS2 but I don't think the code I posted will work.
You're right, I assumed it was coming from a receiver where you could pick each channel.
Here it's attached an image with the signal "format", captured from and Homepage of RC hobbyst (ufff so bad english...LOL)
The short separation pulses reported in post #6 are likely 400us (based on my own experience trying to read a trainer signal a few years ago).
If in the inverted signal, the blank time is high, then instead of reading six pulses, seven pulses could be read. The seven pulses could then be checked to see which is the blank time and the remaining pulses could be assigned their appropriate channels based on their relationship with the blank time.
You'll miss frames during the sort algorithm and you'll also lose frame during the debug statement. My (wild) guess is that maybe one in four frames could be captured this way. If you could do away with the debug, then maybe one in two frames could be captured (another wild guess).
Yes ...I considered this point, because the read stage is inside from the first For-Next loop without slow step, and the output (Debug) stage is inside the second for-next loop. Obviously ....when the problem will be resolved, the output stage will be replaced
Another thing ....I understood, from the signal diagram, that the duration of complete pulse (6 channels + sinc) is arround 20 mili Sec...and reading the manual I undertood that de minimal resolution from PIN command it's in micro sec, so... how is possible basic stamp don't be able or slow to capture correctly the wide pulses? (but maybe some channel really could be losted)
but a last issue
this example obtained from the code editor, read correctly the number 1 channel ... without sinc loop, without make an explicit reffers to number one channel or without IF statement for wait a sinc value
when I did write the logic code to expand the reading to more channels, don't read more channels, only repeted the first
' {$STAMP BS2}
' {$PBASIC 2.5}
Pulse PIN 7 ' pulse input pin
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
Scale CON $200 ' 2.0 us per unit
#CASE BS2SX, BS2P, BS2PX
Scale CON $0CC ' 0.8 us per unit
#ENDSELECT
time VAR Word
Main:
PULSIN Pulse, 1, time ' measure positive pulse
IF (time > 0) THEN ' if not 0
DEBUG HOME,
DEC time, " units ", CLREOL ' display raw input
time = time */ Scale ' adjust for Stamp
DEBUG CR,
DEC time, " us " ' display microseconds
ELSE
DEBUG CLS, "Out of Range" ' else error message
ENDIF
PAUSE 200
GOTO Main
END
There are seven channels on the DX7 but there are eight pulses plus the sync pulse being sent on the trainer line. I think the last pulse is a calibration aid but I'm not sure. I do know the final pulse does get transmitted.
The original trace had a negative voltage. I inverted the oscilloscope connections since I figured the BS2 would prefer not to have negative voltage attached to the pins.
I attempted to capture the pulses with a BS2 but it didn't work All the pulse length were reported as zero. I don't think the BS2 was able to read the low voltage level. The pulses were barely over one volt.
I am curious if your radio also sends an extra pulse so instead of sampling seven pulses try eight to see if you can capture the long sync pulse.
Thanks for your interest
I did read the cable voltage from a Futaba radio and Hitec and was around 5V or more. The information about the Futaba cable I have, it's only that was I attached some post days ago.
Furthermore, I can comment that, I have a USB cable for connect Radio to PC, for a simulator game. The USB connector have an IC labeled em78m612damj , and I will attach the datasheet link if someone can understand how is read (readed?) the cable signal. It powered from the PC.
http://pdf1.alldatasheet.com/datasheet-pdf/view/113351/EMC/EM78M612DAM.html
Looks like its going to be the receiver method until someone cracks the trainer cable.
You would need at least 1.4V to read a high on the BS2 input.