KT motor controllers -- Flexible OpenSource firmware for BMSBattery S/Kunteng KT motor controllers (0.25kW up to 5kW)

Looks like its not unlocking. No communication for some reason
 

Attachments

  • 1736701794829.png
    1736701794829.png
    28.9 KB · Views: 8
Is anyone using BluoOsec with modern android versions? Im not getting any connection.
Bluetooth terminal in diagnostics mode works fine but not the app.
 
Is anyone using BluoOsec with modern android versions? Im not getting any connection.
Bluetooth terminal in diagnostics mode works fine but not the app.
Try giving the app all permission in the settings/app/permissions screen if possible. If it can still work, it might not ask for the correct permissions, which changed I think during android 13. It would be better to recompile the app with later SDK support and fix the permissions properly if you have the source code.

Looks like its not unlocking. No communication for some reason
How long is your cable? Swim does not like bad contacts and long cables.
 
Try giving the app all permission in the settings/app/permissions screen if possible. If it can still work, it might not ask for the correct permissions, which changed I think during android 13. It would be better to recompile the app with later SDK support and fix the permissions properly if you have the source code.


How long is your cable? Swim does not like bad contacts and long cables.
Crappy st-link was causing issues with unlocking. Unfortunately app source code is unavailable.
Im using your fork btw

 
Im using your fork btw
A few people are so I've heard. Should give you some leeway to do some more communication/calculations if need be. I'm not maintaining it anymore since it works (mostly) for me and I'm switching to a stm32 controller, so caveat emptor applies. If you find any errors let me know if you made a pull request, I'm not actively checking github atm.


Crappy st-link was causing issues with unlocking
Been there, I had issues with a custom cable which was too long for the crappy stlink clone I had, cut cable in half and it worked half of the time which is better than never.
 
A few people are so I've heard. Should give you some leeway to do some more communication/calculations if need be. I'm not maintaining it anymore since it works (mostly) for me and I'm switching to a stm32 controller, so caveat emptor applies. If you find any errors let me know if you made a pull request, I'm not actively checking github atm.



Been there, I had issues with a custom cable which was too long for the crappy stlink clone I had, cut cable in half and it worked half of the time which is better than never.
I wish i had enough skill to add my own features. Is there any way to disable interpolation on your fork?
 
Just me or is the standard KT firmware kinda shit? The throttle response is sluggish, and setting C4 to 3 in the settings doesn't do anything, it's supposed to do this: Before power assist, the throttle speed limit is 6KM/h, after power assist, throttle is full speed. Stop power assist, return the throttle speed limit is 6KM/H.

But the throttle just always works, which makes my bike illegal in the EU... I guess what I'm saying is, time for me to start soldering/compiling!
 
Just me or is the standard KT firmware kinda shit? The throttle response is sluggish, and setting C4 to 3 in the settings doesn't do anything, it's supposed to do this: Before power assist, the throttle speed limit is 6KM/h, after power assist, throttle is full speed. Stop power assist, return the throttle speed limit is 6KM/H.

But the throttle just always works, which makes my bike illegal in the EU... I guess what I'm saying is, time for me to start soldering/compiling!
Not all settings are available for all devices. Mine responded to settings not in the manual. If you have a old batch/version some things might not work. It's hit or miss.
 
Things are working!! A week ago I bricked my first kunteng controller because a metal clamp on the FETs caused a short somewhere when I unscrewed it without taking the top of the controller off first or apparently letting the capacitors discharge enough.

The instructions said to 'gently lift' the top panel of the enclosure, that didn't work so I thought the body of my controller didn't have a separate top and was just one solid piece. Turns out it did have a separate top piece, but I needed to pry it off.

With my second controller things went a lot better - I finally have a legal ebike, by setting 'without PAS' to 5 km/h and the limit to 25, which wasn't possible (even just the speed limit) with multiple controllers from aliexpress.

Now for what's not working - 'Battery current cal a' doesn't seem to do much, whether I set it to 100 or 200, the max battery current is around ~3.5a when battery current is set to max 30. Phase current is set to 140.

I hope I don't blow anything this way, is there a way to fix/diagnose this?20250304_201923.jpg
 
Things are working!! A week ago I bricked my first kunteng controller because a metal clamp on the FETs caused a short somewhere when I unscrewed it without taking the top of the controller off first or apparently letting the capacitors discharge enough.

The instructions said to 'gently lift' the top panel of the enclosure, that didn't work so I thought the body of my controller didn't have a separate top and was just one solid piece. Turns out it did have a separate top piece, but I needed to pry it off.

With my second controller things went a lot better - I finally have a legal ebike, by setting 'without PAS' to 5 km/h and the limit to 25, which wasn't possible (even just the speed limit) with multiple controllers from aliexpress.

Now for what's not working - 'Battery current cal a' doesn't seem to do much, whether I set it to 100 or 200, the max battery current is around ~3.5a when battery current is set to max 30. Phase current is set to 140.

I hope I don't blow anything this way, is there a way to fix/diagnose this?View attachment 366684
It's a while since I played with this fw but from memory I don't think that 'bat current cal a' has any function in the code these days. Also, I'm pretty sure that 'bat current max' and 'phase current max' settings don't relate directly to amps, mine are set to 150 and 500 for these settings which seems to give a max current current of around 20amps.
As stated all from (fading) memory, but probably worth playing around with those numbers...:)
 
It's a while since I played with this fw but from memory I don't think that 'bat current cal a' has any function in the code these days. Also, I'm pretty sure that 'bat current max' and 'phase current max' settings don't relate directly to amps, mine are set to 150 and 500 for these settings which seems to give a max current current of around 20amps.
As stated all from (fading) memory, but probably worth playing around with those numbers...:)
Ok, that makes sense, I can still lower the battery/phase amperages by inputting lower current numbers to account for the measurements being out of calibration.
 
@stancecoke Im trying to catch up on the code, could you tell me something about those two commits:

e9dd587 Pushed Andreas changes from zip at ES
That just seems to merge back the same as in
d430d8d Changed to integer arithemtics and right shift
into yet another branch?

And in both cases the new calculation uses SPEED_INFLUENCES_TORQUESENSOR?
 
Hi @Xnyle,

nice to see, that you are active again, I saw your comments on the GitHub issue also.
I don't use Kuntengs any more, the last commits were just a service for guys, who are not familiar with GitHub. I didn't check them technically.

I would be happy, if you could maintain the Kunteng project on your GitHub account, or push it back to the OpenSourceEBike Organization, that @casainho opened several years ago.
You would have to ask @casainho, to invite you to this organization.

1743365243363.png

 
Last edited:
Hey guys,

I have a 2 almost identical builds for mostly cross country based on bafang g040 motor + KT controller (48v 22a 9 mosfets for Polly 5C case), throttle, 10 magnets PAS with Shimano bottom bracket, KT LCD 5 and 11 displays, without brake sensors. I didn't touch the firmware yet, but did minimal improvements into controllers (replaced some mosfets + changed resistor before LM317T to 360 ohm to step down voltage to 20v instead of 15v). I like minimalistic concept of Polly cases with "build in" controllers. For the last time I was looking on torque sensor configuration. I looked on erider t9 and t17. As I understood I don't need to step down power for t17 comparing to t9, so I will choose t17 most probably. Also I was checking between VESC and KT. I know that VESC is better, but I want to keep my controller in the bottom rail of the battery case and I don't want to do a lot of customizations again.

And I have a few questions regarding this firmware. Sorry if I am asking too stupid questions.

1. Is it possible to revert firmware back to stock one? just in case
2. Is it possible to use throttle together with torque sensor? Should I use diodes in this case for the throttle signal?
3. Will it work with my displays? Most probably that yes, but just to double check
 
Last edited:
Hey guys,

I have a 2 almost identical builds for mostly cross country based on bafang g040 motor + KT controller (48v 22a 9 mosfets for Polly 5C case), throttle, 10 magnets PAS with Shimano bottom bracket, KT LCD 5 and 11 displays, without brake sensors. I didn't touch the firmware yet, but did minimal improvements into controllers (replaced some mosfets + changed resistor before LM317T to 360 ohm to step down voltage to 20v instead of 15v). I like minimalistic concept of Polly cases with "build in" controllers. For the last time I was looking on torque sensor configuration. I looked on erider t9 and t17. As I understood I don't need to step down power for t17 comparing to t9, so I will choose t17 most probably. Also I was checking between VESC and KT. I know that VESC is better, but I want to keep my controller in the bottom rail of the battery case and I don't want to do a lot of customizations again.

And I have a few questions regarding this firmware. Sorry if I am asking too stupid questions.

1. Is it possible to revert firmware back to stock one? just in case
2. Is it possible to use throttle together with torque sensor? Should I use diodes in this case for the throttle signal?
3. Will it work with my displays? Most probably that yes, but just to double check
Although the os fw generally works well with the 6-fet and 12-fet controllers I think I remember there being some issues with the 9-fet - I'm not totally sure about this tbh. The answers to your questions are all somewhere in this thread, but hard to find I realise. So:-

1) No, Bafang normally read protect their fw, so you won't be able to download and restore it.

2) If your controller has an X4 connector you *may* be able to connect your torquesensor o/p to that and use the 'Torque_from_X4' branch with the throttle also. Problem here is that it seems that there are variations in X4 circuitry in some controllers that may prevent this from working, so it's a bit of a lottery. Suggest you search for X4 in this thread and have a good read.

3) Same view as yourself - that display seems to have identical functions to the lcd3 display so will probably work but don't know for sure.

......so to be honest it would seem a bit risky to attempt this, maybe worth buying another controller and using that as a test mule rather than potentially bricking your current controllers?
 
Although the os fw generally works well with the 6-fet and 12-fet controllers I think I remember there being some issues with the 9-fet - I'm not totally sure about this tbh. The answers to your questions are all somewhere in this thread, but hard to find I realise. So:-

1) No, Bafang normally read protect their fw, so you won't be able to download and restore it.

2) If your controller has an X4 connector you *may* be able to connect your torquesensor o/p to that and use the 'Torque_from_X4' branch with the throttle also. Problem here is that it seems that there are variations in X4 circuitry in some controllers that may prevent this from working, so it's a bit of a lottery. Suggest you search for X4 in this thread and have a good read.

3) Same view as yourself - that display seems to have identical functions to the lcd3 display so will probably work but don't know for sure.

......so to be honest it would seem a bit risky to attempt this, maybe worth buying another controller and using that as a test mule rather than potentially bricking your current controllers?

Thanks for the answer! I read previously about X4, will check if I have it on my Polly controller because they are a bit simplified comparing to regular in the box. Also for the tests I have a separate "external" controller which I used previously. This is how one of my builds looks like. I wanted to try something new and improve a bit controller's functionality if possible. But also don't want to ruin what has been already created and is working pretty fine.photo_2025-02-13_14-07-41 (3).jpg

photo_2025-02-13_14-07-41 (2).jpgphoto_2025-02-13_14-07-41.jpg
 
Nice bike, functional, no frills :cool:
 
Hi @Xnyle,

nice to see, that you are active again, I saw your comments on the GitHub issue also.
I don't use Kuntengs any more, the last commits were just a service for guys, who are not familiar with GitHub. I didn't check them technically.

I would be happy, if you could maintain the Kunteng project on your GitHub account, or push it back to the OpenSourceEBike Organization, that @casainho opened several years ago.
You would have to ask @casainho, to invite you to this organization.

View attachment 368076

Already figured out that branch is more or less dead and consp did a good job polishing the FW.
I'm currently working on my own branch but have to wait for another motor delivery so I can finalize my testing rig.
@casainho If you want me to push back the changes, just add me as co owner to the original repo.
 
Already figured out that branch is more or less dead and consp did a good job polishing the FW.
I'm currently working on my own branch but have to wait for another motor delivery so I can finalize my testing rig.
@casainho If you want me to push back the changes, just add me as co owner to the original repo.
@stancecoke @Xnyle it brings tears to my eyes to see the both of you back here! The og creaters of this amazing firmware + Bluetooth app!

I would like to convince you that this firmware is not dead and that it provides unique value to the ebike community that other controllers simply cannot offer. People keep coming back to try and further optimize the firmware. The combination of a small form factor of the controller, high power (15 kW+ from the 18 fets), low weight (1 kg), flexible firmware that is reasonably easy to read and edit, native PAS support, (simplified) FOC, flexibility in screen options (lcd3, 8, app or none) + still active community is simply unmatched by any other controller I have encountered so far.

There a still things to be polished and added in (preferably) a user interface (as far as I am up to date/aware):
- display motor temp in kt-lcd 3, with the same logic (10k thermistor) as in the bluosec app. An active customizable upper limit would be highly needed to protect our motors from the large phase currents that the 18 fets can produce.
- easily accessible and customizable field weakening that obeys a certain max in phase amps.
- easily accessible and customizable ramp up time to set duty cycle. I always change this manually in the firmware from 2s to 0.5s. This greatly increases responsiveness/aggressiveness of the throttle response and enables things like instant wheelies.
- optimization of the zero amp finding routine: i have recently started editing this, with double the wait states and 1/10 the zero amp threshold (from 2amp to 0.2amp i believe). This has greatly reduced the power loss at idle, now showing some 50watts at idle on the screen instead of the original 250watts (real losses from 3w to 0.3W or so; much less hot to the touch). Maybe this influences drag when coasting; i did not test that yet.
- implementing the motor constant as a settable value in the java script.
- checking the stability of recent updates to e.g. regen braking (i tried Andrea’s updates and instantly fried 2 controllers so i went back to the original stancecoke, xnyle and torque from x4 master branch, that has always worked flawlessly with powerful regen braking up to skidding the rear wheel). This checking is up to us as a community of course.
- cleaning up all tested modifications in a new master branch + optimally an updated java tool + bluosec (but that is wishful thinking;) )

Of course, we can keep editing the firmware directly by hand, but that would probably lead to chaos in the long run. So a skilled owner would be highly appreciated as this firmware is really a piece of art! And so are the controllers, simple and crappy as some may call them.

See some pictures below as a tribute to the work that you did on the firmware: a 35kg 15kW carbon mtb that has been running your amazing firmware on a modified 18fet kt controller (200batt amps, 300phase amps, oil filled and actively cooled) very reliably for years now. This performance in such a small form factor and for such a low price is still unmatched by all modern controllers in my opinion.

So let’s keep the kt firmware development alive!
 

Attachments

  • IMG_6361.png
    IMG_6361.png
    96.5 KB · Views: 7
  • IMG_3181.jpeg
    IMG_3181.jpeg
    3 MB · Views: 6
  • IMG_3174.jpeg
    IMG_3174.jpeg
    5.4 MB · Views: 6
  • IMG_3172.jpeg
    IMG_3172.jpeg
    2.8 MB · Views: 7
I also think this firmware is a long way from dead, I'm still regularly using it with my torquesensored rear hub bike, suspect many others are still enjoying it too.
With the aid of my coding pal ChatGPT (I'm not a coder), I've made a few minor changes to suit my personal setup/preferences and it all still runs very sweetly....:)
 
Already figured out that branch is more or less dead and consp did a good job polishing the FW.
I'm currently working on my own branch but have to wait for another motor delivery so I can finalize my testing rig.
@casainho If you want me to push back the changes, just add me as co owner to the original repo.
If you look into this firmware again @Xnyle , it would be great, if you could also get the option 'Power based control' to work.
Both the x4 branch and consp's version don't work when enabling that. (At least throttle does not work - as I only use throttle, I don't know if via PAS it would work)
Thanks again for all your work on this!
 
Back
Top