Go Down

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

mem

zitron, thanks for that tip.
BTW, you don't need to modify the library, you can put that code to enable the internal pull up in setup.

dakkar

I have a 3ch Hitec Aggressor.  The first 2 channels control servos.  I want the 3rd channel to be read by my Arduino Duemilanove.  When I press the 3rd channel button, I want the Arduino to sense the change and send one of my digital pins to HIGH.  

I have tried using ServoDecode and I do not see a change when the 3rd channel button is activated.  Any help?

CrashingDutchman

Please try this: if you have a receiver with an inverted output, in ServorDecode.cpp change:
volatile byte pulseEnd = PULSE_START_ON_RISING_EDGE ; // default value
to
volatile byte pulseEnd = PULSE_START_ON_FALLING_EDGE; // inverted pulses

please confirm if this helps

dakkar

just tried that and I get

"The decoder is NOT_SYNCHED
Cx0= 0  Cx1= 0  Cx2= 0  Cx3= 0  Cx4= 0  Cx5= 0  Cx6= 0  Cx7= 0  Cx8= 0  
"

In the original state, all of the values seem to be independent of input from the transmitter anyway.  I have a feeling I am completely off the mark.  I am new to this stuff so any help is greatly appreciated!

mem

The ServoDecode library is designed to decode a composite pulse stream containing all the transmitted servo signals. If you want to decode a single servo channel, It may be easier to use pulseIn to read the pulse width.  See the Arduino reference for more on pulseIn

dakkar

I have tried that as well and it gives me values seemingly independent of transmitter input.  I'm thinking I may have to cheat and read the values used to drive the servo motor.

mem

Quote
I'm thinking I may have to cheat and read the values used to drive the servo motor.


not sure what you me an, the servo motor is driven by the pulse you are trying to measure.

Did you try the tip mentioned earlier in this thread of turning pull-ups on to increase the voltage on the arduino pin used to sense the pulse?

dakkar

Quote
not sure what you me an, the servo motor is driven by the pulse you are trying to measure.


By that I mean the small electric motor inside the servo.  When an input from the the 3rd channel is received, +5v is applied to the motor making it operate.  I would use the circuitry inside the servo as the decoder. Instead of applying +5v to a motor when it receives a signal, it would apply it to the Arduino which would then run a certain piece of code.  

I was just trying to get away without having to break into a servo, although I have a few cheap ones lying around.  

I did try to use a pull-up but it sent everything to +5v no matter what.  I think I may have been using pulseIn() incorrectly though.  I still have a lot to learn... 

mem

#98
Nov 28, 2009, 04:23 pm Last Edit: Nov 28, 2009, 04:23 pm by mem Reason: 1
Try something like this test to see if you are able to read the pulses from the receiver. Don't have the servo connected when you run the test

Code: [Select]

int pin = 7;  // set this to the pin connected to your receiver
unsigned long duration;

void setup()
{
 Serial.begin(9600);
 pinMode(pin, INPUT);
}

void loop()
{
 duration = pulseIn(pin, HIGH);
 Serial.println(duration);
 delay(1000);
}



dakkar

Thanks.  I've written that sketch a billion times thinking I was messing something up.

As a matter of fact I've figured out my problem.  The power supply to the receiver is +6v.  I was using that to power the receiver while attempting to read the control signal with the Arduino.  In an act of desperation, I decided to use the +5v on the Arduino to power the receiver and it magically started to work.  I really didnt think that a 1 volt power differential would make a difference, clearly I was wrong.  

In my research I noticed people putting a 220ohm resistor in line with the pulse being read by the Arduino.  Is that necessary?

I am also using a 10k pull-up per the suggestion and in both cases (using the 220 on the pulse and 10K as a pull up) there seems to be no difference with or without them.  Any thoughts on that?

ardudillo

Very nice tool thanks a lot. One quick question, in the first post you 're talking about "an RC receiver that provides access to the pulse stream". What manner of beast is this? I 've played a bit with RC at various stages and I don't think I 'ever seen a receiver that offered anything except a normal servo plug for each channel. Is it a feature that I perhaps have missed? Do most manufacturers make them? How do I go about getting one? What do I ask for?

mem

dakkar, sorry I missed your post, I hope my reply is not too late.

> I really didnt think that a 1 volt power differential would make a difference, clearly I was wrong.  
Did you have the receiver ground connected to Arduino ground?
Powering the receiver from the Arduino volt supply is best because this ensures that the voltage on the Arduino pins is not too high.

>In my research I noticed people putting a 220ohm resistor in (the input), Is that necessary?
No but its no bad thing. Although all the receivers I have looked at drive the servo outputs at a logic level suitable for direct connect to arduino, using a resistor provides an additional degree of protection.

>I am also using a 10k pull-up per the suggestion and in both cases  
A pull-up should not be required in this application but the Arduino internal pull-up value is high enough that it should not be a problem if you have this enabled.

mem

#102
Dec 31, 2009, 04:36 am Last Edit: Dec 31, 2009, 04:39 am by mem Reason: 1
ardudillo, I have never seen a receiver that provided this signal out of the box. The thread  suggests a number that can be modified by soldering a wire onto the receiver circuit board.

This post mentions one that is cheap and easy to modify: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1248474405/13#13

Here is another receiver that has been discussed in earlier posts : http://www3.towerhobbies.com/cgi-bin/WTI0001P?I=LXGZT0&P=8

Heyarnold

I have this library working with my VEX controller now and was hoping to use it to contol motors with an H-Bridge.  

How would I create a PWM singnal for the H-Bridge?  

I tried using the ServoTimer2 library (it works very well too!) but it isn't suitable PWM for an H-bridge.   Any way to modifiy the ServoTimer2 library to do what I want?    Ideally, I would like to contol both servo motors and H-bridge together. :)

mem

Heyarnold, you control PWM for things like an H-Bridge using the standard arduino analogWrite function. Bear in mind that the decode library uses timer1 and  servoTimer2 uses timer2 so you only have pins 5 & 6 available for analogWrite on a standard Arduino board.

Go Up