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

Electric Motors and Controllers
bj97301   10 µW

10 µW
Posts: 6
Joined: Mar 19 2020 9:09pm

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

Post by bj97301 » Jun 09 2020 11:51am

Pretty sure my controller is broke but does the controller need to be plugged in to the battery and turned on to flash it?

transposon   100 W

100 W
Posts: 109
Joined: Nov 24 2011 4:37pm
Location: Massachusetts

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

Post by transposon » Jun 10 2020 8:32am

I am having a lot of trouble with this firmware. I have the S12SNN 72V controller and a leaf hub motor. The motor ran fine with the controller stock. But now with the new firmware, nothing happens when I hit the throttle. Does anyone have any ideas? Thanks.
Attachments
controller pic cropped.png
controller pic cropped.png (105.21 KiB) Viewed 674 times

Lesny   1 mW

1 mW
Posts: 10
Joined: Jan 30 2020 8:09am

How to run the blueosec app

Post by Lesny » Jun 11 2020 12:52pm

Hi,
J have a problem with blueosec.
After connecting hc 05 to the controller , the application does not display anything. I tried swap rx with tx and it did nothing. Do you know what it might be?

Marctwo   1 µW

1 µW
Posts: 2
Joined: Jun 12 2020 1:02pm

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

Post by Marctwo » Jun 14 2020 5:29am

Hi all and thanks to everyone involved in this project.

I flashed my old bmsbattery s12s with the fw and I'm using it with a bbs02 at 36v. I'm also using an hc-05 with the bluosec app. After a bit of initial fiddling, everything seems to be working quite well.

Now that I'm fine tuning, I'd like to be more confident in the settings I'm using and 'calA' raises some doubts for me.
wiki wrote:Battery Current cal a: Factor a in the calibration function.
ADC value = calA * battery current + calB.
calB is measured automatically at starup.
Required for internal calculation of the current from the 10bit ADC value.
For a 6FET and 12FET controller the value has to be something around 100, for the 18FET about 50.
According to the wiki I should have calA at 'something around 100'... A little ambiguous.

So I tried to use the calibration function to work it out.
ADC value = calA * battery current + calB.
∴ calA * battery current = ADC value - calB
∴ calA = (ADC value - calB) / battery current

I'm assuming that the max ADC correlates to the max battery current and the battery current is in amps.
calB is measured on my setup as 315. So for a conservative 15A we get:
calA = (1023 - 315) / 15 = 47

47 is quite a long way from 100. Does this sound right?

Now I use calA to calculate the 'Battery Current max' value.
Battery Current max = ampere * calA / 10
Battery Current max = 15 * 47 / 10 = 71

I'll try these settings and see what happens but how much confidence should I have in them?

User avatar
stancecoke   100 kW

100 kW
Posts: 1221
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Jun 14 2020 7:54am

Marctwo wrote:
Jun 14 2020 5:29am
ADC value = calA * battery current + calB.
Edit: the wiki was right !

regards
stancecoke
Last edited by stancecoke on Jun 14 2020 11:21am, edited 1 time in total.

geofft   1 kW

1 kW
Posts: 356
Joined: Nov 09 2012 9:41am
Location: Berkshire UK

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

Post by geofft » Jun 14 2020 8:19am

Marctwo wrote:
Jun 14 2020 5:29am
Hi all and thanks to everyone involved in this project.

I flashed my old bmsbattery s12s with the fw and I'm using it with a bbs02 at 36v. I'm also using an hc-05 with the bluosec app. After a bit of initial fiddling, everything seems to be working quite well.
Interested to see you had success using the firmware with the BBS02, this is something I've thought about trying myself. I've got a BBS02 equipped bike sitting around not getting much use just now.

I'm presuming you're using an external Kunteng S12S controller hooked up to the BBS02 hall and motor phase connections? Was it just a case of getting the phases correct to match the Kunteng? I suspect it can't be quite that simple though... :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

transposon   100 W

100 W
Posts: 109
Joined: Nov 24 2011 4:37pm
Location: Massachusetts

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

Post by transposon » Jun 14 2020 11:21am

If no pas sensor is being used, how should we set the "PAS Timeout" parameter?

Marctwo   1 µW

1 µW
Posts: 2
Joined: Jun 12 2020 1:02pm

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

Post by Marctwo » Jun 14 2020 1:40pm

stancecoke wrote:
Jun 14 2020 7:54am
Marctwo wrote:
Jun 14 2020 5:29am
ADC value = calA * battery current + calB.
Edit: the wiki was right !
Hmm... ok, thanks.

I must have the wrong idea about this formula as the figures I worked out were pants and gave me very low power. So is there anyway I can actually work out the correct value for calA? Or should I just settle for what seems to work ok?
geofft wrote:
Jun 14 2020 8:19am
I'm presuming you're using an external Kunteng S12S controller hooked up to the BBS02 hall and motor phase connections?
Yes.
geofft wrote:
Jun 14 2020 8:19am
Was it just a case of getting the phases correct to match the Kunteng?
Yeah, it's just another motor. I'm currently using a motor angle of 246 but that may change over the coming days as I fine tune it.

Hall sensors:
Where the bafang controller had:
Red, Black, Grey, White, Blue
The s12s has:
Red, Black, Yellow, Blue, Green

geofft   1 kW

1 kW
Posts: 356
Joined: Nov 09 2012 9:41am
Location: Berkshire UK

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

Post by geofft » Jun 14 2020 3:01pm

geofft wrote:
Jun 14 2020 8:19am
Was it just a case of getting the phases correct to match the Kunteng?
Yeah, it's just another motor. I'm currently using a motor angle of 246 but that may change over the coming days as I fine tune it.

Hall sensors:
Where the bafang controller had:
Red, Black, Grey, White, Blue
The s12s has:
Red, Black, Yellow, Blue, Green
Thanks, that's all useful info, will probably give this a try sometime.

Also means that if some way can be found to add a torque sensor to the BBS02 it will be easy to configure the f/w to suit...
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   100 kW

100 kW
Posts: 1221
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Jun 15 2020 2:45am

Marctwo wrote:
Jun 14 2020 1:40pm
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

romelec   100 W

100 W
Posts: 114
Joined: Mar 11 2011 3:46pm
Location: Marseille, France

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

Post by romelec » Jun 16 2020 9:35am

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.

User avatar
stancecoke   100 kW

100 kW
Posts: 1221
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Jun 16 2020 12:05pm

romelec wrote:
Jun 16 2020 9:35am
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

romelec   100 W

100 W
Posts: 114
Joined: Mar 11 2011 3:46pm
Location: Marseille, France

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

Post by romelec » Jun 16 2020 1:25pm

stancecoke wrote:
Jun 16 2020 12:05pm
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 wrote:
Jun 16 2020 12:05pm
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 wrote:
Jun 16 2020 12:05pm
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 wrote:
Jun 16 2020 12:05pm
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:

AndZab   1 mW

1 mW
Posts: 14
Joined: May 27 2020 12:22pm

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

Post by AndZab » Jun 17 2020 8:07pm

bj97301 wrote:
Jun 08 2020 10:41am
stancecoke wrote:
Jun 08 2020 2:27am
AndZab wrote:
Jun 07 2020 11:11am
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 wrote:
Jun 07 2020 10:24am
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:

eLsc   1 µW

1 µW
Posts: 2
Joined: Jun 22 2020 1:20pm

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

Post by eLsc » Jun 22 2020 2:00pm

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?

User avatar
stancecoke   100 kW

100 kW
Posts: 1221
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Jun 23 2020 2:38am

eLsc wrote:
Jun 22 2020 2:00pm
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

eLsc   1 µW

1 µW
Posts: 2
Joined: Jun 22 2020 1:20pm

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

Post by eLsc » Jun 23 2020 6:29am

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) Downloaded 5 times

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » Jun 23 2020 6:57am

I sure wish my KT controller wouldn't have gone up in a ball of plasma

Leanier   1 mW

1 mW
Posts: 10
Joined: Jun 21 2020 10:14pm

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

Post by Leanier » Jun 25 2020 4:59pm

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-electr ... oller.html

Blik86   1 mW

1 mW
Posts: 10
Joined: Aug 06 2018 12:03pm

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

Post by Blik86 » Jul 05 2020 2:51am

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
whell_size.png (2.88 KiB) Viewed 188 times

Anders KA   1 µW

1 µW
Posts: 3
Joined: Jul 08 2020 3:23pm

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

Post by Anders KA » Jul 09 2020 4:31am

AlexDaniel wrote:
Apr 15 2020 1:57pm
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: Select all

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: Select all

./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: Select all

./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 (344.96 KiB) Viewed 123 times
IMG-20200709-WA0004.jpg
IMG-20200709-WA0004.jpg (422.85 KiB) Viewed 123 times

AlexDaniel   1 µW

1 µW
Posts: 4
Joined: Oct 18 2019 8:37pm

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

Post by AlexDaniel » Jul 09 2020 4:39pm

Anders KA wrote:
Jul 09 2020 4:31am
AlexDaniel wrote:
Apr 15 2020 1:57pm
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: Select all

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: Select all

./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: Select all

./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. :)

User avatar
stancecoke   100 kW

100 kW
Posts: 1221
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Jul 10 2020 7:56am

AlexDaniel wrote:
Jul 09 2020 4:39pm
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_ ... cts_id=937

Image

regards
stancecoke

Anders KA   1 µW

1 µW
Posts: 3
Joined: Jul 08 2020 3:23pm

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

Post by Anders KA » Jul 10 2020 11:00am

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:

Anders KA   1 µW

1 µW
Posts: 3
Joined: Jul 08 2020 3:23pm

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

Post by Anders KA » Jul 10 2020 11:08am

stancecoke wrote:
Jul 10 2020 7:56am
AlexDaniel wrote:
Jul 09 2020 4:39pm
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_ ... cts_id=937

Image

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!

Post Reply