• 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

Hello, so i jumped the gun and ordered the pcbs last week. Are the fixes for the silkscreening crucial?
Those fixes are not crucial. The only important part is the bulk capacitors silkscreen marks on the AMPLIFIER PCB do not match the capacitors base at the positive side of the capacitors base because of the capacitor base in the CAD model I downloaded from the supplier website and used for reference did not match the actual part base for some reason and in the previous version of the AMPLIFIER PCB that silkscreen matches that wrong CAD model. When you will align those capacitors align them along the silkscreen mark left and right sides and along the negative side and disregard the positive side chamfers mismatching. That is necessary for proper alignment of the capacitors with the BRAIN board edges. You can see those bulk capacitors silkscreen chamfers mismatch on the positive side of the bulk capacitors on my pictures. The soldering pads of those capacitors are OK and you can use them as reference for alignment too.

1774075013074.png

1774075124774.png

And of cause post the progress
 
Last edited:
Interested in selling the UART controller?
There is an Innotrace X1 controller with motor for sale with all the programming tools and stuff, it is basically VESC for Bafang M620 UART controller.


You can also purchase the Pulsedrive controller. I do not know for sure if this is UART, but It looks like it is UART looking on the connectors on the PCB

 
Last edited:
The new CAN harness and the motor with new Innotrace M620 CAN controller is in the frame, guys! The Bluetooth antenna fits just perfect under the plastic cowl

1774151811666.png

1774151865369.png
 
The motor was also a canbus motor before you modified it?
No, the motor was UART. I replaced the torque sensor and the motor internal harness to make it CAN. Controller, torque sensor and internal harness is the only difference between CAN and UART M620 motors (besides the sticker on the motor case). You can purchase the individual parts to convert UART to CAN (and opposite) on Green Bike Kit for instance.
 
Last edited:
Are you using your custom battery? Do I need a canbus compatible battery with your controller?
I use a custom built 14S 52V 80A 4200W battery with this bicycle. This is the battery I use with this bicycle


Originally I built this battery for the Innotrace X1 controller, so it is less than 60V battery (Innotrace X1 can not tolerate more than 60V). The new Innotrace M620 CAN controller can take up to 100V battery though and have more power, but I am not planning to build new higher voltage higher power battery for now and I just reuse the one I used for the Innotrace X1.

You do not need CANbus compatible battery, any regular battery will work with the new Innotrace M620 CAN controller.
 
Last edited:
Anyone is familiar with the VESC stuff here? I just realized I can not set the Maximum Current more than 60A in the VESC Tool application for some reason. Do you think Marcos did this for us? What is going on here? We need more power!

The "+" sign becomes inactive at 60A. When I type manually bigger number it automatically jumps back to 60A.

1774227352031.png
 
Last edited:
Anyway, I just took it for a ride and the controller works amazingly well. It is smoother than Innotrace X1, more torque sensor controllable, but for some reason it provides slightly less power than Innotrace X1 while it is set to the same power (3000W 52V 60A).

On the flat I struggled to achieve 35mph while the Innotrace X1 controller I did 40mph on flat. On light downhill I achieved 40 mph while while on the Innotrace X1 controller I did 45mph on light downhill.

You also can see I struggle to make wheelies while on the Innotrace X1 controller would loop me if I would press the pedals that hard.

After a few minutes uphill ride the controller temperature was slightly above the environment temperature (around 25C), the motor stator temperature reached 80C briefly but then quire quickly (maybe withing a minute) dropped below 60C after the uphill section. The motor with the Innotrace X1 controller on the same uphill section would start overheating in a minute dialing the power less than the VESC for Bafang M620 CAN controller and at the end of that section motor with Innotrace controller is quite hot (I can not hold my hand on it) while with the VESC for Bafang M620 CAN controller the motor was barely warm.


The power is there but it certainly dumps less power than the Innotrace X1 controller (is feels the same as the VESC for Bafang M560 or VESC for Bafang M600 controllers) and the VESC Tool does not allow to set the amperage above 60A for some reason.

Maybe it is the torque sensor related, maybe they programmed it this way. I did not install and test ride the throttle (I am waiting different smaller size throttle to install), maybe on the throttle it would give the full power.

Here is the 3000W VESC for Bafang M620 CAN powered bicycle Top Speed Test


Here is the 3000W Innotrace X1 powered bicycle Top Speed Test for comparison on the same benchmark road, same bicycle, same conditions

 
Last edited:
OK, I connected the VESC Tool application from PC and found there is a Wattage tab. The Maximum Wattage parameter was set to 2500W, not 3000W. Maybe this is the one held us back?

1774243185486.png

I lifted it to 3100W, we need to test it and see if it gives us extra 5mph.

But I feel like we will need to mess with the Luna firmware source code yet again to make this thing works at the full potential.
 
Last edited:
That is sertanly weird, the power and amperage settings of the Innotrace X1 controller are even lower than what is set on the VESC for Bafang m620 CAN controller. You can see the power settings from the VESC Tool application on my Innotrace X1 controller here, and those settings are the same or lower


But for some reason it goes faster. Maybe Luna limited the torque sensor output power?
 
Let's see how much current we set for this controller without changing the hardware.

The current sensor amplifier output pins are connected to the PC0, PC1 and PC2 pin on the STM32 processor

1774289786010.png


The usable input voltage for those pins in analogue mode is up to 3.3V.

We use INA4181A1 current sensor.

1774290797119.png

Than current sensor multiplies the input voltage from the current sensing resistors 20 times

1774291434024.png

We also apply 1.65V on the reference pins of the current sensing amplifier. Therefore the maximum imput voltage from the current sensing resistors can be (3.3V-1.65V)/20=0.08255V


1774293713079.png

That maximum voltage is achieved by the current flows through 2 of 0.0005 Ohm resistors connected in parallel

1774295075898.png

The total resistance of that circuit is 0.0005 Ohm / 2 = 0.00025 Ohm

Therefore the maximum current is 0.08255V / 0.00025 Ohm = 330 A

So the current sense circuits limit us to 330A

Another hardware limit is the MOSFETs. We got IAUA180N10S5N029AUMA1 MOSFETs. That MOSFET can withstand 180A

1774295842508.png

We got 2 MOSFEts connected parallel so the total current this circuit can withstand is 180A x 2 =360A

1774295898441.png

The overheating of the MOSFETs and the motor windings are monitored by the thermistors. The M620 motor battery power leads are thicker than the M600 motor battery power leads and are certainly can go up to 100A continuous no problem.

So we have a perfectly balanced system can go safely up to 300A. And we want to set it just to 100A, but it looks like the Luna firmware does not allow us to do so.
 
Last edited:
It looks like Krasnodar did some kind of magic here and was able to squeeze more power out of the VESC firmware with lower current and wattage settings. How is it possible?
 
OK, I jut tested it with 3500W wattage set through the VESC Tool application and the top speed is still the same. It feels like it pops wheelies easier, but maybe this is an illusion and it is still quite rapidly reduces support torque at higher cadence.

I also changed the wattage to 4500W and I felt no any difference with 3500W.

The motor current is set to 100A, the absolute maximum motor current is set to 200A and the VESC Tool application does not allow me to set those parameters higher just like the battery current.

I also noticed on the VESC Tool gauge when I press the pedals hard the wattage raised briefly up to around 2500W at low cadence and then quite rapidly drops to 1500-1700W when cadence raises and fluctuate at that level when I press the pedals as hard as I can.

So it looks like we need to dig into the VESC Luna firmware yet again. Anyone knows by any chance where those limits in the source code are?
 
Last edited:
image-66-1024x430.png
 
We've got the Power!

1774391993105.png

Now we can set more current and power! At 160A motor current max, 300A absolute maximum current, 80A battery current and 4160W wattage it has similar to Innotrace X1 3000W behavior. It actually pulls harder than Innotrace X1 3000W at low cadence and pulls not that hard at higher cadence, but the top speed now is about the same as Innotrace X1, just at different gears.

I use it with 14S battery but I would recommend you to use higher voltage battery (the Luna firmware limits it up to 20S 74V which should be plenty) to have more torque support whiting wider cadence range.

There are few quirks though. It looks like Luna set the the motor stator thermistor wrong (the reading is off and it feels like the motor heats up too fast according to the motor temperature gauge reading in the VESC Tool. It goes like 90 C pretty fast withing a few minutes of hard ride, but the motor case is barely warm). The luna_m600_Rev5 6.05 firmware also does not allow the cadence/torque sensor to work without connected throttle. And the current and power settings can be adjusted only through the standard VESC Tool interface, the Luna user interface still does not allow to set the battery current more than 60A (I guess it is coded somewhere else).

Regarding the motor stator temperature sensor I took my old measurements I did with the Bafang M620 and M600 (they have the same PTC thermistor) and put them into a temperature sensor calculator and it looks like Bafang uses linear PTC thermistor, while in the Luna firmware they specified PTC 1K at 100C (I guess that means 100C PTC current limiting thermistor) which acts different and not even used for accurate temperature measuring.

1774411070516.png

1774411109821.png

1774411243404.png

So I set custom PTC motor thermistor in the VESC Tool and test rode it and now the motor temperate looks more realistic.

1774411948572.png


I also tested and compared those settings on the VESC M600 controller I got laying around which has the same temperature measuring circuit. I put it in the warm oven, soaked it for some time in the hot air and checked the temperature reading on the gauges in the VESC Tool application

1774413871009.png

This is an example what was before at room temperature (the PCB and the stator temperatures are different, stator is hotter than the room temperature according to the VESC Tool)

1774412219583.png


And now with custom PTC settings the temperatures readings match each other at all temperature range when they match each other in reality

1774412560524.png

And even match the actual temperature

1774412689577.png

Regarding the not functional cadence/torque sensor without connected throttle I just hooked a throttle and now the pedal assist works. I did not plan to use that throttle so I just taped it on temporary.

1774413136963.png

I believe there is an update on github Marcos did regarding that throttle related issue, we need to investigate what is going on here and how to use that update. The original Luna firmware I dumped from the Luna M600 Ludicrous V2 controller does not have this issue while that firmware is older than that update. I used the final release 6_05 of the Luna firmware to build the binary file, I guess we need a newer one.

1774413599978.png



We also might need to figure out how to make the Luna user interface allows to set the battery current higher than 60A, but we can set higher currents and wattage through the standard VESC Tool interface no problem.

The motor controller also can swallow more power. After long ride at full power with some uphills the motor stator was about 80C while the controller was 28C. So the motor is the bottleneck here. The good thing is the controller can use up to 100V so there is a lot of room to make more power with the same thermal performance.
 
Last edited:
I have not found complete working instructions about how to change and build the VESC firmware, there is a couple helpful videos on YouTube, but those do not work if you follow them to the tee. If you want to experiment with the VESC firmware, settings and algorithms here is how you make it:

1) Download the STM32CubeIDE 1.0.8 (you can register an account on their website to download it or you can download it as a guest filling a form on their website)


1774477105153.png

2) Unzip the archive with the STM32CubeIDE 1.0.8 and install it with default settings it offers

3) Download GNU arm embedded toolchain 7-2018-q2-update June 27, 2018


1774478049736.png


4) Install GNU arm embedded toolchain 7-2018-q2-update. Before clicking the "Finish" button check the box "Add path to environment variable". Close the windows popped after the installation.

1774478310104.png

5) Go to the VESC firmware web page


6) Select the version of the firmware you want to download clicking on the button with the branch icon (master (default) is the current work in progress firmware and it can have issues, release_6_06 is current stable version of the firmware, release_6_05 is previous stable version of the firmware and so on). Select the one you need.

1774478611287.png


7) Download the achieve with the selected firmware source code files clicking the green "Code" button and clicking "Download ZIP"

1774478977937.png

8) Unzip the downloaded firmware source files. I recommend to unzip it directly on disk C to avoid possible issues with too many subfolders. Here is an example of the unzipped VESC firmware source files.

1774479173120.png

9) Launch the STN32CubeIDE you installed earlier and click "Launch" button on the popped window

1774479345365.png

10) Since you did not define the firmware folder yet click File --> New --> Makefile Project with Existing Code

1774479600998.png

11) Select MCU ARM GCC on the popped window

1774479697338.png

12) Click the "Browse" button against the Existing Code Location field and select the VESC firmware folder with the source code files you downloaded and unzipped before and click the "Select Folder" button

1774479885592.png

13) Click the "Finish" button

1774479933973.png

14) Click the main source code folder (in this example it is bldc-release_6_06) in the Project Explorer with right mouse button and select Properties



1774480040362.png

15) In the opened menu select C/C++Build --> Behavior. Print luna_m600_Rev5 in the "Build (Incremental build)" field and click the "Apply" button

1774480488043.png

16) Under the "C/C++Build" menu click on the "Environment" menu and double click on the "PATH" option. Copy the whole text from the Value field in the opened window to a text editor (click in the field then press Ctrl+A --> Ctrl+C, then click in a text editor and press Ctrl+V)

1774480798574.png

It should look like this

1774480977749.png

17) Select the the text from the beginning and up to first ";" sigh and delete it (do not delete the ";" sign)

1774481274035.png

So it looks like this

1774481310214.png

19) Copy the path to the bin folder of the Download GNU arm embedded toolchain 7-2018-q2-update you installed earlier. In my case it is C:\Program Files (x86)\GNU Tools Arm Embedded\7 2018-q2-update\bin

1774481532174.png

20) Paste the the path to the bin folder of the Download GNU arm embedded toolchain 7-2018-q2-update to the text editor at the beginning of the copied text before the ";" sign

1774481650429.png

21) Copy the whole text from the text editor (in the text editor window press Ctrl+A --> Ctrl+C) and paste the text into the Value field of the window you opened in the step 16 instead of the existing text (click in the Value field and then press Ctrl+A --> Ctrl+V). Click the button "OK" and then click the "Apply and Close" button. Now you can close the text editor, you do not need it anymore.

1774482017260.png

Now you finished setting up the STM32CubeIDE and do not need to do this anymore and can work with the code in the VESC firmware files.

See the further instructions in the next post
 
Last edited:
Here is an example how you can change the current limits, in this case for the luna_m600_Rev5 firmware we use for our INNOTRACE M620 CAN motor controller:

1) In the STM32CubeIDE locate the code file you want to change in the Project Explorer in the left side. In our case it is the file "hw_luna_m600.h" located in the folder "bldc-release_6_06 --> hwconf --> luna --> m600". Double click on that "hw_luna_m600.h" file to open it in the editing area in the center of the of the STM32CubeIDE application window. Scroll thru the text (code) to the place you are interested in (in our case these are lines 339 - 341 )

1774482927130.png

2) Change the code how you want following the C syntax rules. In our case we want to make the motor (phase) current 200A, the battery current 100A and the motor (phase) current absolute limit 300A, here is how it looks like after editing:

1774483266570.png

3) Click the "Save" button to save changes of the "hw_luna_m600.h" file

1774483513849.png

4) Once you are happy with all the changes and saved them you can build the firmware clicking the "Hammer" icon.

1774483683249.png

5) If everything is OK after building the firmware you can go to the firmware folder (in our case it is "C:\bldc-release_6_06\build\luna_m600_Rev5") and find your firmware binary file there (in our case it is "luna_m600_Rev5.bin" file)

1774483851193.png

6) Now you can flash this file on your motor controller however you want (if you already have installed and working firmware on your controller you can update it using the VESC Tool with Bluetooth)

7) Then connect VESC Tool application and set PTC custom motor temperature sensor like here

1774486354904.png

8) Do the motor detection process explained here (keep it in Sensored mode though)


9) Do the rotary encoder calibration trough the VESC Tool application

10) Adjust the current and power limits through the VESC Tool application

Now you can test if it works.
 
Last edited:
Built firmware number 6_06 and the cadence torque sensor is still disabled when the throttle is not connected. The firmware date is 2024.06.26 which looks like it was before they implemented the fix. I guess we need to use the main not stable firmware

1774496236656.png

The new firmware also does not work correct with old VESC Tool 6_05 and requires new VESC Tool 6_06 to work properly.

But it looks like that 6_06 firmware has some improvements over 6_05. I noticed the walk mode starts perfectly smooth now while in 6_05 it has a little jerky start. I did not test rode it yet, but maybe there are more differences.

By the way, there is a glitch I found in the new VESC Tool 6_06 I did not experience in VESC Tool 6_05 - when I start it it expands beyond the Windows Tool Bar and covers the bottom of the application so I can not see the information there. In order to resolve it I have to reduce the size of the application window and then expand it full screen again. It does this each time I launch it. Maybe the VESC team guys want to fix it.

1774496796064.png

While in not full screen mode I also can not shrink the application window less than my screen height. The minimal width is quite limited too.

1774497175476.png
 
Last edited:
Unfortunately the bldc-master firmware does not work with the VESC Tool 6_06 application (you can not change the settings). I guess we are going to use what we got, you need the throttle to be connected to the harness.

1774574598846.png
 
We did it! We managed to implement the latest Luna updates in the 6_06 firmware Marcos implemented in the master firmware on September last year and now the controller works with the VESC Tool 6_06 application and the cadence/torque sensor can work without connected throttle!

1774588834916.png

There is a weird quirk though might happen (and I did not experience it with the stable 6_06 2024.06.26 firmware) when you connect the controller to the PC version of the VESC Tool 6_06 application, after you click the "load UI" button the VESC Tool 6_06 application can crash, but starting and connecting the VESC Tool 6_06 application over again usually works OK.

If you want to change the current and the power settings use the standard VESC Tool interface instead of the Luna user interface (Luna user interface limits the current and power).

The archive with the new firmware can be downloaded here


The latest firmware file is "M620 CAN #4 (2026-03-26).bin" located in the "M620 CAN VESC controller_BRAIN\Firmware" folder. After flashing the firmware you have to connect the controller to the VESC Tool 6_06 application, apply the motor configuration file "M620 CAN #4 (2026-03-26) motor config.xml" and run rotary encoder calibration for proper motor work and to stop the errors messages popping on the display screen.

More details about the firmware can be found in the "Readme.txt" file in the "M620 CAN VESC controller_BRAIN\Firmware" folder.

The file "bldc-release_6_06 (2026-03-26).zip" is the archive with the files with the source code with the latest Luna updates released after the 6_06 stable firmware release and lifted current limits can be found in the "M620 CAN VESC controller_BRAIN\Firmware" folder.
 
Last edited:
Back
Top