Looking to control an ESC


#1

Hi,

I am attempting to control an ESC with XOD. However, I am unable to figure out how to.

Here is a sketch that does work for me. Is this something that could be made into a node?

Thank you,
Paul

#include <Servo.h>
Servo esc_signal;

void setup()
{
  esc_signal.attach(4);  //Specify here the pin number on which the signal pin of ESC is connected.
  esc_signal.write(30);   //ESC arm command. ESCs won't start unless input speed is less during initialization.
  delay(3000);            //ESC initialization delay.
}

void loop()
{
esc_signal.write(55);    //Vary this between 40-130 to change the speed of motor. Higher value, higher speed.
delay(15);
}

#2

Hi,this can serve you or give you a rough idea, since I do not have one to try.
The values 30 (in boot) and then the delay (3s) 55 in loop (15ms).
Value node Servo is 0-1, map from 0-180 to 0-1, you could omit it if you calculate the value. ESC.xodball (11.8 KB)
Maybe you can also omit the delay of 15ms, placing continuously in UPD of the servo node
ESC-2.xodball (5.0 KB)

ESC


#3

Thank you!

That’s more complex than I thought it would be. This programming method is so versatile, I’m sure I can take this and make it into something workable.

I’ll give it a try when I get home.


#4

That worked beautifully!

I modified it slightly to make it a node. I’m a new user, so I can’t upload a file. I’ll post the code instead from the Xodball file.

{
  "name": "",
  "patches": {
    "@/esc-servo": {
      "comments": {
        "BknbNXY6bkN": {
          "content": "value out 0-1",
          "id": "BknbNXY6bkN",
          "position": {
            "x": 33,
            "y": 203
          },
          "size": {
            "height": 51,
            "width": 68
          }
        },
        "H1-G47t6-J4": {
          "content": "-value boot 30\n-value loop 55",
          "id": "H1-G47t6-J4",
          "position": {
            "x": 373,
            "y": 101
          },
          "size": {
            "height": 51,
            "width": 136
          }
        },
        "HJ1GV7FpWJV": {
          "content": "value input between 0-180",
          "id": "HJ1GV7FpWJV",
          "position": {
            "x": 169,
            "y": 101
          },
          "size": {
            "height": 51,
            "width": 102
          }
        },
        "HyT-EmtaWJV": {
          "content": "delay 15",
          "id": "HyT-EmtaWJV",
          "position": {
            "x": 577,
            "y": 305
          },
          "size": {
            "height": 51,
            "width": 68
          }
        },
        "HyxMVQFTby4": {
          "content": "delay 3000",
          "id": "HyxMVQFTby4",
          "position": {
            "x": 611,
            "y": 203
          },
          "size": {
            "height": 51,
            "width": 68
          }
        },
        "S1R-VQK6Wk4": {
          "content": "port ESC",
          "id": "S1R-VQK6Wk4",
          "position": {
            "x": -1,
            "y": 305
          },
          "size": {
            "height": 51,
            "width": 34
          }
        }
      },
      "links": {
        "BJy-N7ta-1N": {
          "id": "BJy-N7ta-1N",
          "input": {
            "nodeId": "SJ_47tpbk4",
            "pinKey": "rkpbU0OrwyZ"
          },
          "output": {
            "nodeId": "r1zEXYp-kE",
            "pinKey": "B1x2RV3eZ"
          }
        },
        "Bk_Z4mYpb14": {
          "id": "Bk_Z4mYpb14",
          "input": {
            "nodeId": "B14VXtTbyN",
            "pinKey": "Skre8ROSv1-"
          },
          "output": {
            "nodeId": "Skgg47FaZ1E",
            "pinKey": "__out__"
          }
        },
        "HJfZV7taZy4": {
          "id": "HJfZV7taZy4",
          "input": {
            "nodeId": "BJ24XFabJV",
            "pinKey": "ByU7LRuSPkW"
          },
          "output": {
            "nodeId": "HJj4mY6-kV",
            "pinKey": "Bk4gU0drwJ-"
          }
        },
        "HksZV7FpWJN": {
          "id": "HksZV7FpWJN",
          "input": {
            "nodeId": "HkXe47KaW14",
            "pinKey": "__in__"
          },
          "output": {
            "nodeId": "SkXE7FT-1N",
            "pinKey": "BJgBlMF8xm"
          }
        },
        "Hkw-V7K6WJ4": {
          "id": "Hkw-V7K6WJ4",
          "input": {
            "nodeId": "BkbVXFTW14",
            "pinKey": "rygjH06LW"
          },
          "output": {
            "nodeId": "B1yxE7F6bJV",
            "pinKey": "__out__"
          }
        },
        "HyHbNmt6WJE": {
          "id": "HyHbNmt6WJE",
          "input": {
            "nodeId": "SkXE7FT-1N",
            "pinKey": "S1vGmu6Gb"
          },
          "output": {
            "nodeId": "ryaVQtT-JV",
            "pinKey": "__out__"
          }
        },
        "S1-bVmF6-yV": {
          "id": "S1-bVmF6-yV",
          "input": {
            "nodeId": "SJ_47tpbk4",
            "pinKey": "HJCWLAdSwyW"
          },
          "output": {
            "nodeId": "SJSNQtaZ1N",
            "pinKey": "B1x2RV3eZ"
          }
        },
        "S1LbNmYTZ1V": {
          "id": "S1LbNmYTZ1V",
          "input": {
            "nodeId": "BkbVXFTW14",
            "pinKey": "S10qrR6UZ"
          },
          "output": {
            "nodeId": "SkR4QKTbkE",
            "pinKey": "__out__"
          }
        },
        "S1VgNQtaWJ4": {
          "id": "S1VgNQtaWJ4",
          "input": {
            "nodeId": "BJ24XFabJV",
            "pinKey": "ryv7IRdSP1b"
          },
          "output": {
            "nodeId": "BkbVXFTW14",
            "pinKey": "rkWHDAW_f"
          }
        },
        "S1lW4XFpWy4": {
          "id": "S1lW4XFpWy4",
          "input": {
            "nodeId": "Hy94XKpbJN",
            "pinKey": "BJI7P8t9Z"
          },
          "output": {
            "nodeId": "HJj4mY6-kV",
            "pinKey": "Bk4gU0drwJ-"
          }
        },
        "SJqxVQYp-yE": {
          "id": "SJqxVQYp-yE",
          "input": {
            "nodeId": "SJ_47tpbk4",
            "pinKey": "BJlzICOSv1-"
          },
          "output": {
            "nodeId": "BkbVXFTW14",
            "pinKey": "S1yaHC6UW"
          }
        },
        "SkX-V7YabyN": {
          "id": "SkX-V7YabyN",
          "input": {
            "nodeId": "HJj4mY6-kV",
            "pinKey": "SkSuD6LMb"
          },
          "output": {
            "nodeId": "HkINmKpZk4",
            "pinKey": "ByHmL0uHPk-"
          }
        },
        "SyClNXYp-yE": {
          "id": "SyClNXYp-yE",
          "input": {
            "nodeId": "SkXE7FT-1N",
            "pinKey": "SkrgGYLxQ"
          },
          "output": {
            "nodeId": "BJ24XFabJV",
            "pinKey": "ByHmL0uHPk-"
          }
        },
        "SyOeV7K6bJV": {
          "id": "SyOeV7K6bJV",
          "input": {
            "nodeId": "SJ_47tpbk4",
            "pinKey": "rJbGU0_Hv1Z"
          },
          "output": {
            "nodeId": "ByPEmY6bkV",
            "pinKey": "B1x2RV3eZ"
          }
        },
        "SypeV7Fabk4": {
          "id": "SypeV7Fabk4",
          "input": {
            "nodeId": "SJ_47tpbk4",
            "pinKey": "ry1z8CuBDy-"
          },
          "output": {
            "nodeId": "BklV7F6-kE",
            "pinKey": "B1x2RV3eZ"
          }
        },
        "r1PxEXtpb1V": {
          "id": "r1PxEXtpb1V",
          "input": {
            "nodeId": "BkbVXFTW14",
            "pinKey": "rkmiHCaIZ"
          },
          "output": {
            "nodeId": "B14VXtTbyN",
            "pinKey": "HkU3vNoTW"
          }
        },
        "r1YxVQK6ZJN": {
          "id": "r1YxVQK6ZJN",
          "input": {
            "nodeId": "HkINmKpZk4",
            "pinKey": "ByU7LRuSPkW"
          },
          "output": {
            "nodeId": "Hy94XKpbJN",
            "pinKey": "HJhXDIY9-"
          }
        },
        "rJtZN7Kp-1N": {
          "id": "rJtZN7Kp-1N",
          "input": {
            "nodeId": "HJj4mY6-kV",
            "pinKey": "Skre8ROSv1-"
          },
          "output": {
            "nodeId": "HJWeVXKTb1N",
            "pinKey": "__out__"
          }
        },
        "rkhl47Y6-yE": {
          "id": "rkhl47Y6-yE",
          "input": {
            "nodeId": "B14VXtTbyN",
            "pinKey": "SkSuD6LMb"
          },
          "output": {
            "nodeId": "Hk4mFaWyN",
            "pinKey": "ryVmUAOrvkb"
          }
        },
        "rkrgVQFTbk4": {
          "id": "rkrgVQFTbk4",
          "input": {
            "nodeId": "SyY4QtpZkN",
            "pinKey": "ry3zLA_Bv1Z"
          },
          "output": {
            "nodeId": "B14VXtTbyN",
            "pinKey": "HkU3vNoTW"
          }
        },
        "ry5bNmK6WJN": {
          "id": "ry5bNmK6WJN",
          "input": {
            "nodeId": "BJMgVQtpZJE",
            "pinKey": "__in__"
          },
          "output": {
            "nodeId": "SkXE7FT-1N",
            "pinKey": "Hk-rxfFUxm"
          }
        },
        "ryEWEQKTbkE": {
          "id": "ryEWEQKTbkE",
          "input": {
            "nodeId": "BkbVXFTW14",
            "pinKey": "rJUjrCTUb"
          },
          "output": {
            "nodeId": "SyY4QtpZkN",
            "pinKey": "r1if8ROSDJ-"
          }
        },
        "ryIgNQt6ZyE": {
          "id": "ryIgNQt6ZyE",
          "input": {
            "nodeId": "SkXE7FT-1N",
            "pinKey": "r1sfQ_6fb"
          },
          "output": {
            "nodeId": "SJ_47tpbk4",
            "pinKey": "H12bIR_SPyZ"
          }
        },
        "rysl4mtaWkN": {
          "id": "rysl4mtaWkN",
          "input": {
            "nodeId": "HkINmKpZk4",
            "pinKey": "ryv7IRdSP1b"
          },
          "output": {
            "nodeId": "B14VXtTbyN",
            "pinKey": "Bk4gU0drwJ-"
          }
        }
      },
      "nodes": {
        "B14VXtTbyN": {
          "boundLiterals": {
            "SkSuD6LMb": "On Boot",
            "Skre8ROSv1-": "3"
          },
          "id": "B14VXtTbyN",
          "position": {
            "x": 509,
            "y": 203
          },
          "type": "xod/core/delay"
        },
        "B1yxE7F6bJV": {
          "description": "Vary this between 40-130 to change the speed of motor. Higher value, higher speed.",
          "id": "B1yxE7F6bJV",
          "label": "Motor Speed",
          "position": {
            "x": 339,
            "y": -1
          },
          "type": "xod/patch-nodes/input-number"
        },
        "BJ24XFabJV": {
          "id": "BJ24XFabJV",
          "position": {
            "x": 305,
            "y": 305
          },
          "type": "xod/core/any"
        },
        "BJMgVQtpZJE": {
          "id": "BJMgVQtpZJE",
          "label": "ESC Done",
          "position": {
            "x": 33,
            "y": 509
          },
          "type": "xod/patch-nodes/output-pulse"
        },
        "BkbVXFTW14": {
          "id": "BkbVXFTW14",
          "position": {
            "x": 271,
            "y": 203
          },
          "type": "xod/core/select"
        },
        "BklV7F6-kE": {
          "id": "BklV7F6-kE",
          "position": {
            "x": 101,
            "y": 101
          },
          "type": "xod/core/constant-number"
        },
        "ByPEmY6bkV": {
          "id": "ByPEmY6bkV",
          "position": {
            "x": 169,
            "y": 203
          },
          "type": "xod/core/constant-number"
        },
        "HJWeVXKTb1N": {
          "description": "Loop Delay. Standard set to 0.015.",
          "id": "HJWeVXKTb1N",
          "label": "Loop Delay",
          "position": {
            "x": 407,
            "y": 305
          },
          "type": "xod/patch-nodes/input-number"
        },
        "HJj4mY6-kV": {
          "boundLiterals": {
            "SkSuD6LMb": "On Boot",
            "Skre8ROSv1-": "0.015"
          },
          "id": "HJj4mY6-kV",
          "position": {
            "x": 407,
            "y": 407
          },
          "type": "xod/core/delay"
        },
        "Hk4mFaWyN": {
          "id": "Hk4mFaWyN",
          "position": {
            "x": 543,
            "y": 101
          },
          "type": "xod/core/boot"
        },
        "HkINmKpZk4": {
          "id": "HkINmKpZk4",
          "position": {
            "x": 475,
            "y": 305
          },
          "type": "xod/core/any"
        },
        "HkXe47KaW14": {
          "description": "ESC Error",
          "id": "HkXe47KaW14",
          "label": "ESC Err",
          "position": {
            "x": 67,
            "y": 509
          },
          "type": "xod/patch-nodes/output-pulse"
        },
        "Hy94XKpbJN": {
          "id": "Hy94XKpbJN",
          "position": {
            "x": 577,
            "y": 407
          },
          "type": "xod/core/defer"
        },
        "SJSNQtaZ1N": {
          "boundLiterals": {
            "B1x2RV3eZ": "180"
          },
          "id": "SJSNQtaZ1N",
          "position": {
            "x": 135,
            "y": 101
          },
          "type": "xod/core/constant-number"
        },
        "SJ_47tpbk4": {
          "boundLiterals": {
            "HJCWLAdSwyW": "180",
            "rkpbU0OrwyZ": "1"
          },
          "id": "SJ_47tpbk4",
          "position": {
            "x": 67,
            "y": 305
          },
          "type": "xod/math/map"
        },
        "SkR4QKTbkE": {
          "description": "//ESC arm command. ESCs won't start unless input speed is less during initialization.",
          "id": "SkR4QKTbkE",
          "label": "ESC Arm Command",
          "position": {
            "x": 271,
            "y": -1
          },
          "type": "xod/patch-nodes/input-number"
        },
        "SkXE7FT-1N": {
          "id": "SkXE7FT-1N",
          "position": {
            "x": 33,
            "y": 407
          },
          "type": "xod/common-hardware/servo"
        },
        "Skgg47FaZ1E": {
          "description": "ESC initialization delay.",
          "id": "Skgg47FaZ1E",
          "label": "ESC Delay",
          "position": {
            "x": 509,
            "y": -1
          },
          "type": "xod/patch-nodes/input-number"
        },
        "SyY4QtpZkN": {
          "id": "SyY4QtpZkN",
          "position": {
            "x": 441,
            "y": 203
          },
          "type": "xod/core/not"
        },
        "r1zEXYp-kE": {
          "boundLiterals": {
            "B1x2RV3eZ": "1"
          },
          "id": "r1zEXYp-kE",
          "position": {
            "x": 203,
            "y": 203
          },
          "type": "xod/core/constant-number"
        },
        "ryaVQtT-JV": {
          "description": "Specify here the pin number on which the signal pin of ESC is connected.",
          "id": "ryaVQtT-JV",
          "label": "Port",
          "position": {
            "x": 33,
            "y": 305
          },
          "type": "xod/patch-nodes/input-port"
        }
      },
      "path": "@/esc-servo"
    },
    "@/main": {
      "nodes": {
        "ryieF6-yE": {
          "boundLiterals": {
            "B1yxE7F6bJV": "55",
            "HJWeVXKTb1N": "0.015",
            "SkR4QKTbkE": "30",
            "Skgg47FaZ1E": "3",
            "ryaVQtT-JV": "D4"
          },
          "id": "ryieF6-yE",
          "position": {
            "x": 442,
            "y": 102
          },
          "type": "@/esc-servo"
        }
      },
      "path": "@/main"
    }
  }
}


#5

Great, this is simpler and more variable through a POT in A0, the first one is more detailed so you can understand it.


#6

@cesars @avaviel
Hi guys!
Here are nodes that I use for my hobby ESC devices. Maybe you will find it useful.

https://xod.io/libs/gabbapeople/esc/

And, here are the steps:

  1. Open the example-esc-calibrate patch from the lib. Set up an Analog ESC pin. Set CLB on boot. The led node is for built-in D13 onboard LED.
  2. Connect your ESC to the Arduino board.
  3. Power your Arduino board.
  4. Once the LED (D13) is HIGH/ON connect the power to your ESC, you have 5 sec to do so.
  5. Once the LED is LOW/OFF the calibration should be done. If you use simple hobby ESC, you will hear a music =).
  6. Now your ESC is calibrated between 1000us and 2000us.
  7. Use the esc node from the lib in your program to control the speed. Put the SPD values from 1000 to 2000.

That lib works fine for me =)


#7

Nice! I’ll give that a try!