3
\$\begingroup\$

I have a Electronic Speed Controller (ESC) being controlled with Pulse Width Modulation (PWM) from an Arduino.

When I put my hand close to the cables the signal goes screwy until I move my hands away. I checked for shorts but didn't find any. I don't have an oscilloscope or that would give me my answer.

What's happening here?

I also made this video to help explain the situation.

Rough Schematic

schematic

EDIT

Adding working Arduino code for future visitors

#include <SoftwareServo.h> // Download from http://playground.arduino.cc/ComponentLib/Servo

SoftwareServo myservo;  // create servo object to control a servo

//int potpin = 0;  // analog pin used to connect the potentiometer
int PIN = 2;
int val;    // variable to read the value from the analog pin

void setup()
{
  Serial.begin(115200);
  myservo.attach(PIN);  // attaches the servo on pin 2 to the servo object
}

void loop()
{
  char r = Serial.read();
  String inStr = String(r);
  if(r > -1) {
    Serial.print("serial in: ");
    Serial.println(inStr);
  }

  if(r <= -1) {
    // void
  } else if(inStr == "h") { // high
    Serial.println("HIGH");
    digitalWrite(PIN, HIGH);
  } else if(inStr == "m") { // medium
    Serial.println("medium");
    myservo.write(90);
  } else if (inStr == "l") { // low
    Serial.println("LOW");
    digitalWrite(PIN, LOW);
  } else if (inStr.toInt() >= 0 && inStr.toInt() <= 9) {
    int val = inStr.toInt() * 20;
    Serial.println(val);
    myservo.write(val);
  }
  
//  float t = millis() / 100;
//  val = sin(t / 10) * 1000;//analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
//  //  if(val < 0) val *= -1;
//  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
//  val = millis() / 100;
//  myservo.write(val);                  // sets the servo position according to the scaled value
//  Serial.println(val);
//  delay(15);                           // waits for the servo to get there

  SoftwareServo::refresh();
}
\$\endgroup\$
17
  • 2
    \$\begingroup\$ Do you have schematics? \$\endgroup\$
    – Mark
    Jul 27, 2016 at 22:16
  • 2
    \$\begingroup\$ You should add your schematics. It sounds like a capacitive node which you are coupling to. For example the gate of an undriven mosfet. \$\endgroup\$
    – jbord39
    Jul 27, 2016 at 22:18
  • 3
    \$\begingroup\$ There's a schematic button on the editor toolbar. Show where the battery GND is connected to the Arduino GND and whether the Mac is on mains or not. (That may give a mains ground through the USB cable.) \$\endgroup\$
    – Transistor
    Jul 27, 2016 at 22:26
  • 1
    \$\begingroup\$ But is there a ground connection between the Arduino and the ESC? \$\endgroup\$
    – Mark
    Jul 28, 2016 at 1:26
  • 1
    \$\begingroup\$ You are also sending it a lot of noise if you don't connect a wire between the ground of the Arduino and the ground of the ESC. Your finger is simply amplifying the noise. \$\endgroup\$
    – Mark
    Jul 28, 2016 at 3:47

1 Answer 1

2
\$\begingroup\$

This answer originated from a comment by @Mark

This is a ground issue.

Even though the ESC will work without a ground from the Arduino, to make the signal stable I needed to accompany the signal wire from the Arduino with a ground wire from the Arduino.

Per my example I took the disconnected ground from the ESC and connected it to the GND from the Arduino.

\$\endgroup\$

Your Answer

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

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