Arduino – RX PWM [R/C Receiver channel pulse output wire]

OK, it’s easy to control a servo using servo.h library to write an angle to a servo connected to one of the arduino inputs 2-13. But how can we read the signal coming of the third wire coming out of a receiver channel? Let’s find out, starting with this ‘RC Hobby Controllers and Arduino’ tutorial from Nick Poole & the good folks at SparkFun.

The tutorial wires up three channels from an RX which gets power from the 5v of a (non DUE) arduino. We need to modify things for just one channel and for external power (a 6v 3xAA NiMh battery pack from a glider). First we need to make up a servo lead that provides the pulse and our common earth. Then (the hardest part for me) we have to pick an input of the Arduino DUE. A quick look at the specs suggests any of the 53 DIGITAL inputs would do. Because some of them (1-21) have special labels like PWM, Communication TX, RX, I picked 30 which does not.

Setup:

Radio controlled computa!

  • RX signal (orange) to Pin30 set for pinMode(30, INPUT)
  • Common earth (brown) to GND next to pin 53

Code: MikeRX01.ino

Modifying Nick Pool’s code was easy. Just delete the lines for unused channels 2 & 3 & change pin to 30.

The key lines are:

  • pinMode(30, INPUT); // Set our input pins as such
  • ch1 = pulseIn(30, HIGH, 25000); // Read the pulse width
  • Serial.println(ch1);  // Display read values on serial monitor

What happened was the values changed as follows:

  • 0 everything off
  • 1583 power up TX & RX
  • 2013 pull full up on my TX Elevator (T3 Stick)
  • 1146 push full down

Cool eh?

p.s.

  • PWM: Pins 2 to 13
    Provide 8-bit PWM output with the analogWrite() function. the resolution of the PWM can be changed with theanalogWriteResolution() function.
  • FrSKY TFR6 Bind: power on TX, Hold ‘F/S’ button on RX while power up.
  • Values: 1583 CH1 neutral, 0 servomon, 2013 full UP +100 servomon, 1146 full DOWN -100 servomon
  • Change to CH2: Values: 1578 CH2 neutral, 0 servomon, 2015 full RIGHT +100 servomon, 1142 full LEFT -100 servomon

Creative Commons License

Fang – Mike Seyfang

TriBeardLesBones

Advertisements

About mseyfang

Interruptus Digitalis
This entry was posted in Hobbies, MyModelPlanes, phd and tagged , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s