Go Down

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

Heyarnold

Hi mem!  Thanks for such a quick response ( and the libraries!).  

I didn't think analogWrite function would work at all with both libraries going.  
I will try it out on pins 5 and 6 this weekend and report my results back to you.

loris

Hi,

I tried to use your librairies (ServoTimer2 and ServoDecode) and I have a problem. My transmitter is a Graupner MX 16s.

I used your sample sketch and this is the result :

Code: [Select]
The decoder is in Failsafe
Cx0= 9628  Cx1= 1500  Cx2= 1500  Cx3= 1491  Cx4= 1500  Cx5= 1490  Cx6= 1517  Cx7= 1881  Cx8= 1087  
Ch1= 1877  Ch2= 1488  Ch3= 1491  Ch4= 1488  Ch5= 1489  Ch6= 1512  Ch7= 1880  Ch8= 1088  
Ch1= 1878  Ch2= 1488  Ch3= 1492  Ch4= 1487  Ch5= 1490  Ch6= 1517  Ch7= 1880  Ch8= 1087  
Ch1= 1878  Ch2= 1488  Ch3= 1490  Ch4= 1489  Ch5= 1488  Ch6= 1517  Ch7= 1880  Ch8= 1088  
Ch1= 1877  Ch2= 1488  Ch3= 1490  Ch4= 1488  Ch5= 1489  Ch6= 1517  Ch7= 1500  Ch8= 1500  
The decoder is in Failsafe
Cx0= 9628  Cx1= 1500  Cx2= 1488  Cx3= 1490  Cx4= 1489  Cx5= 1490  Cx6= 1518  Cx7= 1880  Cx8= 1088  
Ch1= 1878  Ch2= 1487  Ch3= 1491  Ch4= 1489  Ch5= 1490  Ch6= 1511  Ch7= 1880  Ch8= 1088  
Ch1= 1877  Ch2= 1488  Ch3= 1491  Ch4= 1488  Ch5= 1490  Ch6= 1517  Ch7= 1881  Ch8= 1088  
Ch1= 1878  Ch2= 1487  Ch3= 1490  Ch4= 1488  Ch5= 1490  Ch6= 1518  Ch7= 1880  Ch8= 1087  
The decoder is in Failsafe
Cx0= 9628  Cx1= 1500  Cx2= 1500  Cx3= 1485  Cx4= 1500  Cx5= 1500  Cx6= 1500  Cx7= 1880  Cx8= 1089  
Ch1= 1873  Ch2= 1488  Ch3= 1491  Ch4= 1488  Ch5= 1490  Ch6= 1517  Ch7= 1880  Ch8= 1089  
Ch1= 1878  Ch2= 1488  Ch3= 1490  Ch4= 1488  Ch5= 1490  Ch6= 1517  Ch7= 1880  Ch8= 1088  
Ch1= 1878  Ch2= 1488  Ch3= 1491  Ch4= 1487  Ch5= 1490  Ch6= 1514  Ch7= 1880  Ch8= 1088  


The decoder is always going on failsafe and even with ServoDecode.setFailsafe() the output servos is moving. I tried to put a servos on the output of the receiver and this servos had also noise when the receiver is connected to the Arduino).

I tried with digitalWrite(8, HIGH); and the servo connected to the receiver didn't have noise any more but I have the same problem of failsafe.

Do you have an idea of the problem? and why even with ServoDecode.setFailsafe() the servo had noise ?


Thanks.

mem

are you sure you have all the grounds connected together?

Can you post a link to a picture that shows your wiring?

loris

Yes I'am sure that the ground is connected. I plug the ground and the 5V to the arduino board.

I used this receiver with paparazzi before so it should work. Maybe the signal is not high enough, I will try the get a scope to check.

loris

I managed to make it works!! The problem was that the board (+receiver + 2 servos) was powered by the usb and it was not power enough!

mem


loris

In fact my problem is not solved. When I only try do decode the PPM signal with your lib it works fine but when I want to control servos with your ServoTimer2 lib I have the same problem. Sometimes I lost the PPM signal.

I have a main loop at 50Hz where I read the channel pulses and then write commands to servos (2 servos and 4 ESCs) and if the decoder state is not ready I light on a LED. This LED is very often on and there is some noise on the servos.

mem

It sounds like the problem is on the servo side, why not try and isolote the problem, perhaps try a test sketch using serial commands to control the servos.

loris

#113
Mar 24, 2010, 08:57 pm Last Edit: Mar 24, 2010, 09:08 pm by loris Reason: 1
The servos control works fine. I manage to control the servo with serial commands.

I though the problem came from interrupts. I also use ADC interrupt in my software buy I tried without and I have the same problem.

I tried with your test sketch for ServoDecoder and ServoTimer2 and this is the problem:

Code: [Select]
The decoder is in Failsafe
Cx0= 10819  Cx1= 1099  Cx2= 1497  Cx3= 1482  Cx4= 1497  Cx5= 1482  Cx6= 1489  Cx7= 1493  Cx8= 1087  
The decoder is in Failsafe
Cx0= 10824  Cx1= 1099  Cx2= 1497  Cx3= 1482  Cx4= 1497  Cx5= 1482  Cx6= 1489  Cx7= 1493  Cx8= 1086  
The decoder is in Failsafe
Cx0= 10822  Cx1= 1099  Cx2= 1497  Cx3= 1482  Cx4= 1497  Cx5= 1482  Cx6= 1497  Cx7= 1491  Cx8= 1081  
Ch1= 1100  Ch2= 1489  Ch3= 1493  Ch4= 1484  Ch5= 1487  Ch6= 1493  Ch7= 1489  Ch8= 1094  
The decoder is in Failsafe
Cx0= 10820  Cx1= 1099  Cx2= 1497  Cx3= 1482  Cx4= 1496  Cx5= 1488  Cx6= 1490  Cx7= 1491  Cx8= 1084  
The decoder is in Failsafe


Without attaching a servo it works fine.

I used the Ardu IMU 2+ board.

Edit : I tried with this sketch

Code: [Select]
// ServoDecodeTest
#include <ServoTimer2.h>
#include <ServoDecode.h>

// define the servo pins
#define servoApin  9   // the pin the servo is attached to/
ServoTimer2 servoA;    // declare variables for the servos

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

int count;
void setup()                    // run once, when the sketch starts
{
 Serial.begin(38400);
 count=0;
 
//  digitalWrite(8, HIGH);       // turn on pullup resistor on pin 8
servoA.attach(servoApin);
 pinMode(5,OUTPUT);   // Red
 ServoDecode.begin();
 delay(1000);
 ServoDecode.setFailsafe();
}


void loop()                     // run over and over again
{
 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("  ");
   digitalWrite(5,HIGH); // Light on Red led
   }
   Serial.println("");
 }
 else {
   if( count % 20 == 0){   // decoder is ready, print the channel pulse widths every second
     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("  ");

     digitalWrite(5,LOW); // Light off Red led
     }
     Serial.println("");
   }
   count++;
 }
 servoA.write(ServoDecode.GetChannelPulseWidth(3));
 delay(20); // update 50 times a second

}


And the LDE is always blinking. (I cannot have the telemetry because I powered the board with the ESC)

mem

Try simplifying things to try and isolate the problem . Try it with just one servo wired up.  Does that work ok? If it does, experiment with various combinations of components to see if you can find out what triggers the problem.

Can  you post a link to a clear picture showing how the setup that has the problem is wired.

loris

It is very very strange. I tried with only 1 servos + 1 receiver + power supply from an ESC and I have the same problem.

Then I tried with an other brand of servo and it works ...

Do you think digital servos can create problems?

mem

It sounds like the problem is related to power or wiring issues.

loris

Everything is powered by one ESC (5V 2A). I tried to wire only the ESCs and it worked but when I plugged one servo the problem occured.

I checked the connections and all grounds and all 5V are connected. The signal are connected to pin 9, 10 (servos) and 11, 12 (ESC).

Maybe servos have a problem but it is strange it interferes with the PPM decoder.

mem

digital servos do draw more current than standard servos which is why I think there may be a power or wiring problem. you could try testing using another 5v power supply instead of  the ESC as the power source. Also have you tried adding decoupling capacitors to the power leads?

loris

I tried with an external power supply and there is the same problem.

The power consumption is very low (60mA) and servos small (5g) so I think an ESC has enough power to drive it. I don't see any wiring problem.

It is very strange that servos disturb the PPM decoder.

Go Up