I am working on a quadcopter project for school and have run into an issue that seems to be a problem with the Arduino DUE and/or IDE because the code runs fine on an Arduino Uno and an Arduino Mega. I switched from these baords the the DUE so I can improve performance, taking advantage of the 32-bit processor and faster clock speed.
For my design, I am using the Flysky FS-T6 controller, which uses radio frequency to transmit a microsecond pulse between 1000 and 2000 to the receiver module which the Arduino board uses the pulseIn() function to read. I am powering the radio receiver using the boards 5v pin. Previously, I was using A0-A5 to connect to the 6 channel pins on the receiver, but I have also tried using pins 16-21 and have found the same results.
I have troubleshot the problem to the furthest of my abilities making sure the wiring is correct and that everything is functioning correctly and even had a second pair of eyes check my work. Using a multi-meter, I can confirm that the receiver is receiving 5v.
When I try to run my program, the serial monitor shows that the code is getting hung up whenever it tries to execute the pulseIn() function meaning the pulseIn() function is timing out like there is not a signal. I am providing just an example of code to show what the program is doing below. What this does is just stream a constant flow of zeros to the serial monitor, but still gets hung up every cycle during the timeout whereas if the program wasn't timing out, the serial monitor would be printing zeros much faster. The code belows shows A0 as thats the pin I have been using on all three boards, but I have tried other pins on the Arduino DUE as well.
int CH1;
void setup() {
// put your setup code here, to run once:
Serial.begin(250000);
}
void loop() {
// put your main code here, to run repeatedly:
CH1 = pulseIn(A0,HIGH);
Serial.println(CH1);
}
I don't have access to an oscilloscope so I decided to be intuitive and found that by maxing the serial monitor baud rate, and connecting the channel pins on the receiver to A0-A5, I was able to simulate a oscilloscope using the analogRead() function and returning the value straight to the serial monitor using the code shown below.
int CH1;
void setup() {
// put your setup code here, to run once:
Serial.begin(250000);
}
void loop() {
// put your main code here, to run repeatedly:
CH1 = AnalogRead(A0);
Serial.println(CH1);
}
What this did is return multiple instances of zero and then periodic bursts of six or seven instances of 1023 meaning the signal is at zero, then spikes to 3.3v, then returns to zero, cycling continuously. This response confirms that both the Arduino pins and the receiver modules are working correctly. The only thing I can think of is that there is some sort of problem with the Arduino DUE and the pulseIn() function.
I am continuing to research the issue, but I wanted to see if the community had any other ideas as to what is happening.