0

I have a very simple sketch that's supposed to intercept the signal from an RC receiver and print the pulse duration from that channel.

Sketch

int PwmPin = 9;
unsigned long duration;

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

void loop() {
  duration = pulseIn(PwmPin, HIGH);
  Serial.println(duration);
}

Output

0
0
0
...

My setup is the normal one that would occur without an Arduino, and only the battery is connected through the ESC to provide power to the receiver. The Arduino is connected via USB because I'm just trying to read values.

wiring

I have been trying to plug between the receiver's data pin to the Arduino's PWM pin and read the pulses from the rudder channel. (I have previously tested the channel with a servo and know that it works correctly). However, no signal (0) is being printed to the serial monitor. I have difficulty understanding why.

I checked the documentation for pulseIn(), and it seems simple enough. I tested PWM pins D3, D5, D10... none of them works. I don't understand where the problem is at this point. Update: I am now connecting from the receiver's negative pin to one of the Arduino's GNDs.

This is a simplistic scenario, so I don't see what's going wrong (my programming experience is good, but my experience with Arduino is near nil).

The goal of this experiment is to program lights to change according to throttle input, and asymmetric thrust through two motors for a boat. I know that pulseIn isn't the best function to use, but for the moment I just want to do some quick development before getting into the weeds.

Update: I am attempting to follow this video, except that connecting the Arduino to the receiver didn't work, possibly because the ESC's BEC sends some sort of power signal that arms the receiver. (The receiver's LEDs usually make a visual signal, but they just turn on without a signal when connected through the Arduino).

According to the manual on page 6 and page 8, "receivers have an operational voltage range of 3.5 to 9 volts", with an ideal voltage being above 4.8V (because servos tend to brownout sooner). This should fall within Arduino range at 5V.

9
  • 2
    First: Never show code and serial output as an image. Copy and paste them as text into the question and format them as code. Second: You really need to connect the ground between Arduino and receiver. That is not optional. Are you sure, that there really is a signal on the receivers pin?
    – chrisl
    May 9, 2020 at 21:42
  • 3
    No ground connection?! majenko.co.uk/blog/importance-sharing-grounds
    – Majenko
    May 9, 2020 at 21:43
  • 1
    Everything needs a common ground in order to work. You need a common point to reference voltages to.
    – Delta_G
    May 10, 2020 at 2:41
  • 1
    You can't measure a voltage with only one connection. You have to connect the grounds.
    – Delta_G
    May 10, 2020 at 3:48
  • 1
    BTW, there is no such thing as a "PWM Input Pin" - PWM is output only. You are just using the generic GPIO functionality of the pins, and as such you can use any pin.
    – Majenko
    May 10, 2020 at 9:31

1 Answer 1

1

What misled me is the pin numbers. I was referencing this diagram:

NANO pinout

I thought that all the pins were numbered sequentially, so that pinMode(9, ...) would set D6 (09 in the diagram). However, this sets D9. Connecting to the correct pin works fine.

2
  • If you're still doing this without a ground connection then it may only appear to be working fine for now. IT may simply stop working at any time it sees fit based on that voltage reference.
    – Delta_G
    May 10, 2020 at 14:30
  • I read the article Majenko commented previously and understand that. IDK whether working on my unplugged laptop proves the concept. Since there are only two grounds, I'm already running out. I am running the receiver and an ESC from the Arduino, but still need to add another ESC, plus LEDs... @Delta_G May 10, 2020 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.