Communicating with the VESC using UART

Many people have asked me how to communicate with the VESC using UART, but I did not have a good answer since I haven’t written any tutorial about that and the only thing I could refer to was the BLDC Tool code. Now I have created a project for the STM32F4 discovery board that implements UART communication with the VESC where the full interface is implemented. In this post I will try to explain how the code works and how to port it to other platforms.

Continue reading

VESC – Writing Custom Applications

Updated: 2016-01-22

The VESC has several extra ports and much extra computational power, so it can be used to run custom user code in addition to controlling a motor. This is convenient when there are space constraints and it is also the best way to implement real-time control applications where timing is critical. The code of the VESC is organized in such a way that it is easy to write and maintain custom applications while keeping the code up to date without having many conflicts when pulling updates using git. In this tutorial I will demonstrate how to make a custom application that will run a motor using speed control while a button is held with a speed proportional to the voltage on the ADC_EXT pin.

Continue reading

Connecting a programmer/debugger to my custom STM32 PCBs

When I make custom STM32 PCBs (such as my RF-mote or my ESC), I use an SWD connector for programming and debugging the microcontroller. The connector is a 6-pin micro-jst connector with 2mm pitch, which easily can be found by searching on ebay. An STM32 discovery board with stlinkv2 works perfectly for programming and debugging, and can be connected as shown here (click on the picture to get a larger version where the wire colors can be seen):

DiscoveryBoards_text

Notice that I have removed two jumpers on the discovery board to disconnect the SWD from the microcontroller. The pins in the jst connector are ordered in the same way as on the discovery board, but the outermost (green) cable is connected to 3V or VDD.

There are also some small and inexpensive stlinkv2 programmers available on ebay (just search for stlink v2), such as this one which I have soldered a micro-jst cable to:

EbayStlink_small

Update:

I had some problems with too long JST cables. If uploading the program does not work for you, try shortening the JST cable.

Chosing the right BLDC motor and battery setup for an electric skateboard

Recently, I have been involved with the electric skateboard community because of my custom ESC. I get many questions about motor kv, gear ratio, current, voltage and efficiency. In this post, I will try to explain how things are connected and how to chose the right setup. I will try to keep things simple and not involve too many equations to provide a good intuition for the DIY community. The assumption in this post is that we are using an 50mm-60mm hobby outrunner motor.

Continue reading

Debugging the STM32F4 using openocd, gdb and Eclipse

About

This article will describe how to debug the STM32F4 microcontroller using the zylin eclipse plugin. The following setup will be used:

  • STM32F4 discovery board
  • The built-in SWD programmer/debugger on the discovery board
  • Toolchain and example program from this tutorial (I have updated the build script for debugging to work, so if you have followed the tutorial before you may have to download and run the summon-arm script again)

The result will look something like this:

Debug_View

You can:

  • Set hardware breakpoints
  • See variable values when hitting the breakpoints
  • Change variables, then continue
  • Many other things…

Continue reading

Get started with the STM32F4 on Ubuntu Linux

Updated 2014-04-03

Introduction

This tutorial describes how to set up a complete and free toolchain for STM32F4xx microcontrollers, including how to use hardware floating point support. It is mostly aimed towards beginners with ARM microcontrollers, however, experienced developers could probably find something useful here as well. It is assumed that the reader is a bit familiar with the C programming language and the Bash terminal.

At the end of this tutorial, the reader should be able to build and upload programs to the STM32F4** using the STLinkV2 interface (such as the one found on the STM32F4 Discovery board). This is done using Ubuntu Linux in this tutorial, however, the instructions should be general enough to make this work on any Debian-based GNU/Linux distribution.

The following hardware/software will be used:

Continue reading

Access IEEE papers via Chalmers from home

If you are studying at Chalmers University of Technology you can download IEEE papers for free, but that only works if you are connected to the network at the university. One way to work around this and access them from home is to use an SSH tunnel, and I’m going to explain how to do this from Linux. This is tested on Ubuntu 12.04, but it should work the same way from any distribution if OpenSSH is installed, which it usually is by default.

Continue reading