Arduino obtains the PPM control signal from the model remote control receiver

Source: Internet
Author: User

Wireless remote control uses high-frequency radio waves to control the model. For example, the 6-channel 2.4 GHz Remote Control of wfly, a set of more than 200 pieces, with automatic frequency hopping anti-interference capability, theoretically, we can allow hundreds of people to remotely control their models at the same site without interfering with each other. In addition, the remote control distance is also quite advantageous. The power of the 2.4 GHz remote control system is only less than 100 MW, and its remote control distance can reach more than 1km.

Remote control transmitter and receiver principle

The pulse width of each channel is 0 ~ 2 ms, change range: 1 ~ Within 2 ms. The signal length of one ppm frame is 20 ms. Theoretically, there can be up to 10 channels, but the synchronous pulse also takes time. The model remote control can have up to 9 channels.

PPM format

Only connect Channel 3 (accelerator)

It is very easy for Arduino to measure the pulse width time. There is a dedicated library function pulsein (). The problem is that this library function uses the query method. The program remains stuck here during the measurement period, and the CPU usage is too low. Therefore, the following code is interrupted, which is highly efficient.
Code reference: http://arduino.cc/forum/index.php/topic,42286.0.html

Arduino source code:

// Read PPM Signals from 2 channels of an RC reciever // http://arduino.cc/forum/index.php/topic,42286.0.html // the receiver is connected to the Arduino Digital Port 2 and 3 respectively. // Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital Pin 3 ). // The Arduino mega has an additional four: Numbers 2 (PIN 21), 3 (pin 20), 4 (PIN 19), and 5 (pin 18 ). int ppm1 = 2; int ppm2 = 3; unsigned long rc1_pulsestartti Cks, rc2_pulsestartticks; volatile int rc1_val, rc2_val; void setup () {serial. begin (9600); // ppm inputs from RC receiver pinmode (ppm1, input); pinmode (ppm2, input); // level change triggers the interruption attachinterrupt (0, RC1, change); attachinterrupt (1, RC2, change);} void RC1 () {// did the pin change to high or low? If (digitalread (ppm1) = high) rc1_pulsestartticks = micros (); // store the current micros () value else rc1_val = micros ()-rc1_pulsestartticks;} void RC2 () {// did the pin change to high or low? If (digitalread (ppm2) = high) rc2_pulsestartticks = micros (); else rc2_val = micros ()-rc2_pulsestartticks;} void loop () {// print values serial. print ("Channel 1:"); serial. print (rc1_val); serial. print (""); serial. print ("Channel 2:"); serial. println (rc2_val );}

Each channel of the above Code occupies an interrupt port. However, generally, only the digital ports 2 and 3 of Arduino are interrupted. That is to say, only two channels can be connected. If you want to use more channels, you need to use mega, which has five external interrupt sources. In fact, there is also a simple way to use an interrupt to receive all channels. This is to bypass the decoding circuit of the receiver and use Arduino to directly decode the PPM signal. The trouble with this method is that you need to split the receiver and bring out the pre-decoding PPM signal.

Reference: http://diydrones.com/profiles/blogs/705844:BlogPost:38393
There are several ways to find the PPM signal interface after enabling the receiver:

1. Check the chip information. For example, if the Futaba receiver uses the bu4015bf shift register chip, solder The Pin 1 or 9 to a wire. 2. Use an oscilloscope 3. use Arduino to write the program for measuring the pulse width, and find it on the circuit board until some random number estimates appear.

Find and use the following code for decoding. This code segment uses the query method, which is less efficient. A more efficient way is to use two interruptions. One Interrupt detects the synchronization signal, and the other interrupt processes the PPM signal.

Arduino source code:

//http://diydrones.com/profiles/blogs/705844:BlogPost:38393#define channumber 4 //How many channels have your radio?int value[channumber]; void setup(){        Serial.begin(57600); //Serial Begin        pinMode(3, INPUT); //Pin 3 as input}void loop(){        while(pulseIn(3, LOW) < 5000){} //Wait for the beginning of the frame        for(int x=0; x<=channumber-1; x++)//Loop to store all the channel position        {                value[x]=pulseIn(3, LOW);        }        for(int x=0; x<=channumber-1; x++)//Loop to print and clear all the channel readings        {                Serial.print(value[x]); //Print the value                Serial.print(" ");                value[x]=0; //Clear the value afeter is printed        }        Serial.println(""); //Start a new line}

 

Arduino obtains the PPM control signal from the model remote control receiver

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.