Post updated 2016-01-22
About this project
I have made many updates to my custom motor controller recently and the old post is getting confusing with notes and updates, I decided to write a new post about it that hopefully is more clear, more complete and easier to follow. This might sound a bit ambitions, but my goal is to make the best ESC available. I really enjoy sharing knowledge, so I want to keep all the hardware and software open.
This is an overview of the schematic (download a complete PDF here):
This is the front of the PCB:
3D render from KiCad:
Some screenshots of the configuration GUI (BLDC Tool):
All files are on github to keep them up to date, so check these links on a regular basis:
- Hardware design
- Bill of materials
- Configuration GUI
- Video logger
- osx and windows builds of BLDC Tool, Video logger etc. by Jacob Bloy
- Old post motor controller (just for reference)
- Video overlay logging
- Electric skateboard motor tutorial (KV, cells, etc.)
- Startup torque
- Hardware debugging
- Making a programmer
- Writing custom applications
- UART Communication
Because information about the VESC is scattered all over the internet and a lot of information is in email conversations with me, I have created a forum dedicated to the VESC here.
I have created an IRC channel on freenode where you can live chat with me and other users about VESC and my other projects. Feel free to join: http://webchat.freenode.net/?channels=vedder
- The hardware and software is open source. Since there are plenty of CPU-resources left, the customization possibilities are almost endless.
- STM32F4 microcontroller.
- DRV8302 MOSFET driver / buck converter / current shunt amplifier.
- IRFS7530 MOEFETs (other FETs in the same package also fit).
- 5V 1A output for external electronics from the buck converter integrated on the DRV8302.
- Voltage: 8V – 60V (Safe for 3S to 12S LiPo).
- Current: Up to 240A for a couple of seconds or about 50A continuous depending on the temperature and air circulation around the PCB.
- Sensored and sensorless FOC wich auto-detection of all motor parameters is implemented since FW 2.3.
- Firmware based on ChibiOS/RT.
- PCB size: slightly less than 40mm x 60mm.
- Current and voltage measurement on all phases.
- Regenerative braking.
- DC motors are also supported.
- Sensored or sensorless operation.
- A GUI with lots of configuration parameters
- Adaptive PWM frequency to get as good ADC measurements as possible.
- RPM-based phase advance (or timing/field weakening).
- Good start-up torque in the sensorless mode (and obviously in the sensored mode as well).
- The motor is used as a tachometer, which is good for odometry on modified RC cars.
- Duty-cycle control, speed control or current control.
- Seamless 4-quadrant operation.
- Interface to control the motor: PPM signal (RC servo), analog, UART, I2C, USB or CAN-bus.
- Wireless wii nunchuk (Nyko Kama) control through the I2C port. This is convenient for electric skateboards.
- Consumed and regenerated amp-hour and watt-hour counting.
- Optional PPM signal output. Useful when e.g. controlling an RC car from a raspberry pi or an android device.
- The USB port uses the modem profile, so an Android device can be connected to the motor controller without rooting. Because of the servo output, the odometry and the extra ADC inputs (that can be used for sensors), this is perfect for modifying an RC car to be controlled from Android (or raspberry pi).
- Adjustable protection against
- Low input voltage
- High input voltage
- High motor current
- High input current
- High regenerative braking current (separate limits for the motor and the input)
- Rapid duty cycle changes (ramping)
- High RPM (separate limits for each direction).
- When the current limits are hit, a soft back-off strategy is used while the motor keeps running. If the current becomes way too high, the motor is switched off completely.
- The RPM limit also has a soft back-off strategy.
- Commutation works perfectly even when the speed of the motor changes rapidly. This is due to the fact that the magnetic flux is integrated after the zero crossing instead of adding a delay based on the previous speed.
- When the motor is rotating while the controller is off, the commutations and the direction are tracked. The duty-cycle to get the same speed is also calculated. This is to get a smooth start when the motor is already spinning.
- All of the hardware is ready for sensorless field-oriented control (FOC).
Writing the software is the remaining part. However, I’m not sure if FOC will have many benefits for low inductance high-speed motors besides running a bit quieter.Sensored and sensorless FOC is fully implemented since FW 2.3.
The is the ESC mounted on my electric longboard:
Sensorless startup and low-speed performance:
A short tutorial/demonstration on how to upload the firmware and get your motor running:
My electric longboard:
Video overlay logging (see a post about that here):
The PCB is designed using KiCad. Have a look at the links under the Resources heading at the top of this page to find all files. Currently I have no assembled PCBs or kits to sell, but you can order bare PCBs from hackvana with these gerber files. Since hackvana got so many orders for my ESC, Mitch wrote a wiki page about how to order VESC boards from him. That makes it super easy to order the PCBs from him.
The components in the BOM can be ordered from mouser.com. Mouser numbers are included in the BOM as well. Make sure to order a bit extra of small capacitors and resistors in case you drop some of them and since the price doesn’t change much at all. Last I ordered, ordering 10 MOSFETs was cheaper than ordering 6 because there is a price break at 10, so have a look at the price breaks as well.
For assembling the PCBs, the following pictures are useful (the latest versions can be found on github):
Remember to put an electrolytic capacitor close to the ESC on the supply cable. How large it has to be depends on the length and inductance of the battery cables, but I usually use a 2200uF 63V capacitor.
This is the best tutorial I have seen so far. It really is as easy as it looks when done right.
- Flux is essential. Without flux, it won’t work. I use a flux pen.
- Lead-free solder is no good. It has more poisonous flux, requires more heat, gives lower quality and is difficult to handle. Don’t use lead-free solder.
- Use a flat, screwdriver-shaped tip. Don’t use a cone tip, because putting solder on the top of it is almost impossible.
- If you get bridges between smd pins, removing them is easy with a soldering wick.
- Make sure to get the alignment right for the microcontroller when soldering the first corner. If you solder multiple corners and the chip is misaligned, you have to use hot air and remove it, then clean the pads and start over.
Here is a video on the technique I use to solder the pad under the DRV8302:
I just put solder on the pad and use a hot air soldering station. Again, using leaded solder makes it easier. When soldering the DRV8302, I first solder the pad using hot air and then I solder the pins with a soldering iron. Notice that the pad under the DRV8302 must be connected for it to work, since it is the ground connection.
VESC Hardware by Benjamin Vedder is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Software Installation and Configuration Tutorial
This a brief tutorial on how to get everything running using a fresh install of Ubuntu 14.04. Here is a video where I do everything live to demonstrate that it isn’t that difficult. Please read all the instructions carefully to avoid most problems.
So let’s open up a terminal and get started…
Install a toolchain to compile the firmware (for more details, have a look at this page):
sudo apt-get remove binutils-arm-none-eabi gcc-arm-none-eabisudo add-apt-repository ppa:terry.guo/gcc-arm-embeddedsudo apt-get updatesudo apt-get install gcc-arm-none-eabi=126.96.36.1995q3-1trusty1
Install other dependencies
sudo apt-get install build-essential qt-sdk openocd git libudev-dev libqt5serialport5-dev
Add yourself to the dialout group to access the USB port of the ESC without being root:
sudo adduser $USER dialout
Uninstall modemmanager (unless you use it) to avoid a delay every time the ESC is plugged in to the USB port:
sudo apt-get remove modemmanager
Add udev rules to access the programmer without being root:
wget vedder.se/Temp/49-stlinkv2.rulessudo mv 49-stlinkv2.rules /etc/udev/rules.d/sudo reload udev
Log out and log back in. You should now be ready to compile the firmware, upload the firmware, compile BLDC Tool and run BLDC tool.
DOWNLOAD, COMPILE AND UPLOAD THE FIRMWARE
First, connect a programmer as described in this post. Then, download the latest firmware from github, compile and upload it:
mkdir BLDCcd BLDCgit clone https://github.com/vedderb/bldc.git bldc-firmwarecd bldc-firmwaremake uploadcd ..
Note: before running the make upload command, you should open conf_general.h and select which hardware version you are using. It is printed on the PCB. Also, 2015-01-22 I changed the voltage divider resistors to allow up to 60V to be measured by the ADC, so in that case you also have to override VIN_R1 to 39000.0 in conf_general.h.
DOWNLOAD, COMPILE AND UPLOAD THE BOOTLOADER
Again, connect a programmer as described in this post. Then, download the latest bootloader from github, compile and upload it:
mkdir BLDCcd BLDCgit clone https://github.com/vedderb/bldc-bootloader.git bldc-bootloadercd bldc-bootloadermake uploadcd ..
With the bootloader, BLDC Tool can be used to upgrade the firmware later.
DOWNLOAD, COMPILE AND START BLDC TOOL
From the BLDC directory that you created in the previous step, type:
git clone https://github.com/vedderb/bldc-tool.git bldc-toolcd bldc-toolqmake -qt=qt5make./BLDC_Tool
You should see the following screen:
Connect the ESC to the USB port of your computer and click “Connect” in BLDC Tool. The lower right corner should now say “Connected”. If you have gotten this far, you should be ready to connect a motor and configure the ESC from BLDC Tool.
Note: If you have more than one usb-modem device in your computer (laptops often have built-in 3g modems), then you have to change ttyACM0 to the port of the ESC. To figure out which ttyACMx port the ESC got, open a terminal and type the following command right after plugging the USB cable in:
dmesg | tail
BLDC Tool can also be started by going to the bldc-tool directory with a file browser and double-clicking on “BLDC_Tool”.
UPDATING TO THE LATEST FIRMWARE
Updating to the latest firmware and the latest version of BLDC Tool is rather simple. From the bldc-firmware directory, type the following commands while the programming cable is connected to the ESC:
git pullmake upload
Note: Updating the firmware will delete the configuration of the ESC. To save it from BLDC Tool, use the “Read configuration” button and then “Save XML”. After updating the firmware, you can restore it with “Load XML” and “Write configuration”.
Also updating BLDC Tool is important and recommended at the same time as updating the firmware. In order to do that, go to the bldc-tool directory and type:
Now you have the latest version of the firmware and BLDC Tool. Remember to reconfigure the ESC after these changes.
Note: During the configuration, it is assumed that the USB cable is connected to the ESC and that the lower right corner of BLDC Tool says “Connected”.
The first thing to do in the “Motor Configuration” tab is to click “Read configuration” while the ESC is connected to get the current configuration. After that, click “Load XML” and look for a configuration that is the same as or similar to your motor in the “mc_configurations” folder included with BLDC Tool. If you find exactly your motor, you don’t have to change anything unless you want to tweak some parameters for your application.