• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

VESC based INNOTRACE motor controller for Bafang M620 CANbus

Prepared the washers for the AMPLIFIER PCB terminals

Lightly sanded the flat face of the copper washers to make sure there are no burrs

1773182854737.png

Coated the bottom face with a thin layer of solder to ease the soldering process

1773182920286.png

1773182954122.png

1773182999455.png
 
Guys, we are so back! The BRAIN board and the Bluetooth work with the VESC Tool application! Still waiting the last bit for the AMPLIFIER board before with can fire this bad boy up.

1773362696059.png
 
Last edited:
Alrighty, you already know how to flash the Bluetooth module firmware with J-Link. But that thing is very expensive. So today I am going to show you how you can flash your INNOTRACE M620 CAN motor controller Bluetooth module NRF chip with a cheap ST-Link V2 USB dongle.

Here is the tools list you need (the same tools you need to flash the STM32 chip of the motor controller):

1) Obtain an ST-Link V2 dongle (ST-Link V2 dongles can be purchased here for example https://www.amazon.com/dp/B0B2D6HZR6?th=1)

2) Obtain a Tag-Connect cable TC2030-MCP-NL (This cable and all further items below are to connect the ST-Link V2 dongle to the controller. This cable and all items below are optional, you can solder wires to the pads and connect them to ST-Link dongle, however you want to make it happens. The cable can be purchased here https://www.digikey.com/en/products/detail/tag-connect-llc/TC2030-MCP-NL/2666489)

3) If you want to use the Tag-Connect cable I mentioned above then you also might want to obtain a TC2030-CLIP (This clip fastens the Tag-Connect cable to the controller board. This part is obsolete and hard to find. But you can use TC2050-CLIP and re-solder one receptacle to match the TC2030-MCP-NL cable interface. This clip can be purchased here https://www.digikey.com/en/products/detail/tag-connect-llc/TC2050-CLIP-3PACK/12318009 )

1774643761959.png



1774643775852.png



1774643788437.png



This clip can hold the Tag-Connect cable connected

1774644115681.png



4) Obtain an RJ11 to pins adapter ST-RJ11-R-BB if you want to use the Tag-Connect cable I mentioned above (This adapter is to connect Tag-Connect cable plug and have convenient access to the pins. The adapter can be purchased here https://www.digikey.com/en/products/detail/schmalztech-llc/ST-RJ11-R-BB/23307380 )

5) You also might need to obtain some jumper wires for wiring between the ST-Link V2 and the ST-RJ11-R-BB adapter (To connect the ST-Link dongle to ST-RJ11-R-BB. Bulk of such wires can be purchased here https://www.digikey.com/en/products/detail/digikey/DKS-20FF-20/17038802 )



I recommend you to install Bluetooth firmware first before flashing the motor controller firmware. Here are the Bluetooth flashing instructions:

1) Download and unzip the OpenOCD Windows Programmer files (latest version should probably work the best): Download OpenOCD for Windows

2) Open Notepad application and type the following text and save it as openocd.cfg file into the OpenOCD “bin” directory (same dir as openocd.exe):


# nRF51822 Target
source [find interface/stlink-v2.cfg]

transport select swd

set WORKAREASIZE 0x4000
source [find target/nrf51.cfg]

# use hardware reset, connect under reset
#reset_config srst_only srst_nogate

3) Copy the Bluetooth firmware hex file from the shared KiCAD files controller archive "\M620 CAN VESC controller_BRAIN\Firmware" folder to the OpenOCD “bin” directory (same dir as openocd.exe). Name that copied firmware file to Bluetooth_Firmware_nRF51822.hex


4) Make sure ST-Link V2 drivers are installed. ST Link V2 drivers can be downloaded here https://www.st.com/en/development-tools/stsw-link009.html

5) Connect St-Link V2 to the BRAIN board PCB (3.3V to 3.3V, GND to GND, SWDIO to SWDIO, SWCLK to SWCLK) using the P8(NRF) interface (Tag-Connect). Pinout of the P8(NRF) interface can be found in the BRAIN board KiCAD files.

1773364365738.png

1773364568213.png

1773364671486.png

6) Type cmd.exe into the address bar of Windows Explorer while you are in OpenOCD “bin” directory (same dir as openocd.exe) and press Enter

1773365570577.png


1773365622211.png

7) Paste this command and press Enter on the keyboard

openocd -f openocd.cfg -c "init" -c "halt" -c "nrf51 mass_erase" -c "program Bluetooth_Firmware_nRF51822.hex verify reset exit"


1773365063131.png

8) Wait until the program finished flashing the Bluetooth module, then you can disconnect the ST-Link V2. The last lines of the report of the OpenOCD program in case of properly flashed firmware should look like this:

** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked

1773364459803.png


Now the Bluetooth module is flashed!

After this you can flash the STM32 with the controller firmware the regular way with the same ST-Link V2 with the same Tag- Connect cable with STM32 ST-LINK Utility application. You need to connect the Tab-Connect cable to the P7(STM32) Tag-Connect interface. That interface has the same pinout as the P8(NRF) interface for the Bluetooth module (plus NRST pin) so you can use the same cable to flash the firmware files for both, Bluetooth and STM32 without changing the pins. Here are the instructions


After flashing the controller firmware on the blank STM32 the green LED should light up and you also should be able to connect the controller to VESC Tool application using Bluetooth.

1773365318432.png
 
Last edited:
The moment of truth is coming guys! The excitement is over the top! The controller has been installed in the motor case!

1773794475277.png

Here is the installation process:

Place some thin double sided adhesive tape on the bottom of the AMPLIFIER board

1773794579393.png

Stick the 0.4-0.5mm thick isolation layer on the bottom of the AMPLIFIER board. We cut this isolation layer here


1773794684732.png

Cut 6 of 0.5x8x15mm thermal pads

1773794806005.png

Attach the thermal pad to the isolation layer pockets

1773794861240.png

1773794893922.png

Install the AMPLIFIER board to the motor case

1773794965177.png

Before tightening the motor leads screws I recommend to attach the plastic shroud and route the motor leads the way they do not interfere with the plastic shroud, then tighten the motor leads screws

1773795084549.png

The plastic standoffs need to be a little taller for proper fitment. I 3D printed the spacers for those out of ABS plastic. The "Standoffs spacer.STL" file for 3D printing can be downloaded here


Also pay attention I used one low profile screw from the Bafang plastic shroud to for the PCB. This is necessary to avoid interference. For one shroud screw you can use the Bafang PCB screw instead.

1773795211327.png


1773796261489.png

Attach the BRAIN board and external Bluetooth antenna

1773796018805.png

1773795780925.png

I recommend to cut a chamfer on the plastic shroud edge at the wiring harness grommet if you are planning to use external Bluetooth antenna to avoid stress on the antenna cable

1773795883534.png

1773795915684.png

Attach the shroud. Pay attention I reused the Bafang PCB screw to attach the shroud in one spot because of I used one low profile shroud screw for the PCB

1773796110171.png

The matching wiring harness connectors are indicated on the BRAIN board PCB by colors abbreviations

1773796478896.png
 
Last edited:
Guys, we are dangerously close! Everything is ready and I am about to stick the fully charged 13S battery to the motor controller. The best thing I can do is to put a 10A fuse in the power line. Do you think we can do this? Who knows what can happen?

1773797362033.png

1773797282892.png

1773797445503.png
 
Good news, I connected the battery and it did not explode! That means there is only one thing left to do - try to turn the controller on, setup the motor and see if it spins. Do you think it is going to work?

1773798304658.png
 
Holy cow, we did it again! It works! Unbelievable, from the first try! We nailed it, guys, again! It is time to party!


Walk mode works, speed sensor works!


Cadence + Torque sensors works! We got everything works guys!

 
Last edited:
Arighty, it is time to pack everything up and close the motor. Motor closes nice and easy, thanks to the slim design and the cable management, but you still need to make sure you do not jam the wires between the motor parts and the wires go to the cavity.

The Bluetooth antenna cable should be sandwiched between the grommet the the gasket.

1773816117798.png

1773816175510.png
 
Last edited:
The controller files has been updated (some fixed on the silkscreen and components CAD models, fixed a part link, dumped controller firmware from the working motor with proper M620 motor configuration, added Bluetooth firmware installation instructions, added a CAD file for the 3D printed standoffs spacers, added a CAD file for the 3D printed rotary encoder bumper, some other minor changes)


Full Scale.gif
 
Since there are people might be interested to assemble this thing I will post the tools you will likely need.

Here is the list of must have tools.

Hot plate. You can probably save money using your kitchen cook top or your household iron/steamer to solder the PCB, but that certainly requires experience and skill to utilize such items without ruining the parts. But there is a budget dedicated tool for this should work better of cause, this hot plate works good


Hot air. This cheap hot air station works just fine


Besides necessity to solder the bottom pads on some integrated circuits where I places through plated holes and some through hole components most of the work can be done with a hot plate and a hot air tool. You also might need to fix something after the hot plate soldered PCB, or if you did not place a component and need to solder it later then you do need soldering irons (and in some cases even soldering tweezers). Depending on the task you will need different sizes, different power, different thermal mass etc. I will not recommend anything here, but I am sure the cheap stuff from Amazon will work just fine for a single work.

You can use these cheap boards to fix the PCB on the table top for stencil soldering paste application. Those boards are 1.6mm thick, same as the BRAIN board. The AMPLIFIER board is 1mm thick so you will need to put that 0.4-0.5mm thick isolation layer on the bottom to level it with the 1.6mm boards for proper soldering paste stencil leveling.


This is the leaded solder paste should work


This is the leaded solder should work in case you need it (in perfect situation you do not need it)


Solder wick just in case (in perfect situation you do not need it)


Flux (in perfect situation you do not need it)


Leaded soldering iron tip tinner (in perfect situation you do not need it)


Soldering iron cleaning sponge (in perfect situation you do not need it)


Microscope. I recommend you to do some research here if you want to find a budged solution will work for you. If you are experienced you might get away with a cheap option. If not, you do need large working area, stereoscopic view and a lot of magnification for components placement, soldering, cleaning and inspection. You do not need microscope with camera, just a microscope without camera. I would say Amscope SM-1 7X-45X continuous zoom microscope combined with 0.5X WD165 Barlow lens is perfect for this work and you might need to orient on this option if you want to find something perfectly suitable for this work but more budget.



You also need non-magnetic antistatic tweezers. There are plenty of options


Precision probes. I do not know if non-magnetic antistatic (like tweezers) precision probes exist, I did not find such. You might struggle working with small components because of they might attract them. The probes are still must have to position the placed components precisely after dropping them into the place and usually work better than tweezers. You might need to build a probe out of antistatic tweezers if you will struggle with regular probes. I used these


Vacuum pick and place tool. This is the tool can make assembly significantly easier and more stress free. If you are patient enough and has steady hand you can avoid using it, but this tool makes life much easier. The tool works the best if you pick the components from the tape rail rather than from a surface.


If you use that vacuum pick and place tool combine it with thin dispensing needles (the kit does not have very thin needles and you will need those for very small components.

 
Last edited:
Started removing the old M620 with VESC for Bafang M620 UART controller and other UART components from the bicycle

1774070772018.png

1774071341372.png
 
Last edited:
Back
Top