Go Down

Topic: Decoding Radio Control signal pulses (Read 73951 times) previous topic - next topic

mem

No software is flawless and its fair to say that the Arduino platform is not intended for mission critical applications. That said, I have not seen any problems that would rule out the Arduino for your application.

My advice is to use the failsafe to keep the engines running if there is a problem with the signal and do a lot of testing prior to your maiden flight.

Have fun!

AlexanderB

I'm so happy! After finally managing to connect the GND wire (how emparassing!) It works like a charme! This is the first and important step!

Cheers Alexander

mrmeval

http://autopilot.sourceforge.net/pcm.html

PCM is really complex. The link has limited information but allows comparison of them visually with two oscilloscope screen captures.

The DIY UAV looks interesting
http://autopilot.sourceforge.net/

AlexanderB

#138
Jul 08, 2010, 07:51 pm Last Edit: Jul 08, 2010, 07:52 pm by AlexanderB Reason: 1
Mem,

I'm stuck. I got your example running and the Servo example sweep does work as well.

I tried to let one servo follow CH 1. It does not work at all. I stripped as much as possible to prevent any side effects. Still nothing.

I also tried different pins. Nothing.

Code: [Select]

// ServoDecodeTest

#include <ServoDecode.h>
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
               // a maximum of eight servo objects can be created

char * stateStrings[] = {
 "NOT_SYNCHED", "ACQUIRING", "READY", "in Failsafe"};

void setup()                    // run once, when the sketch starts
{
 myservo.attach(2);  // attaches the servo on pin X to the servo object
 ServoDecode.begin();
 ServoDecode.setFailsafe(3,1234); // set channel 3 failsafe pulse  width
}

void loop()                     // run over and over again
{
 int pulsewidth;
 if( ServoDecode.getState()== READY_state) {
         pulsewidth = ServoDecode.GetChannelPulseWidth(1);
         myservo.writeMicroseconds(pulsewidth);
 } else {
         pulsewidth = 1500;
         myservo.writeMicroseconds(pulsewidth);

 }  
}


Any ideas? BTW I use ARDUINO 0018

Cheers Alexander

AlexanderB

Another try:

Code: [Select]

// ServoDecodeTest
#include <ServoDecode.h>
#include <ServoTimer2.h>  // 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  :)

mem

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

AlexanderB

No, does not help. Still fluttering.

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

Cheers
Alexander

AlexanderB

#142
Jul 08, 2010, 09:14 pm Last Edit: Jul 08, 2010, 09:29 pm by AlexanderB Reason: 1
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

mem

#143
Jul 08, 2010, 09:34 pm Last Edit: Jul 08, 2010, 09:35 pm by mem Reason: 1
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.

AlexanderB

Thank you.

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

Cheers
Alexander

mem

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.

AlexanderB

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

vinceherman

#147
Jul 09, 2010, 10:31 pm Last Edit: Jul 09, 2010, 10:32 pm by vinceherman Reason: 1
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?

mem

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

vinceherman

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?

Go Up