Decoding PPM From RC Receiver Revisited

Back to square one for me. MEM are you listening? I seem to have gotten off track in my quest to be able to read the Pulse Stream from an RC Receiver and then sending that to an Arduino and finally having the Arduino send the servos their proper commands.

I am in need of a way to be able to read the signal on the receiver(either at the PPM point or at the receiver connectors for the servos), then process that to the serial monitor so I can see the values of the channels change as the sticks/knobs are moved. I have used the ServoDecode library but it seems that all that does is capture the channel data and print it out on the serial monitor and defaults it to 1500. No changes to the values as the sticks/knobs on the transmitter are moved. I have tried pulseIn as well but I must be doing something wrong because there is no change to the values.

This is for a project to build and fly a quadcopter.

Jim

Hi Jim, how did you arrive back at square one? I thought last week you were decoding the pulses OK as per your last post here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1229454415/4#4

BTW, would it not have been better to add to that thread rather than start a new one?

Anyway, clarify what was working and what has stopped working and I will try to help.

// ServoDecodeTest[/

#include <ServoDecode.h>
[/color] setup() // run once, when the sketch starts
{
Serial.begin(38400);
ServoDecode.begin();

//setFailsafe() can set a pulse width for a channel if the Tx signal is lost.
//By default all channels not explicitly set will hold the last good signal
ServoDecode.setFailsafe(3,1234); // set channel 3 failsafe pulse width
}

void loop()
{
int pulsewidth;

// print the decoder state
if( ServoDecode.getState()!= READY_state) {
Serial.print("The decoder is ");
Serial.println(stateStrings[ServoDecode.getState()]);
for ( int i =0; i <=MAX_CHANNELS; i++ ){ // print the status of the first four channels
Serial.print("Cx");
Serial.print(i);
Serial.print("= ");
pulsewidth = ServoDecode.GetChannelPulseWidth(i);
Serial.print(pulsewidth);
Serial.print(" ");
}
Serial.println("");
}
else {
// decoder is ready, print the channel pulse widths
for ( int i =1; i <=MAX_CHANNELS; i++ ){ // print the status of the first four channels
Serial.print("Ch");
Serial.print(i);
Serial.print("= ");
pulsewidth = ServoDecode.GetChannelPulseWidth(i);
Serial.print(pulsewidth);
Serial.print(" ");
}
Serial.println("");
}
delay(500); // update 2 times a second
}

Hey MEM,

I just don't know if I am just confused ::)or expecting too much from the effort I have expended.

This sketch I have included works fine except that it does not update the serial monitor with the new values of the pulsewidths when I move the sticks or knobs. Is it supposed to show a running display of the values? I suspect not. :-/

What I would like to do is to have the PPM Stream decoded like above, but show me the pulsewidth values as they change. Other than that, this Decode works well.

Thank you for looking and Cheers.

Jim

Hi Jim,

If the channels values print as Cx1=1500 then you are in failsafe mode, the decoder is not getting valid channel data so it wont change

If you are getting Ch1=1500 then this should be valid data.

Yes, I am getting the CH 1= 1500.

Why does the value not change when the stick is moved to show another position other than centered. Maybe I am misunderstanding whether this should be changing as the sticks change position.

If I have the transmitter on and the channel 1 stick untouched, The value is 1500.
If I move the channel1 stick to the left side, the value remains at 1500. I thought the value should rise or fall on any other side of center stick.

Thanks again.

Jim

Yes, the pulse width should change as the stick changes. Does a servo on that channel follow the stick movement?

Yes sir. :smiley: :DIt is connected directly to the receiver, and the receiver connected to the Arduino.. I don't know what magic you have done just by your input, but it now seems to be working. I had no idea the servo had to be connected to the receiver in order to show a change. Periodically though, a spurious number of around 22200 pops up at the end of the channel count but the functioning of the receiver and servo do not appear to be affected by this.

Thank you so very much and it should be quite late there so why don't you get some sleep?

Jim

Hi Jim,

The servo suggestion was just to test that the receiver was responding to the stick movements, it should make no difference to the functioning of the decode software. If it is, then perhaps there is some intermittent wiring that is affecting the operation. Double check that everything is connected up reliably.

Good morning to you MEM. Merry Christmas and thank you again for the help.

Nope still does not show value changes with the servo removed from the system. I have a solder joint set up for the connection to the arduino and a servo plug from the receiver to the arduino. Re flowed all solder joints too. Without the servo....no changes...with the servo...changes. The servo has its own power and that in turn is grounded to the arduino. Go Figure.

Now to be able to use the decoded string and do processing on the pulse stream(Gyros/Accel,,). Could you point me in a direction to proceed?

Jim

It could be that the receiver's servo control output pins are open collector and require a pull-up resistor that's being supplied when the servo is hooked up. Try adding a pull-up resistor on the Arduino (even the internal soft pull-up may work) and see if you can read the servo pulse then without a servo hooked to the receiver.

Lefty

Hi Lefty,

Well the progress I made last night went down the drain today. Now it won't read the changing values again whether the servo is attached or not. I will try a pull down resistor if you can recommend a value. Do I connect it to the output from the receiver before it gets to the Arduino?

Thanks in advance. I am ready to stomp this thing it is so frustrating. >:(
Jim

Add the following to your setup code to enable the pullup resistor on pin 8
digitalWrite(8, HIGH); // turn on pullup resistor on pin 8

I wonder if your problem is due to the way you are tapping the signal off your receiver. Can you post a diagram of how you have the receiver, servo, and Arduino connected.

Hi MEM,

I just do not know why it worked last night and then not today. The only difference between last night and today was that I turned everything off and went to bed. I left everything except the power hooked up. I cannot figure how to make up a diagram for the forum so let me describe how everything is connected:

I have a BBB board from Modern Device. I have the USB cable and connect it to the proper pins. I then have the signal wire connected to Pin 8 and the opposite end connected in to pin 7 of the 4015 chip on the Futaba FP-R148DF. Anyway it is the second pin to the right of the big dot that is embossed on the chip) this was the only wire that had a steady stream of values when I went snooping on the circuit.

The ground between the receiver and the arduino are connected. I have a Nicad battery that supplies power to the receiver at the battery pin on the receiver so the arduino gets power from the USB, and the receiver and servos, when they are connected, get their power from the battery. Servos, when I connect them for this test, are connected to the receiver pins.

Once I start the code I get the acquiring reading and then the challel outputs all go to 1500 and remain there regardless of the stick position. If I turn the transmitter off, The serial monitor then tells me it is fAILSAFE and the channel values go to Cx1=1500... Turning the transmitter back on the values go to C=1500(?) and they stay there.

I have another piece of code I have used to test the output at the channel pins using pulseIn and they all work fine. The servos move as they are supposed to on both sketches.

I tried the pullup resistor code you provided, but no joy yet.

I am really perplexed. Have re-compiled this sketch and run it but I always get the same result.

Sounds like you are connected to pin 14 – depending on how Futaba has wired the 4015, pin 14 or pins 7 could be the input. FYI, there is a diagram of the 4015 here: http://www.doctronics.co.uk/4015.htm

It may be worth you modifying the pulseIn code you tried so that it reports the pulse widths on pin 8. Perhaps write a sketch that sends the width of eight consecutive pulses (or however many your tx is sending) to the serial port.

Something like this pseudo code:

Capture the width of a pulse
Wait for a pulse greater than 3 microsecondes (you are waiting for the end of the sync pulse)
Now store the value of the next 8 pulses (I think yr Rx has 8 channels )
Send the pulse widths to the serial port
Wait for a second
Repeat

You should then be able to see what kind of pulses are being received on pin 8. If you never get a pulse greater than 3 microseconds then the pulse stream may be inverted. The ServoDecode logic handles this automatically, but your test code may need pulseIn(LOW) instead of the expected pulseIn(HIGH)

You are looking for a waveform that should be something like this:

This one was captured from a six channel receiver, yours should have more pulses.

If you still have problems, it may be worth rigging up a scope using your sound card and one of the many free downloads. Google oscilloscope sound card

Hi MEM,

Well I got a great Christmas present. I went back and started troubleshooting from the very beginning. I also went to the site for the BU4015BF chip on the receiver. I then went back to the receiver and starting checking the pins..

I now have the whole thing working. The problem was that I had the wrong pin connected to Pin8.
Last night when it began working, it seems I inadvertantly :-*touched the wire to the proper pin and it worked. It is now connected to Pin1 of the chip and I had it soldered up to the the second pin last night which makes it really pin 2.

Anyway. Thank you for all the help and now I move to the next phase:......getting the captured pulse train doing something useful--like moving servos on command.

Merry Christmas.

Jim

Jim , great to hear you have it going, looking forward to reading about progress with your project.

Have fun!

Yes sir got it running.

Thank you again for the assistance. You really gave me a clue when you said to check the interface connection. :smiley:

Jim