Among many VESC users, some are passionate about programming and prefer controlling their VESC with Arduino. In this blog, we’ll step by step introduce three ports controlling by using Arduino: PPM, UART, ADC.

Preparations

PPM port Control

UART port control

ADC port control

Preparations:

Make sure the software compilation tool (arduino) has been installed and an arduino board is prepared; make sure you have skills of flashing program, adding a zip file, etc. get an arduino software download: https://www.arduino.cc/en/Main/Software Make sure you have skills of soldering or wiring and are able to wire according to the wiring diagram I drew. Got basic knowledge of C language.

PPM Control:

General introduction of PPM signal

Wiring diagram

Code to achieve PPM control

VESC tool operation reminds

First ,we need to know, what is the PPM signal?

I would like to briefly describe it here: a signal with pulse width of 1ms to 2ms in a cycle of 20ms, the standard level of it is 5V.

20ms(50Hz)One Cycle Signal

PPM Signal with Pulse Width of 2.0ms

PPM Signal with Pulse Width of 2.0ms

Want to know more detail information about PPM, here it is by someone else: Https://oscarliang.com/pwm-ppm-difference-conversion/

Reminds: Controlling VESC with PPM signals is the most popular and most conventional one. It’s actually not necessary to completely follow the PPM signal format since the VESC's throttle signal is adjustable. But , the VESC tool PPM mapping default set is standard PPM signal format.

Secondly , make correct wiring:

Wiring diagram is as follows:

UNO VESC 5V 5V (red wire) GND GND (black wire) D5 Signal wire (white wire)



Following picture is an arduino board with wiring instruction:

The potentiometer indicated in this blog can also be a joystick.

Next Step:

Set the value of the PPM output by the digital port 5 according to the detected change of the potentiometer

Here’s setting value code:

#include <Servo.h>

const uint8_t VescOutputPin = 5;

const uint8_t PotentiometerPin = A0;

Servo esc;

void setup() {

esc.attach(VescOutputPin);

esc.writeMicroseconds(1500);

}

void loop() {

esc.writeMicroseconds(map(analogRead(PotentiometerPin), 0 , 1023, 1000, 2000));

}

Lastly, you need to finish parameter setting in VESC tool, the operation is similar like with a remote control. Refer to our tutorial: https://goo.gl/UMtZnS

UART Control:

General introduction of UART control mode

Install a library to arduino

Wiring diagram

Input code to achieve UART control mode

VESC tool operation for UART mode

Controlling VESC with UART is also a common way: writing data to VESC through UART so that the VESC can make corresponding actions according to the given instructions.

So UART-VESC communication can not only control the throttle, but also make reverse , cruise and other functions possible. Some parameters from the VESC can also be read, such as battery voltage, eprm value, motor temperature and so on. For details, please refer to the UART description written by Benjamin: http://vedder.se/2015/10/communicating-with-the-vesc-using-UART/

Fist step: Install a library to arduino.

The library I used in this blog was written by RollingGecko and modified and updated by SolidGeek. Thanks to them for their contributions to the esk8 community! This is the link to the library I am using: https://github.com/SolidGeek/VescUART , you may download it from the link above and add it to the arduino library.

Second step: Wiring

Wiring diagram is as follows:

UNO VESC 5V 5V GND GND TX RX RX TX