Skip to content

Vesc interface manual

Vincent Manoukian edited this page Nov 9, 2021 · 13 revisions

Goal of interface

Using a Vesc Controller from vedder to drive de BLDC motor like MIGE of others. Connection between OpenFFBoard and the vesc is done with a CANBus. CANBus is used to send torque command to the VESC, get Status and get Vesc Encoder Position. Vesc driver required an encoder to work in FOC mode and some upgrade, take a look on the Hardware section below ;)

Hardware

BOM

  • 1 Vesc -> 4.12 or a vesc 4.20 are tested (from flipky) but others hardware would works
  • 1 CANBus transceiver -> TJA1051 works well ( CJMCU-1051 )
  • 2 shunts 0.005 Ohm (5 mOhm)
  • wiring

Wiring the VESC and OpenFFBoard

OpenFFBoard / disco TJA1051 VESC
5V VCC (2)
GND GND (2)
TX CAN / PD1 CTX
RX CAN / PDO CRX
CAN H CAN H
CAN L CAN L
S CAN / PD4 S
3V NC (1)

(1) The NC Pin on the TJA1051 is badly name : NC on one side, and 3V on the other side ;)

(2) Connect GND and 5V on the VESC if you want to power a discovery board from the vesc

Wiring the VESC to an ABZ Encoder

Vesc in FOC mode can use a lot of encoder, take a look on the vesc-project.com website to get documentation.

In my case i use the Mige ABI encoder 2500cpr wiring like this:

VESC Encoder
GND GND
5V 5V
Hall 1 A wire
Hall 2 B wire
Hall 3 Z wire

VESC hardaware update

  • Replace the 2 stock shunt 0.001 ohm with the 0.005 ohm: this reduce the current range from -150/150A to -30/30A. By reducing the range we increase the accuracy of current's samples. It reduces noise and vibrations in the wheel.
  • If you want to use an ABZ encoder on the VESC Remove the 3 capacitor and resistance on Hall 1, 2 and 3 on Vesc 4.x

Software

First setup the vesc to drive the motor

Flash the firmware

Since the release 5.03 dev 51 release, the vesc firmware include all necessary command to be drive by OpenFFBoard.

You can get any release after 5.03 to build this setup. Currently the 5.3 release is work on progress, i build and share for you the required Firmware and the VescTools to setup you vesc. Take a look here to download it: Vesc 5.3 dev release

You can upgrade the firmware of the vesc with the vesc tools connected in USB: vesc power supply is mandatory and motor connected on the Vesc.

!!!! NEVER turn on a vesc without a motor wired : you will burn vesc !!!!

Setup vesc

This is not a tuto on how to setup a vesc, but in few word:

  1. Wire vesc, motor and encoder: all of them before power on the vesc.
  2. Start vesctools to setup
  3. In general/motor setup you motor in FOC, select the encoder and is resolution (ABI 10000ppr for my 2500 cpr for exemple)
  4. Setup the current for motor/battery and don't change the abs max current settings. Current motor is the max current you want FFB engine send to the motor.
  5. In the FOC tab do a motor calibration, chose ENCODER instead of SENSORLESS and save
  6. In FOC/Encoder tab do a calibration and save
  7. In the RT/graph go to position tab, click on encoder and turn the motor shaft, graph must move when you turn, else you have an encoder setup issue
  8. In general/motor/advanced change min current to 0.0A and frequency to 25000hz
  9. In the bottom of the vesc tool : click on D0.20 to run motor in dutycyle : i must turn in CW direction, click on stop button to stop it. If not reverse the motor "general/motor" tab, and redo a sensor calibration (2 steps below). If you have another issue try redo a detection and check the vesc documentation for more information. TIPS: on large motor use 5A, 0.3 duty cycle and 700 erpm to do the detection.
  10. If you are here and the motor turn in dutycyle, you can now test the torque force. With my mige 15015, i can run motor with I=0.7A and feel it counter when i try to rotate. Force is linear during a turn. If you feel force growth/reduce, you have a foc calibration issue.

Setup the OpenFFBoard to drive the motor

In the Configurator, choose the VESC as driver.

By default the CANBus speed is set to the default vesc CAN Bus so you don't need to change it. Check if the vesc status is ok and the encoder rate is around 1000, if not you can increase the canbus speed to increase it.

When you move the wheel, the bargraph have to move.

If you need, you can center it in the Axis tab: the VescDriver store the center position to keep it. If you want to erase the stored position, you have a button to reset it.

Contribution

https://www.dropbox.com/s/0drc02w5u76eyx5/vesc_3rdparty.jpg?dl=1