VESC – Open Source ESC (original) (raw)

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):

Schematic-1

This is the front of the PCB:

PCB_Front

The back:

pcb_back

3D render from KiCad:

3D

Some screenshots of the configuration GUI (BLDC Tool):

RT_Data

MCCONF_Limits

APP_PPM

Resources

All files are on github to keep them up to date, so check these links on a regular basis:

Forums

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.

Live Chat

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

Features

The is the ESC mounted on my electric longboard:

pcb_on_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):

Hardware

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):

B_Modules-1 F_Modules-1

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.

Soldering Tips

This is the best tutorial I have seen so far. It really is as easy as it looks when done right.

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.

Creative Commons License
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…

Preparations

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-eabi sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded sudo apt-get update sudo apt-get install gcc-arm-none-eabi=4.9.3.2015q3-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.rules sudo 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 BLDC cd BLDC git clone https://github.com/vedderb/bldc.git bldc-firmware cd bldc-firmware make upload cd ..

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 BLDC cd BLDC git clone https://github.com/vedderb/bldc-bootloader.git bldc-bootloader cd bldc-bootloader make upload cd ..

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-tool cd bldc-tool qmake -qt=qt5 make ./BLDC_Tool

You should see the following screen:

MCCONF_Limits

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 pull make 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:

git pull qmake make

Now you have the latest version of the firmware and BLDC Tool. Remember to reconfigure the ESC after these changes.

Motor Configuration

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.

Note: Even if you load an XML configuration file, use “Read configuration” first anyway because the XML might not contain all parameters. The missing parameters will become blank and can mess with things. Soon I will make sure that sane default parameters are loaded, but I haven’t done that yet.

Sensorless Motor Parameters

Since this ESC uses uncommon techniques to commutate the motor in order to get good low-speed performance without sensors, it is important to set correct motor-dependent parameters in the sensor(less) tab. Otherwise, the motor will run poorly or not at all.

This is what the Sensor(less) configuration page currently looks like (I will probably add more auto-detect options soon):

MCCONF_Sensorless

The important motor-dependent parameters are “Integrator limit” and “BEMF Coupling”, and they can be measured with the detection part. I will make a video showing this for several different motors soon, but until then you can try to follow these instructions:

  1. Connect the motor without any load and make sure that it can spin up freely.
  2. Make sure that no other input such as PPM is used. If it is, it will stop the motor immediately when the detection tries to start it and the detection will fail.
  3. Click the “Start detection” button. The motor should spin up, release throttle and then run slowly for a moment.
    1. If the motor doesn’t spin up properly, Adjust “Current” and “Min ERPM” until it does. In general, small motors should have lower current and higher ERPM and larger motors the other way around. Current usually is in the range 1A to 6A and min ERPM usually is in the range 300 to 1200.
    2. If spinning up works but running slowly afterwards doesn’t (the motor just stutters), try increasing “Low duty” to 0.1 or so. Increasing low duty will make it easier for the motor to run slowly during the test, but the result will become less accurate.
  4. Manually put the obtained values into the boxes. I usually round “integrator limit” down to the closest multiple of 5 and “BEMF Coupling” down to the closest multiple of 50. Having them slightly lower than the detection result is good in most cases, so that’s why I round them downwards like that. Getting these parameters perfectly right is not too critical though.
  5. The next parameters to adjust are “Min ERPM” and “Min ERPM for integrator limit”.
    1. What they should be depends on the application and is in most cases not too important, but in general lowering them will work better if the load has much inertia. I have Min ERPM around 200 and Min ERPM for integrator limit around 1000 for all my applications.
    2. You can probably keep the same parameters I have, but if you want to tweak your startup you can experiment with them.
    3. It is important that “Min ERPM” always is lower than “Max ERPM at full brake” and “Max ERPM at full brake in current control mode” on the “Limits” page.
  6. Commutation mode should always be “Integrate”.
  7. The other parameters are for RPM-based timing advance and some other things that aren’t necessary to adjust in the normal case, so I won’t explain them here yet.

For small low-inductance high-speed motors, the delay commutation mode can be used in case the integrate mode does not work. It does not require many parameters, just the minimum RPM which usually can be around 1500. I haven’t tested this mode much, but it is more or less how most hobby ESCs work (which is why it doesn’t require so many motor-specific parameters). Currently it does not support adjustable timing, but I will implement that in a few days since it is quite easy.

Phase advance (other terms: timing adjustment, field weakening)

To compensate for the current lagging behind the voltage at high speeds because of inductance or to get a bit higher top speed at the expense of some efficiency and torque, phase advance can be used. It is implemented in a speed-dependent way so that the motor gets more phase advance the faster it spins. It is implemented this way because having phase advance at low speeds does not give any improvements at all as far as I know, so the best way is to increase the effect as the motor increases its speed. BR ERPM is the electrical RPM of the motor at which the set phase advance is used, and Integrator limit scale at BR ERPM (will rename this option soon…) is the amount of phase advance to use. Setting it to 1.0 gives no phase advance and setting it to 0.0 gives 30 degrees (maximum) phase advance. The set phase advance will be mapped linearly between 0 ERPM and BR ERPM. If you don’t know what this is, you can leave the default options since it is not that important.

Motor

Current, temperature, RPM and voltage-limits can be configured depending on your application.

BLDC_Tool_motor_motor

Note: These limits are not foolproof. If you set them too high, you can damage the ESC and/or the motor.

Once the ESC is configured for your motor, you can use the up and down arrow keys to run the motor forwards or reverse in current control mote, or the right and left arrow keys to run the motor forwards and reverse in duty cycle mode. The buttons in the right-hand side of the GUI can also be used.

Misc

Here are the rest of the motor configuration parameters. You probably want to experiment with Startup boost if you are using current control. The rest of the parameters can be left as their default values unless you have some specific reason to change them.

BLDC_Tool_motor_misc

Application Configuration

First, click “Read configuration” to get the current configuration from the ESC. After that, select which application to use and configure that application.

BLDC_Tool_app_general

PPM

The signal that a normal RC receiver outputs is a PPM signal, so this can be used when connecting an RC receiver to the servo port.

Bldc_Tool_app_ppm

Nunchuk

The Nyko Kama wireless nunchuk can also be used to control the ESC. Note that not all nunchuks for the nintendo wii will work, because they slightly differently.

BLDC_Tool_app_nunchuk

A video where I test this:

Realtime Data Display

Use the “Realtime Data” tab to display realtime information from the ESC. Make sure that the “Activate sampling” box is checked.

RT_Data

Common Problems and Solutions

As I encounter different problems, I will put them here together with possible solutions for reference.

Uploading the firmware does not work.

A DRV8302 fault code appears as soon as the motor starts.

Connecting to VESC via BLDC Tool does not work.

My motor is not running properly.

Is there a way to “boost” the startup of my motor when using current control?

Update: I have ordered assembled VESCs, some of them are for sale

Update about this update: There are no assembled ESCs left. However, If you are interested in assembled VESCs you can still send me an email as described below so that I can put you on my extra list. If someone changes their mind or if there are other problems, I can send you VESCs that get left.

I have ordered 100 assembled VESCs and they will arrive this or next week. I don’t need all of them, so I will sell some of them for 115€ + shipping. Worldwide shipping with tracking is 20€ per order (which can contain more than one VESC). Shipping within Sweden is less expensive and I will update this post as soon as I know the price. You can contact me by email if you are interested (benjamin at vedder.se). Tell me how many VESCs you’d like and your address, and I will reply with an email that confirms that I have put you in my list. Later, when I have figured out how to accept payments, I will send another email with information about how to do that. As soon as I receive your payment, I will ship the VESC(s) to you and send an email with tracking information

I will update this information in the coming days, so make sure to check if there are updates.