Decoding Radio Control signal pulses

Another try:

// ServoDecodeTest
#include 
#include   // the servo library


// define the servo pins
#define servo1Pin  2   // the pin the servo is attached to
#define servo2Pin  3

ServoTimer2 servo1;    // declare variables for the servos
ServoTimer2 servo2;

void setup()
{
 Serial.begin(38400);
 servo1.attach(servo1Pin);
 servo2.attach(servo2Pin);
 ServoDecode.begin();
}


void loop()
{
 int pulsewidth;  //[MAX_CHANNELS];

 if( ServoDecode.getState()!= READY_state) {
   Serial.println("The decoder is not ready");
 }
 else {
   // decoder is ready, do somthing with the channel pulse widths
   servo1.write(ServoDecode.GetChannelPulseWidth(1));
 }
}

Here something happens but the servo flutteres.

Any ideas? Thank you :)

try adding delay(20) at the end of loop.

No, does not help. Still fluttering.

BTW Why can't I use the Servo Library that comes with Arduino?

Cheers Alexander

Sorry, I got the solution: the composit signal from the sat Extension of the RX sent a bad signal I connected the original Sat (that has no other task than giving that signal) and it works OK. Still a little noise but acceptable.

Still one open question: why can't I use the regular servo lib that comes with Arduino 0018?

Cheers Alexander

Good to hear you have it going. I still recommend adding the delay(20) in loop.

The standard servo library uses the same timer as the ServoDecode library so only one of them will run on an Atmega168 or 328. ServoTimer2 was written to use a different timer so it will work with ServoDecode on standard Arduino boards.

But you can use the standard library if you have a Mega board (see earlier in the thread for getting ServoDecode working on the Mega.

Thank you.

Since I want to learn: what is the idea behind using the delay(20)?

Cheers Alexander

The servo library will update the servo every 20 milliseconds, writing to the servo more frequently does not improve performance.

Indeed, constantly rewriting values much more frequently than necessary can actually slow things down.

Thank you,

the code will - of course - get more complex in the future. This was just a basic test and it works. Unfortunately the composit signal that the receiver is supposed to deliver is faulty. Using the basic Satellite works though. So I go on with my tests.

Cheers Alexander

Wow, this thread has been active for (almost) 2 years! [ch61514]

I have read through the entire thing, and I have learned a lot, which also means that it has raised a lot of questions.

Can I use this decoding method if I OR together several RC receiver channels together with diodes? Here is a schematic of what I am thinking of. I took it from the wiki page on diodes and modified it for my plans. http://www.vinceherman.net/robot/media/OrDiodes.JPG

I have successfully decoded individual channels using attachinterrupt on 6 channels. But that maxes out the number if pins available on my Mega for using the attachinterrupt. I would rather just use 1 pin, even if it is just for 4 channels. In the future I am sure I will want more channels.

I guess I need to go through my box'o'parts and see if any of them are diodes. If not, where do I order, and anyone have recommendation on what type? I have not ordered much in the way of individual electronic components.

Am I on the right track? Where can I get current versions of the ServoDecode library?

vinceherman, I don't think that will work because most RC receivers do not have a break between one channel going low and the next going high. In that case the signal will simply remain high from the start of the first channel to the end of the last and no valid decoding will occur.

I have thought about the possibility of using an or gate to trigger a monostable circuit (google 555 timer) but have not had the time to try anything along those lines. Perhaps somone else here has?

The code at the start of the thread is the latest version, with a modification posted in reply #70 to use timer4 if you have a Mega board so ServoDecode can be used with the standard servo library

Thanks for the quick reply. Do you think I can put all the odd number channels on one pin, and the evens on another, so that I do get a break? Or if I put 1,3 and 5 on one pin, can I use the low signal time as the duration of the even channels?

Separating odd and even channels could work although it would require very significant rework of the library to support this.

I don’t have the time to look into this but would be happy to assist if someone comfortable working with timer interrupts wants to try and get this going.

But in my opinion, its much less effort to modify a suitable RC receiver to get access to the PPM stream so it can be decoded by the current code.

Since I aked a lot I just want to give a short update. Yes. Arduino does a perfect job for RC models. I started with a fully programmable Gear Door Sequencer that can handel as mans Servos as pins are available.

Every delay and speed of each servo can be individually set.

This is the init of the servos shown on the video below.

  // Prepare Servo Parameters and timings
  gearParameters[sNosegear].servoPin = 2;
  gearParameters[sNosegear].upPos_us = 1000;
  gearParameters[sNosegear].downPos_us = 2000;
  gearParameters[sNosegear].delays[GEAR_UP].wait_ms = 100;
  gearParameters[sNosegear].delays[GEAR_UP].delay_ms = 4000;
  gearParameters[sNosegear].delays[GEAR_DOWN].wait_ms = 7500;
  gearParameters[sNosegear].delays[GEAR_DOWN].delay_ms = 4000;

  gearParameters[sNoseDoor].servoPin = 4;
  gearParameters[sNoseDoor].upPos_us = 1000;
  gearParameters[sNoseDoor].downPos_us = 2000;
  gearParameters[sNoseDoor].delays[GEAR_UP].wait_ms = 4500;
  gearParameters[sNoseDoor].delays[GEAR_UP].delay_ms = 750;
  gearParameters[sNoseDoor].delays[GEAR_DOWN].wait_ms = 6700;
  gearParameters[sNoseDoor].delays[GEAR_DOWN].delay_ms = 750;

  gearParameters[sMainGear].servoPin = 3;
  gearParameters[sMainGear].upPos_us = 800;
  gearParameters[sMainGear].downPos_us = 2200;
  gearParameters[sMainGear].delays[GEAR_UP].wait_ms = 100;
  gearParameters[sMainGear].delays[GEAR_UP].delay_ms = 5000;
  gearParameters[sMainGear].delays[GEAR_DOWN].wait_ms = 1000; // Wait for door to open
  gearParameters[sMainGear].delays[GEAR_DOWN].delay_ms = 5000;

  gearParameters[sMainDoor].servoPin = 5;
  gearParameters[sMainDoor].upPos_us = 800;
  gearParameters[sMainDoor].downPos_us = 2000;
  gearParameters[sMainDoor].delays[GEAR_UP].wait_ms = 5500;
  gearParameters[sMainDoor].delays[GEAR_UP].delay_ms = 750;
  gearParameters[sMainDoor].delays[GEAR_DOWN].wait_ms = 100;
  gearParameters[sMainDoor].delays[GEAR_DOWN].delay_ms = 750;

Here it is in action:

http://www.youtube.com/watch?v=VtJAJNm8W8k

I plan to add a swicth that tells Arduino if the gear is up to prevent damage if the switch on the TX is set to down and the gear is actually down or vice versa.

Downside: I cannot use the Decoding lib as I had hoped. The PPM signal of the Jeti R10, R14 or R18 is not sufficient. BTW it is also not sufficient to use it in the way Jeti intended it, that one RX can serve as a satellite in case of signal loss. I did some more investigation and observed the same behaviour: wild servo movements if the Sat signal from the other RX is used.

But I am totally happy that I stumbled into Ardino.

And thank you mem for your initial suppport :)

Cheers Alexander

Looks good, can't wait to see a video of it installed in the DC-6.

I am curious why the PPM signal was unable to be decoded by Arduino. Do you have any technical information on the JETI PPM output (or a scope trace showing the voltage levels and timing)

Thank you mem. Well I guess you have to be patient.

If you're interestes please follow my build thread on rcgroups.com

http://www.rcgroups.com/forums/showthread.php?t=1116302&page=31#post15520864

Regarding the PPM signal. I don't have the electronic knowledge. That's why I use Arduino ;)

But to me it looks like a Problem on the Jeti Receiver. Another Jeti receiver isn't either capable to deal with the signal and shows the same weird behaviour of the servos when forcing it into signal loss.

I forwarded it to Jeti and let's see.

Cheers Alexander

I have subscribed to your rcgroups thread and will follow it with interest.

If you get any info from JETI (or if anyone else with one of those receivers has a scope) I will see if I can help get it working with the library.

Thank you for our interest!

I'll post information here if I find something on the Jeti issue.

Cheers Alexander

Hi all, It's my first post on this Forum ;) I start programming Arduino only few weeks ago. My problem is use the ServoDecode Library to grab 7 ch from a modifyed Graupner RX. The RX send the impulse train all toghether on one wire connected to digital pin of Arduino 2009. I add Servodecode library to my sketch and I have this errors compiling the library: (also with the example sketch)

o: In function __vector_13': C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build1989424199835515901.tmp/ServoDecode.cpp:45: multiple definition of__vector_13'

C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build1989424199835515901.tmp\ServoDecode\ServoDecode.cpp.o:D:\arduino-0018\arduino-0018\libraries\ServoDecode/ServoDecode.cpp:45: first defined here

o: In function __vector_10': C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build1989424199835515901.tmp/ServoDecode.cpp:52: multiple definition of__vector_10'

C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build1989424199835515901.tmp\ServoDecode\ServoDecode.cpp.o:D:\arduino-0018\arduino-0018\libraries\ServoDecode/ServoDecode.cpp:52: first defined here

o: In function __vector_13': C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build1989424199835515901.tmp/ServoDecode.cpp:45: multiple definition ofpulseEnd'

C:\DOCUME~1\ADMINI~1\IMPOST~1\Temp\build1989424199835515901.tmp\ServoDecode\ServoDecode.cpp.o:D:\arduino-0018\arduino-0018\libraries\

and many more.....

I'm running Arduino 018 with the library taken from the start of this thread.

Any help will be apreciated and sorry for my bad english ;)

@MatrixGTI

are you sure you tried the code and the example sketch exactly as posted at the start of this thread? they compile okay for me using 0018

@mem I copy/past the code in the first page, maybe happend something during copy. May I ask u the link of the library as file and not as code. just to be sure of the file structure.

Thanks

Flavio