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

Marctwo said:
So is there anyway I can actually work out the correct value for calA?
Just take an amp-meter and measure the drawn current under load, then calculate back the Cal_a value. Perhaps at different loads to get an averaged value.

regards
stancecoke
 
I received today a 9FET controller and an LCD-8S, I will use this firmware and plan to make the following changes:
  • Add support for the LCD8, and ideally use more of its settings to set up the controller. It will still need the Android app for the first setup but some parameters will allow to change the max current, regen level and things like that.
  • Ideally, allow to use the LCD and Android app without reflashing. I will try to detect the protocol at startup then use the correct.
  • Add a virtual freewheel: inject a small current (about 0.5A) if no throttle or PAS, useful for direct drive motors (same as phaserunner)
  • Add a temperature sensor input and at least send it to the display, then use it to limit the power. Although not shown in the schematic, the pin 15 is available through a 2.2k series resistor on the pad noted X4. Can someone with other controllers confirm this is also the case ?

A new firmware for the LCD with the same protocol as the Android app is also a possibility, it should be easy with Casainho's code but that will be for later.
 
romelec said:
I received today a 9FET controller and an LCD-8S

Hm, with this 9 FETs we had only trouble so far. I don't know if someone got it working finally. Please report your experience!

The temperature measurement is already implemented and there are different hardware versions, some with pullup at X4, some without.

Is the protocol of the LCD8 really different from the other Kunteng Displays? The Kunteng protocol is completely implemented but not used for setting parameters except wheel size and speed limit.

I don't understand, why you want to use BlueOsec for the basic setup?! All parameters can be set in the javatool directly!

I'm looking forward to see your improvements!

regards
stancecoke
 
stancecoke said:
Hm, with this 9 FETs we had only trouble so far. I don't know if someone got it working finally. Please report your experience!
Hum, I don't think I saw this information in this thread, I guess I will read from the beginning !
stancecoke said:
The temperature measurement is already implemented and there are different hardware versions, some with pullup at X4, some without.
There is nothing in the master branch but I saw your message about Xnyle removing that feature, not sure why he did it but I will be able to reuse that code.
stancecoke said:
Is the protocol of the LCD8 really different from the other Kunteng Displays? The Kunteng protocol is completely implemented but not used for setting parameters except wheel size and speed limit.
There are new parameters, L1 to L4, I think the protocol will be a little bit different (didn't check yet) or at least the CRC
stancecoke said:
I don't understand, why you want to use BlueOsec for the basic setup?! All parameters can be set in the javatool directly!
Well I misread All "grey" parameters can be changed via the BluOSEC Android App at runtime. to the fact that it was mandatory to use the app to set them :oops:
 
bj97301 said:
stancecoke said:
AndZab said:
If you can point me to the Bafang serial protocol specs, I can think about it.

For my Lishui-Project, I took the code from the "Forumscontroller", see the display_bafang.cpp and the display_bafang.h

The Bafangs work with 1200 BAUD, you have to change this in the UART init function.

bj97301 said:
wondering if I should use this firmware or the tsdz one because this one is no longer maintained
This project is alive, only casainhos fork is inactive. See my signature!

regards
stancecoke

Very good. Thank you. I’ll see if I can update some docs to better indicate this on your repo.

Thank you so much stancecoke ! :thumb:
 
First of all, a big thank you to casainho, stancecoke and all the other contributors of this awesome firmware, I first saw this project a year ago and it inspired to build myself an ebike to commute.

So I got myself an S06S (6FET) controller together with the Q100C motor from BMSbattery and started building my 36V system.It was intended to run with the Bluetooth app wich hasn’t arrived yet, so I shorted the according wires on the display cable to start up the controller.
I tested all parts (motor with throttle and pas) with the original firmware on the controller which worked. So knowing the motor and controller worked together I went on flashing successfully (not using the outdated config as the hall sensor parameters (false/true) seem to no longer be implemented in the current version), but the motor doesn’t seem to turn at all apart from occasional 1-2cm depending on the angle, drawing current doing so.
What does apparently work is regenerative breaking (only backwards that is), as turning the motor does induce a resistance depending on how fast it’s spinningChanging to any configuration of hall sensor cabling or phase cabling or even with no hall sensor at all doesn’t get the motor running. I tried flashing configs from the proven settings tab but without success.

Am I missing something here, as so many people have got it working and I now have no clue on what could be wrong?
 
eLsc said:
but the motor doesn’t seem to turn at all apart from occasional 1-2cm depending on the angle, drawing current doing so

Without seeing your setting, it's difficult. Often, a wrong motor specific angle or a wrong HallSensor-/Phase combination cause your problem.

regards
stancecoke
 
Thanks for replying,
these are my 'current' settings, but I tried the proven Q128 and the outdated Q100 settings with the angels from various motors/posts on the forum.
Thanks again for helping me out,
eLsc
 

Attachments

  • 20200623-131232MESZ.ini
    241 bytes · Views: 49
Could someone point me in the right direction for a 5000 watt controller that will work with the open source? I'm trying to do a trials bike build and want full control over the motor and code to get the throttle response I want (fast and precise)

I'm planning to use the cyclone 3000 for the build, and maybe upgrade to a cyc x1 later if it works

Would this one work?
https://www.elecycles.com/bomber-electric-bike-controller-3000w-5000w-electric-bicycle-controller.html
 
Hello. Can the "wheelsize" value in the KT LCD protocol be calculated (does it mean something)? Or just decrypt according to the table?whell_size.png
 
AlexDaniel said:
Hello! I hope this is not too off-topic. Earlier in this thread there was a mention of a similar KZQW22A controller, which I also have. The most annoying thing about that controller is that there is a hard power cutoff after 25km/h which makes the riding experience horrible. That is, there's no PID or anything like that to keep the speed at 25km/h, it just stops assisting altogether once you reach the speed. Thanks to the help from Aleksandr Boldin we managed to reverse-engineer the firmware and remove the speed limit (in my country there's no speed limit for 250W bikes anyway). The bicycle didn't get significantly faster (it can only reach around 30km/h without the software limit), but the riding experience is much better now. I've been using it for a few months without any issues. :p

I'm attaching the modified firmware which you can flash if you have the same controller with the same firmware. Original firmware is also attached.

Here are some helpful notes:

Programming connector:
Code:
black – GND
yellow – SWIM
blue – Reset
red – maybe VCC, you don't need it

To read data from the microcontroller (assuming you use stlink v2):
Code:
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s flash  -r KZQW22A-flash.bin
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s eeprom -r KZQW22A-eeprom.bin
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s opt    -r KZQW22A-opt.bin

To write the firmware:
Code:
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s flash -w KZQW22A-flash-hacked-double-speed-limit.bin

Good luck!

Thank for your contribution to flash the controller.
my model unfortunately has no wires for the programming connector. it seems to be a different model. i might remove the jelly to connect the 4 wires by hand. can you helf me to identify the correct code settings?
 

Attachments

  • Screenshot_20200709-113028_WhatsApp.jpg
    Screenshot_20200709-113028_WhatsApp.jpg
    84 KB · Views: 2,440
  • IMG-20200709-WA0004.jpg
    IMG-20200709-WA0004.jpg
    89.3 KB · Views: 2,440
Anders KA said:
AlexDaniel said:
Hello! I hope this is not too off-topic. Earlier in this thread there was a mention of a similar KZQW22A controller, which I also have. The most annoying thing about that controller is that there is a hard power cutoff after 25km/h which makes the riding experience horrible. That is, there's no PID or anything like that to keep the speed at 25km/h, it just stops assisting altogether once you reach the speed. Thanks to the help from Aleksandr Boldin we managed to reverse-engineer the firmware and remove the speed limit (in my country there's no speed limit for 250W bikes anyway). The bicycle didn't get significantly faster (it can only reach around 30km/h without the software limit), but the riding experience is much better now. I've been using it for a few months without any issues. :p

I'm attaching the modified firmware which you can flash if you have the same controller with the same firmware. Original firmware is also attached.

Here are some helpful notes:

Programming connector:
Code:
black – GND
yellow – SWIM
blue – Reset
red – maybe VCC, you don't need it

To read data from the microcontroller (assuming you use stlink v2):
Code:
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s flash  -r KZQW22A-flash.bin
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s eeprom -r KZQW22A-eeprom.bin
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s opt    -r KZQW22A-opt.bin

To write the firmware:
Code:
./stm8flash -c stlinkv2 -p stm8s105s4t6c -s flash -w KZQW22A-flash-hacked-double-speed-limit.bin

Good luck!

Thank for your contribution to flash the controller.
my model unfortunately has no wires for the programming connector. it seems to be a different model. i might remove the jelly to connect the 4 wires by hand. can you helf me to identify the correct code settings?


I'm afraid you won't be able to do much about your controller. There was another user with "MIFA" version of that controlled who I had a lovely conversation with. Basically, you can remove the jelly and solder a connector, but it's very likely you won't be able to read the firmware. At least in the one the other user had, the firmware readout protection was enabled. That said, you can still flash a new firmware. In fact, that user tried to flash one of the firmware dumps I provided, but it ended up not being able to communicate with the display, essentially bricking the controller.

I'll send them a message, maybe they will be able to share more information with us. :)
 
AlexDaniel said:
In fact, that user tried to flash one of the firmware dumps I provided, but it ended up not being able to communicate with the display, essentially bricking the controller.

A german dealer offers the re-programming of this kind of controllers, so it could be possible to bring the controller back to life...
https://www.groetech.de/index.php?main_page=product_info&cPath=16&products_id=937

tongsheng-tool-1.jpg


regards
stancecoke
 
I'm afraid you won't be able to do much about your controller. There was another user with "MIFA" version of that controlled who I had a lovely conversation with. Basically, you can remove the jelly and solder a connector, but it's very likely you won't be able to read the firmware. At least in the one the other user had, the firmware readout protection was enabled. That said, you can still flash a new firmware. In fact, that user tried to flash one of the firmware dumps I provided, but it ended up not being able to communicate with the display, essentially bricking the controller.

I'll send them a message, maybe they will be able to share more information with us. :)

OK , there is poor chance to be successful.
The Controller works fine with the original front hub motor. I don't want to brick it.
I just ordered an KT Controller and join the world of freedom... :wink:
 
stancecoke said:
AlexDaniel said:
In fact, that user tried to flash one of the firmware dumps I provided, but it ended up not being able to communicate with the display, essentially bricking the controller.

A german dealer offers the re-programming of this kind of controllers, so it could be possible to bring the controller back to life...
https://www.groetech.de/index.php?main_page=product_info&cPath=16&products_id=937

tongsheng-tool-1.jpg


regards
stancecoke
I checked the offer by groetech.
the controller should be from 2013 or later. mine is too old.
the reprogramming is done once by groetech. controller has to be shipped to them.
no software is to be purchased!
 
Hi. I'm the guy which tried to flash KZQW22A-MIFA/PR with mentioned soft.

So...MIFA is protecting their ST chips with a ROP byte, beside there is no simple rule that mentioned hacked soft will work with every kind of KZQW22A model. They differ in communication protocol (with panel) and used kind of sensors depend of e-bike manufacturer and e-bike model. Soft posted by AlexDaniel of corse is OK by only for GZR e-bikes because for those was originally designed. In my opinion (based on eperience) - it has no sense trying to flash KZQW22A controllers made by MIFA with mentioned soft.

In their case it is far way better to choose other universal, sensorless and unlocked controller with similar small size.

Here is example of controller which can be used in a place of original MIFA KZQW22A (small, even stronger-350W, cheap, unlocked, with S866 LCD panel, has lot of settings, can work both as sensor and sensorless, can use speed throttle, lamp etc):
https://a.aliexpress.com/_B1ySQA
https://www.youtube.com/watch?v=vAj4BvREvUs

Surely this model can fit into MIFA original casing (like batter case) without any case modification.
 
But.....if someone want to try anyway (on it's own risk!), I give a scheme of pins which shall be connected to the same pins of STLINK V2 programmer and a way how to clear a ROP byte (please note that clearing ROP byte initiates global memory erase and irretrievable loss of original soft !):

echo "00" | xxd -r -p >ROP_CLEAR.bin
stm8flash -c stlinkv2 -p stm8s105?4 -s opt -w ROP_CLEAR.bin


There are also some "cheats" to bypass ST chip ROP protection and acquire original soft, but it require
the knowledge, oscilloscope and it's not always succesful:
https://itooktheredpill.irgendwo.org/2020/stm8-readout-protection/
 

Attachments

  • KZQW22A flash pins.jpg
    KZQW22A flash pins.jpg
    153.3 KB · Views: 3,729
stancecoke said:
AlexDaniel said:
In fact, that user tried to flash one of the firmware dumps I provided, but it ended up not being able to communicate with the display, essentially bricking the controller.

A german dealer offers the re-programming of this kind of controllers, so it could be possible to bring the controller back to life...
https://www.groetech.de/index.php?main_page=product_info&cPath=16&products_id=937

tongsheng-tool-1.jpg


regards
stancecoke


Hi, how i need to configure firmware when i change acs712 30a on acs758 50a
Thanks
 
Slipy said:
how i need to configure firmware when i change acs712 30a on acs758 50a
You have to change nothing. With the phase current sensor we only detect the zero-crossing for the advance angle correction. So the absolute value of the signal is irrelevant. The signal has to be 2,5V at 0 amps.

regards
stancecoke
 
After 2 unsuccessful attempts, I finally managed to get a 9c RH212 motor running on a 12FET KTs controller with the open source firmware. Unfortunately, it's still super buggy, and I could use some help configuring it correctly. Setup is pas+throttle and kt lcd3 display.
What works:
- compiling / flashing the OS firmware
- motor / controller powers on
- hall / phase in the correct order
- pas starts the motor
- throttle starts the motor
- some sort of regen, although its behaviour is super strange
What does not work:
- max power seems to be limited to 500W although I pur 35A as upper limit (on 52V). This motor can take 2000W, and I need all of it to haul the trailer.
- PAS levels 1-4 are useless, only 5 seems to work, and still no very strong.
- throttle configuration: can't find the correct values for my standart thumb throttle. either it's always on, or it gets so sensitive I can't really push through it
- light function on the kt lcd3 display. (hold arrow up for 1-3s). Worked fine on stock firmware - now it seems to be broken
- temperature display on the lcd3. I soldered a temp sensor to x4 but can't figure out where/how to enable it.

Attached, my current config. Any help / suggestions would be greatly appreciated.
config.jpg

EDIT: batt current max is 400, not 40. Seems to be a jre/screenshot glitch
 
Hi everyone,

I'm looking to flash the custom firmware on my KT controller which came with my electric scooter (Glion Dolly). However, I have a non-standard controller which is impossible to find anywhere else. From the several pages I've read on the forum, I'm guessing that I'll be able to flash the firmware into the controller using the solder contacts marked "SOF".

There are a few things I want to know:

First, does it have a phase current sensor?

Second, this controller is sensorless controller. Would it be possible to wire in hall sensors, either by hooking it up to the sensor emulator board or by removing the board and soldering the wires where it was? Also, would I have to add any small resistors/capacitors to the hall sensor to get it to work?

Third, could I wire a display connector up to the controller?

Thanks!

yIYfZvw.jpg

40QkqAO.jpg

85yUd9z.jpg

ywDwFXQ.jpg
 
RE: "However, I have a non-standard controller which is impossible to find anywhere else"

It has standard 48pin STM8S105C6 controller. If it's not ROP protected you can try to dump it's memory content by STLINK V2 programmer. The pinout scheme you can find in attachment
 

Attachments

  • pinout.jpg
    pinout.jpg
    54 KB · Views: 3,407
  • stm8s105c6.pdf
    1.9 MB · Views: 111
RE: Third, could I wire a display connector up to the controller?

Pins 46 and 47 are TX and RX used for communication with the display, so yes - if the controller has programmed display operation.

You can try to study activity on those pins by USB/RS232 cable or oscilloscope. If display operation is set then you shall get some activity.
 
Hey guys, I'm about to buy one of these bike kits, it doesn't have a display wire at all so I'm not sure if it'd be compatible with this firmware since I see you need to solder stuff to it to get it to work with the app over bluetooth (I have spare modules laying around).. Is there any way to add a display connector for bluetooth? What controller do you think this might come with? Thanks a bunch, still new to all of this.

https://www.ebay.com/itm/26-1500W-Rear-Wheel-48V-Electric-Bicycle-Bike-Motor-Conversion-Kit-Hub-Cycling/322269304808
 
Back
Top