Introduction

The VESC Project, started in 2017, provides open-source hardware and software for sensored brushless DC motor control.

I needed several VESC version 6 brushless motor controllers for a project. After looking at all the different options available, I decided to build the Cheap FOCer 2, with a few tweaks for manufacturability. I went for the highest quality components I could source, including Infineon MOSFETs and Rubycon capacitors. I also ordered some extras, which can be purchased on the Vertile store.

If you would like to support my work:

Assembled, flashed, and tested CFOCer BLDC Motor Control Boards can be purchased on my online store: https://store.vertile.com/product/cfocer

Add the case as an option when purchasing the CFOCer for a discount or purchase separately: https://store.vertile.com/product/cfocer-case

Alteratively, control boards and cases are available on my Tindie store: https://www.tindie.com/stores/vertile/

Pinout

This is the pinout for the Vertile CFOCer VESC v6.

Hardware Assembly

I ordered the PCBs with most of the SMD components already mounted. I only had to hand-solder the SMD inductors. I also soldered the 2mm JST plugs, Infineon MOSFETs, and Rubycon capacitors.

I built my own case, which is a combination CNC milled aluminum heatsink and 3D printed case.

I used silicon heat pads to electrically isolate the MOSFETs from the heatsink. In the future, I may try to anodize the aluminum heatsinks.

Case Design

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.

Vertile CFOCer VESC v6 case drawing.

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 Setup

Once the new hardware is assembled, I flash each board with the initial firmware, which can be compiled from this branch: https://github.com/nathantsoi/bldc/tree/cfocer-black-2022-09-23. The following steps describe the initial flashing process. The same process can also be used to re-flash an existing CFOCer to re-set it to the initial state. For this first flash, you'll need an ST-Link adapter.

Initial Flashing

Clone the repo and checkout the branch like so:

git clone https://github.com/nathantsoi/bldc
cd bldc
git checkout cfocer-black-2022-09-23

Install the compiler and toolchain:

make arm_sdk_install

Plug in your ST-Link and the blue light will come on to indicate the board is powered:

Vertile CFOCer VESC v6 SWD pins.

Flash the board by running the following. You'll see the board's LEDs flash after the process is complete:

make Cheap_FOCer_2_flash

When making a large volume of boards it's typical to create an assembly jig, so the board can be flashed without soldering the SWD pins. I laser cut a jig and installed some pogo pins to make this simple jig:

Vertile CFOCer VESC v6 laser cut jig.

Once the lights flash, you can unplug the board. The next step is to configure the board using the VESC Tool.

VESC Tool Configuration

Note: Download the pre-compiled VESC Tool from vesc-project.com. To access the download, create an account and "purchase" the "VESC Tool Free" version. No payment information is required, simply click next and you will be able to download the software. You can of course also make a donation to the project by selecting a different version. However, all versions have the same functionality as the free version, only the logo in the app is different.

Watch this quick configuration guide to get started, or follow the steps below:

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

Vertile CFOCer VESC v6 connected to USB.

You'll need to power the controller by connecting a supply of at least 10v to the main power leads. 4mm banana plugs work great for testing:

Vertile CFOCer VESC v6 connected to power via 4mm banana plugs.

I also wired up a 6384 size 120KV 4.6KH BLDC Outrunner Brushless Motor with a Hall Sensor for testing, also using 4mm banana plugs:

Once everything is plugged in, connect the VESC Tool to the controller by clicking the connect button:

Flashing the latest firmware

When you connect, if you get an error like the following, you'll need to flash the latest firmware:

Vertile CFOCer VESC Tool Error: Could not deserialize motor configuration.
Vertile CFOCer VESC Tool Error: Connected VESC has test firmware.

To flash the firmware, connect to the board and click the little down arrow button to flash the latest firmware:

Vertile CFOCer VESC Tool: Flashing the latest firmware.

Next, we'll walk through both the motor configuration and the input configuration.

Motor Setup

With the motor connected, click the "Setup Motors FOC" button. Pick the usage type. I'll test with Generic. Continue by clicking "Next" at the bottom right:

Vertile CFOCer VESC Tool: Submit Motors FOC.

Then load the default parameters to reset the settings on the board, when prompted:

Vertile CFOCer VESC Tool: Reset parameters.

Choose the motor size and click "Next":

Vertile CFOCer VESC Tool: Select the motor size. I'm using a medium size motor.

Accept the battery settings and click "Next":

Vertile CFOCer VESC Tool: Accept battery settings.

"Run Detection" on the Setup page. Note that the motor will spin up while it runs the detection.

Vertile CFOCer VESC Tool: Run motor detection.

Accept the detection results and click "OK":

Vertile CFOCer VESC Tool: Accept the motor detection results.

Finally, test the motor is setup correctly and running in the right direction with the FWD and REV buttons

Vertile CFOCer VESC Tool: Test motor direction.

Input Setup

Click the "Setup Input" button and hit "Next":

Vertile CFOCer VESC Tool: Open the VESC Input Setup Wizard.

I'm using a PPM RC servo tester, so I'll use the PPM option. Click "Next":

Vertile CFOCer VESC Tool: PPM Input option.

While on the PPM Mapping page, move the PPM throttle on the RC servo tester to the minimum and maximum positions. Move it back to the middle position and click "Next":

Vertile CFOCer VESC Tool: PPM Mapping.

On the PPM Configuration page, under the "Control Type" you can select the various types of motor control. I'm leaving it at the default, "Current No Reverse With Brake." Click "Next":

Vertile CFOCer VESC Tool: PPM Configuration.

Click "Finish" and you're done with the configuration.

Vertile CFOCer VESC Tool: Conclusion.

You can now test the motor by moving the throttle on the RC servo tester.

Advanced

In this section, I detail how to debug the firmware with Eclipse and build the configuration tool from the source.

Firmware Debugging

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, instead of just downloading it from vesc-project.com.

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.