VESC BLDC Motor Control

The VESC Project, started in 2017, provides open source hardware and software for sensored brushless DC motor control. The Cheap FOCer 2 is a VESC version 6 derivative that focuses on affordability and design for manufacture.

I have further improved the latest Cheaper FOCer-2 version 1.0 board. I needed several for a project, but I also ordered some extras from LCSC.

If you would like to support my work:

Assembled, flashed, and tested CFOCer v1.0 BLDC Controllers can be purchased on Tindie: https://www.tindie.com/products/vertile/cfocer-v10-bldc-foc-controller-based-on-vesc-v6/

Add the case as an option when purchasing the CFOCer v1.0 Cases are also available for purchase on Tindie: https://www.tindie.com/products/vertile/cfocer-v10-case-with-integrated-aluminum-heatsink/

Assembly

After ordering from LCSC, I followed the steps outlined in the assembly guide, to complete assembly of the hardware.

I built my own case, a combination CNC milled heatsink.

The sides are 3D printed out of PTEG.

You'll also need a silicon heat pad to electrically isolate the MOSFETs from the heatsink.

Case

I designed an aluminum and 3D printed case that is easily assembled with M3 bolts. It also has a through-hole mounting pattern to make mounting the case easy. See the following drawing for details on the mounting pattern. The assembled width of the case is 23mm, so you'll want to use M3 bolts longer than 23mm for mounting on another surface.

Case design files are available on thingiverse under the Creative Commons Attribution-NonCommercial-ShareAlike license, if you have access to a CNC and a 3D printer and would like to make your own.

Case Hardware

You'll need a few things to assemble the case, and optionally mount the case on another surface.

Software

The following is how to build the necessary software on MacOS. There is a somewhat dated but perhaps still useful guide on setting up a linux build environment on the VESC site.

Updated repositories with support for the Cheaper FOC are:

Dependencies

Install Version 7 of the GNU arm gcc toolchain by running:

./scripts/setup.sh

Then add the toolchain to your path:

export PATH=$(pwd)/toolchain/bin:${PATH}

Note: Version 7 of the gnu arm toolchain must be used, lest you run into errors.

On mac, use brew and install stlink and openocd at the same time:

brew install arm-gcc-bin stlink openocd

Note, the bootloader is included with the main firmware, so no need to upload it separately

Firmware

Edit conf_general.h to select the correct board (which is already done in my fork and build and upload with the following command.

Plugin your board to your st-link adapter, you'll see a blue light come on, then flash the bootloader by running:

export PATH=$(pwd)/toolchain/bin:${PATH} # make sure to use the right toolchain on MacOS!
make upload

Now you're ready to connect the speed controller to your computer with a micro USB cable.

You'll need to power the controller by connecting a supply of at least 10v to the main power leads. I also wired up a motor for testing.

VESC Tool Configuration

Now we can configure the ESC with the VESC tool.

Walk through both the motor and the input setups to spin up the board and test it.

Software Debugging Setup

If you're not so lucky to have the above just work, you can setup a debugging environment:

Note: after downloading on MacOS, run the following to remove the quarantine attribute:

xattr -d com.apple.quarantine ~/Downloads/eclipse-embedcdt-*-macosx.cocoa.x86_64.tar.gz

Unzip:

tar xzf eclipse-embedcdt-2020-09-R-macosx.cocoa.x86_64.tar.gz

Move the application into your applications folder:

mv eclipse.app /Applications/
  • Import projects -> C/C++ -> Existing Code as a Makefile Project

  • Create a new Debug configuration

    • Pick OpenOCD Debugging

    • Specify your debug configuration with full paths to the binaries

A UART is available on the COMM port (J2) Pins 1 (GND), 5 (RX), and 6 (TX) should be used.

Building the Configuration Tool

If you prefer to build your own copy of the configuration tool.

Dependencies

Install qt5

brew install qt

Building

The normal build script is ./build_macos, but this wasn't working for me, so I just ran some of the commands in the script:

export PATH=$(brew info qt|grep Cellar|awk '{print $1}')/bin:$PATH
rm -rf build/macos/*
qmake -config release "CONFIG += release_macos build_original"
make clean
make -j8
open build/macos

Drag esc_tool_3.00.app into your Applications folder

References

Check out the Cheaper FOCer 2 post on the esk8 forum for more info on the hardware.