RC Input to Propeller
Greg Norton
Posts: 70
I have an application where I'd like to receive 3 channels of RC input to the Propeller. My goal is to have 2 channels of directional input (from the right stick of the transmitter), and one on/off type input from one of the switches on the transmitter (normally used for landing gear on an RC plane). These are designated a channels 1,2, and 6 on the RC receiver.
The problem I'm having is with the InputServosRC object from the exchange. I can get the first two channel inputs to the propeller to work fine and show inputs from the right stick on the transmitter. However, I cannot get the 3rd input to the propeller working unless I connect it to the 3rd channel of the RC receiver.
Here's a diagram to try and clarify the situation. The following DOES work. My example program (see attached) shows expected values. I slightly modified InputServosRC to try and figure out where the problem lies.
RC Receiver Channel => Prop Input Pin
Channel 1 => Pin 8
Channel 2 => Pin 9
Channel 3 => Pin 10
The following DOES NOT work.
RC Receiver Channel => Prop Input Pin
Channel 1 => Pin 8
Channel 2 => Pin 9
Channel 6 => Pin 10
When I try the failing case, my program shows all 0 values, including the status value. I'm not even sure how this is possible. I have examined the output of the RC receiver channel 6 and it shows what I expect. The pulse width is 1.0 - 2.0 ms depending on the position of the switch. My examination of InputServosRC does not lead me to believe there is any requirement to use sequential channels from the RC receiver, but this seems to be the case so far.
Anyone have a suggestion on this?
Thanks.
Greg
The problem I'm having is with the InputServosRC object from the exchange. I can get the first two channel inputs to the propeller to work fine and show inputs from the right stick on the transmitter. However, I cannot get the 3rd input to the propeller working unless I connect it to the 3rd channel of the RC receiver.
Here's a diagram to try and clarify the situation. The following DOES work. My example program (see attached) shows expected values. I slightly modified InputServosRC to try and figure out where the problem lies.
RC Receiver Channel => Prop Input Pin
Channel 1 => Pin 8
Channel 2 => Pin 9
Channel 3 => Pin 10
The following DOES NOT work.
RC Receiver Channel => Prop Input Pin
Channel 1 => Pin 8
Channel 2 => Pin 9
Channel 6 => Pin 10
When I try the failing case, my program shows all 0 values, including the status value. I'm not even sure how this is possible. I have examined the output of the RC receiver channel 6 and it shows what I expect. The pulse width is 1.0 - 2.0 ms depending on the position of the switch. My examination of InputServosRC does not lead me to believe there is any requirement to use sequential channels from the RC receiver, but this seems to be the case so far.
Anyone have a suggestion on this?
Thanks.
Greg
Comments
What transmitter and receiver are you using? Probably does not make a difference but would be nice to know. I can try to set up same senario on my Hitec Optic 6 Xmiter and Hitec Micro 05S receiver and let you know what happens.
Jim
the doc of the InputServosRC_v1.0.spin-files says
....
In order for a series
of pulses to be considered valid, every channel starting at 'FirstPin' and
ending at 'FirstPin' + 'Total' must receive a valid pulse, and be in sequential
order. If any channels from the radio receiver to the Propeller are
disconnected, or connected out of order, no pulse sequences will be considered
valid.....
So I think this is what's happening.
if there is a time-gap between the pulse for channel 2 and channel 6
(because inbetween the pulses for channel 3-5 are sended) the calculation of the pulse-length is out of range
To handle this you have to modify the object that every channel has it's own variables for the snapshot of cnt
for the rising edge. The falling edge is the actual value of cnt itself
The driver as it is uses the ONE variable "LastCnt" for the snapshot of the rising edge.
best regards
Stefan
Joel-
Donald
There's another glitch.· In my case, I was using gyroscopes in line with the RX outputs, and the output from the gyroscopes were not perfectly periodic even if the receiver was.· Therefore, at any given instant, the signals could have one timing relationship where the signals do not overlap and another cycle at some future time the signals could overlap. If you already know exactly what the input will look like, then you can optimize for that.· If you're trying to make a product that works with everything available,·then you have to design it to be more robust.· In my case, I was making a product that was meant to interface to everyone's receiver, not just the one I had on my shelf.
I don't know if Greg needs anything this robust or not.· I decided to mention it to help others who might pursue building a device that needs a bullet proof front end such as this.· It all depends on what you're doing.· Some people might choose to simply filter the glitches out with software.· I'd prefer to eliminate the glitch at the source.
Joel-
·
I found out through experimentation what StefanL38 pointed out from the comments (should have read them more closely ).· Looking at waveforms on the outputs of the receiver showed that the sequential channels share a falling/rising edge.· That is, the falling edge of the channel 1 pulse is the same as the rising of the channel 2 pulse.· The code was designed for this and was only looking for falling edges of pulses after the initial rising edge from channel 1.· I modified the code to look for a rising edge on each of the additional channels and then do the measurement based on that.· This could be causing me to miss the rising edge of channel 2, but then channel 2·will be·measured·on the next set of pulses from the receiver.· I'll have to check this out when I get home.· My application is a fairly slow moving robot so I can afford the degraded refresh rate that results.
Greg
http://forums.parallax.com/showthread.php?p=690465
His comments imply that it gets 1uS resolution, but it's actually 1/4 that (he's assuming 1 instruction per clock, but it's every 4 clocks), so you get about 250 steps over the 1ms range for all 8 inputs.
That said, if you modify the code to handle only 4 inputs, you can double the precision, and run two cogs to sample 4 pins each.· My quad-rotor is using this code modified to handle 6 inputs (gets me a little more precision) and it's great.
·
Donald