In order to change the firmware running on the VESC, one need to compile the custom firmware with the modifications needed. I use Mac OS X on my workstation and here is how I do it.
First download the latest firmware from https://github.com/vedderb/bldc
git clone https://github.com/vedderb/bldc.git
brew tap PX4/homebrew-px4
brew install gcc-arm-none-eabi-49
sudo brew link gcc-arm-none-eabi-49
In the bldc folder you cloned from github you first need to edit a few things before the make and the upload to the VESC (IMPORTANT)
you need to define the correct HW version that´s compatible with your VESC. When cloned from github the preselect HW is #define HW_VERSION_60
In my case it should be 4.12.
Simply comment-out the HW_VERSION_60 and uncomment the correct version
In my case it should look something like this:
//#define HW_VERSION_40 //#define HW_VERSION_45 //#define HW_VERSION_46 // Also for 4.7 //#define HW_VERSION_48 //#define HW_VERSION_49 #define HW_VERSION_410 // Also for 4.11 and 4.12 //#define HW_VERSION_60 //#define HW_VERSION_R2 //#define HW_VERSION_VICTOR_R1A //#define HW_VERSION_DAS_RS //#define HW_VERSION_PALTA //#define HW_VERSION_RH //#define HW_VERSION_TP //#define HW_VERSION_75_300 //#define HW_VERSION_MINI4
Now you are free do edit the other files in which they suits your needs. For example one can edit in the conf_general.h to enable the HW SPI PINS which allows you to connect the encoder to the HW pins instead of the hall sensor port (no modification on the VESC needed which would be the case if you have hall sensor filter)
// Settings and parameters to override //#define VIN_R1 33000.0 //#define VIN_R1 39200.0 //#define VIN_R2 2200.0 //#define CURRENT_AMP_GAIN 10.0 //#define CURRENT_SHUNT_RES 0.005 //#define WS2811_ENABLE 1 //#define WS2811_TEST 1 //#define CURR1_DOUBLE_SAMPLE 0 //#define CURR2_DOUBLE_SAMPLE 0 #define AS5047_USE_HW_SPI_PINS 1
When you are done editing simply open terminal
cd bldc make
This will compile the firmware and create a build folder which include a .bin file which can be used in vesc tool under “custom file”
Please note that everything is at your own risk and I take no responsibility if you are the VESC takes any damages.