• entries
50
92
• views
66639

1527 views

As I'm learning more and more about electronics, I have more advanced ideas in my head. Currently my goal is to create a POV display, using motors, servos and shift registers ( which are new stuff I learned about ). However, that's not what I worked on today.

The friend that lent me his Arduino kit is putting together a quadcopter, and he wants it to be Arduino-controlled. He has a FlySky FS-TH9X transmitter that he wants to control the 'copter, and paired FS-R8B receiver that will be used to provide Arduino with information necessary for controlling the flying contraption.

I asked if I can be of any use to him, and he said that indeed I could - I got the job of putting the FlySky controllers to work.

I had absolutely no idea what it's all about, so he gave me a crash course: there are 8 interesting pins on the receiver that I need to connect as arduino inputs, and that the signal is most likely PPM or Pulse Position Modulation, so I should google something about that. The website I found shown that it's a timing based system, where frequency of HIGH signals is used to indicate the value that's transmitted. I asked my friends how to use oscilloscope, because I have never used it before, and I have learned that it's a bit different system. It was PWM or Pulse Width Modulation, not PPM. Instead of frequency of HIGH spikes, HIGH signal lasts for certain time in a loop, and length of that signal can be converted to value. Oscilloscope measurements displayed values of ~1ms for minimum length signal, ~2ms for maximum length signal, and the loop period of 20ms on current controller settings. I only needed to count that and convert to something that could be more intuitive ( I chose a -127 to 127 range, so that it would fit into a signed char ).

I connected all the pins to the inputs 13 to 6, because why not ( naah, just pulling your leg, since I'm communicating through serial with computer, and pins 0 and 1 are used for that communication, I decided to start from other side of board.

With a help of another friend, I quickly put together a code for parsing the pulses into values:

const int minVal = 1000;const int maxVal = 2000;char values[8] = {};unsigned long currentState[8] = {};unsigned long currentStartCycle[8] = {};int ch1 = 13;int ch2 = 12;int ch3 = 11;int ch4 = 10;int ch5 = 9;int ch6 = 8;int ch7 = 7;int ch8 = 6;int startCycle = 0;int currentCycle = 0;void setup() { pinMode(ch1, INPUT); pinMode(ch2, INPUT); pinMode(ch3, INPUT); pinMode(ch4, INPUT); pinMode(ch5, INPUT); pinMode(ch6, INPUT); pinMode(ch7, INPUT); pinMode(ch8, INPUT); Serial.begin(9600); startCycle = millis(); currentCycle = startCycle; for ( int i = 0; i < 8; i++) { values = 0; currentState = 0; currentStartCycle = 0; }}void loop(){ int currentMicros = micros(); for ( int i = 0; i < 8; i++) { // trololo if ( digitalRead(13 - i) == HIGH && currentState == 0 ) { currentState = 1; currentStartCycle = currentMicros; } // very trololo :> else if ( digitalRead(13 - i) == LOW && currentState == 1) { values = map ( currentMicros - currentStartCycle, minVal, maxVal, -127, 127); currentState = 0; } } currentCycle = millis(); if ( currentCycle < startCycle ) { startCycle = currentCycle ; } if ( currentCycle > startCycle + 1000 ) { startCycle = currentCycle; for ( int i = 0; i < 8; i++) { Serial.print("| Ch"); Serial.print(i + 1, DEC ); Serial.print(": "); Serial.print(values, DEC); } Serial.println(""); } }

And it works! I managed to learn how to do remote control . Now, my DeathBots that will help me take over the world are another step closer.

Oh yeah, and here's how my desk looked like ( yeah, just showing off ;) )

Till next time!

There are no comments to display.

## Create an account

Register a new account