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

Electric Motors and Controllers
User avatar
stancecoke   100 kW

100 kW
Posts: 1003
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 30 2019 3:17am

flangefrog wrote:
Jul 30 2019 2:56am
Currently to connect you just click the Bluetooth icon on the header (ux could be better). You should see a Bluetooth device chooser dialog.
Hm, that only works on my newest android tablet. With my older android mobile and on IPhone and Windows10 it doesn't work.

Perhaps you can write a small tutorial, how to make it work offline?!

Regards
stancecoke

User avatar
flangefrog   1 kW

1 kW
Posts: 368
Joined: Jun 26 2013 10:21pm
Location: Auckland, New Zealand

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

Post by flangefrog » Jul 30 2019 4:05am

As per https://github.com/WebBluetoothCG/web-b ... -status.md
The Windows implementation is available in Chrome 70.0.3526.0 and requires Windows 10 version 1703 (Creators Update).
Android: Requires Android 6.0 Marshmallow or later.
WebBLE is an app for iOS that supports the GATT Communication API
See also https://caniuse.com/#search=web%20bluetooth

You can also use Chromium or Opera on Windows. Of course the PC will need to support Bluetooth LE. Most Bluetooth 4/5 adaptors are dual mode and support LE. Or you can buy one of these: https://www.ebay.com/itm/Mini-USB-Bluet ... 2848510670

On Android you need Opera Mobile, Samsung Internet, Android Browser or Chrome. Make sure you use the browser and the link isn't opening inside an app like Gmail for example, as that will use the WebView where Web Bluetooth isn't yet supported.

On iOS webBLE is a browser that implements the Web Bluetooth API as the iOS WKWebView component used by Chrome doesn't yet support it.

There are already thousands of tutorials on how to use Service Workers. You generally use them as a proxy and supply resources from a local cache rather than a remote server.
https://css-tricks.com/serviceworker-for-offline/
https://developers.google.com/web/funda ... s/offline/
https://developer.mozilla.org/en-US/doc ... ce_workers

I'll add offline support when I have some time.

User avatar
stancecoke   100 kW

100 kW
Posts: 1003
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 30 2019 4:31am

flangefrog wrote:
Jul 30 2019 4:05am
I'll add offline support when I have some time.
Hm, I think this will be necessary. I am already very IT-affine, but such headstands to get an app running offline is not a good prerequisite for a wide use of such applications...

regards
stancecoke

qwerkus   1 kW

1 kW
Posts: 390
Joined: Jul 22 2017 4:00am

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

Post by qwerkus » Aug 02 2019 7:03am

Hi, anyone working on making the sw102 display compatible with the kt open source firmware ? Lot of useful infos here: https://github.com/OpenSource-EBike-fir ... -LCD-SW102
I'd join the effort but my knowledge is not deep enough to do everything by myself.

User avatar
stancecoke   100 kW

100 kW
Posts: 1003
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 » Aug 02 2019 11:36am

Sorry, but both of the main developers don't like any display. (Xnyle prefers his BlueOsec App for the android cell phone, I prefer to have no device at my handlebar at all :wink: )

Of course everbody is invited to implement the stock Bafang-protocol to our firmware. I think it could be done by copy and paste from the "Forumscontroller" code. As long as there is no possibility to flash the sw102 without destroying the housing, a custom firmware for the display is no alternative...

regards
stancecoke

qwerkus   1 kW

1 kW
Posts: 390
Joined: Jul 22 2017 4:00am

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

Post by qwerkus » Aug 02 2019 1:40pm

stancecoke wrote:
Aug 02 2019 11:36am
Sorry, but both of the main developers don't like any display. (Xnyle prefers his BlueOsec App for the android cell phone, I prefer to have no device at my handlebar at all :wink: )
Cool! I get that there is no need for all the hype stuff, bu how do you check batt level and how do you control power / temperature to make sure it doesn't overheat ?
stancecoke wrote:
Aug 02 2019 11:36am
Of course everbody is invited to implement the stock Bafang-protocol to our firmware. I think it could be done by copy and paste from the "Forumscontroller" code. As long as there is no possibility to flash the sw102 without destroying the housing, a custom firmware for the display is no alternative...
Ok, thanks for the heads up.

User avatar
stancecoke   100 kW

100 kW
Posts: 1003
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 » Aug 03 2019 2:53am

qwerkus wrote:
Aug 02 2019 1:40pm
how do you check batt level and how do you control power / temperature to make sure it doesn't overheat ?
I know quite exactly, how far I can ride with a fully charged battery. I use the motor only for commuting, not for trips in the mountains. The power is controlled by my legs, I have a torque- and cadence-sensor installed. Overheat is no problem with 10 amps maximum current and no long/steep inclines.

regards
stancecoke

fi7ippo   10 mW

10 mW
Posts: 24
Joined: Aug 26 2018 2:29am

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

Post by fi7ippo » Aug 03 2019 10:27am

FedeleC wrote:
May 26 2019 11:07am

I want to investigate on my thought that in some situations (hilly journeys), the power saved by auto shift (letting the driver legs/motor work with the most adequate gear) is more than the power consumption of this sub-system.


So, I rerouted/created some input/output of my KT36/48SVPR-HRD01:
  • Rearranged some wires to power the Sempu T2 @ 36 V
  • Draw current directly from Vbat +36V pad to a DC/DC Step Down Converter to 6,8V, to power the servo. I reached to connect and enclose it inside the controller box
  • Attached Servo signal output to a pad connected (via a 2,2K resistor) to PIN 43 of STM8S: I want try to use it as a PWM output of Timer 3, not used yet by OSEC, @ about 50 Hz. I've to check if i'll need to short circuit the 2,2 K resistor, I hope not :wink:
  • Attached a passive buzzer output to a pad connected (via 2,2 K resistor, again) to PIN 45: it would be sooo nice to notice the driver of an imminent gear shift...This PIN has to be reconfigured with the STM8 S Option byte to work as a Beep source.
After finishing optimizing the OSEC to my motor (it worked at first start!), next days I'll work on FW to create the automatic gear shift function: altough I'm not a programmer I have a past experience in motor controllers...so let's try! :D
Hi FedeleC, I'm very interested to Your project! Do You make any progress?

I don't know if putting the servo on the derailleur is the best thing because of its weight on the gearbox. It would probably be easier to use with any derailleur if it operated the stock cable (much shorter, since the servo can be put on the dropout).
But the principle is the same.
I'm dreaming of connecting a bluetooth remote control for the gears to the SW102 display and controlling the derailleur with the KT or TSDZ2 controller (but I don't think there is a pwm free output on this), so we can no authorise gear change if cadence < 10, or pedal torque > 30Nm, automatic gear change, and a lot of more stuff ...

Thanks You!

haiyi911   1 W

1 W
Posts: 57
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Aug 06 2019 1:35am

Hi,
When I start to ride under PAS mode, the motor works intermittently, with a creaking sound. Yet when I speed the pedaling up, the abnomal sound disappear and it goes smoothly.Do I have to worry about parameters?
PAS magnets:5
timeout:3125
ramp end :1500 or 18750(10rpm)
ramp start:64000
pas threshold:1.1
Thanks in advance.

User avatar
stancecoke   100 kW

100 kW
Posts: 1003
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 » Aug 06 2019 2:34am

haiyi911 wrote:
Aug 06 2019 1:35am
When I start to ride under PAS mode, the motor works intermittently, with a creaking sound.
Ramp start bigger than timeout makes no sense.
Use a PAS with more magnets and /or increase timeout.

regards
stancecoke


redmouse   100 mW

100 mW
Posts: 48
Joined: Aug 03 2017 7:16pm

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

Post by redmouse » Aug 15 2019 3:50pm

Good day folks,
would anyone advise which pins on my controller are used for programming?
Mine is 18-fet and the board looks different than the example controller.
Or can I straight up use the display cables for programming?

here's pictures of my controller:
https://imgur.com/a/w2XMfQr

And in case anyone can help with my cutting out problem: viewtopic.php?f=30&t=101681

tolkaNo   100 W

100 W
Posts: 111
Joined: Dec 29 2017 4:28am
Location: South Australia

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

Post by tolkaNo » Aug 20 2019 3:23am

Do you guys know if the KT-LCD8 display's will work on non KT controllers? Obviously i won't have any programming features but i should still be able to get voltage and speed readout assuming one of the wires from the display is for hall's

User avatar
Xnyle   10 W

10 W
Posts: 73
Joined: Sep 03 2018 1:05pm

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

Post by Xnyle » Aug 25 2019 10:55am

It isn't, its a very minimalistic (1980s style) digital protocol via UART. IIRC even the voltage reading is not being measured directly by the display.

csbike   100 mW

100 mW
Posts: 37
Joined: Apr 05 2019 2:18am

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

Post by csbike » Aug 26 2019 5:52am

sorry for my newbie question. I just got my stlinkv2 and I would like to flash the firmware from MacOSX.
openOCD seems to work, but I cannot find scripts for stm8, only stm32. Is this normal?
Otherwise there seems to be stm8flash. I haven't tried it yet. Does it require openocd? Or is it standalone?

thanks

User avatar
stancecoke   100 kW

100 kW
Posts: 1003
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 » Aug 27 2019 2:37am

csbike wrote:
Aug 26 2019 5:52am
Does it require openocd?
openocd is only needed for debugging.

regards
stancecoke

csbike   100 mW

100 mW
Posts: 37
Joined: Apr 05 2019 2:18am

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

Post by csbike » Aug 27 2019 4:55am

stancecoke wrote:
Aug 27 2019 2:37am
csbike wrote:
Aug 26 2019 5:52am
Does it require openocd?
openocd is only needed for debugging.

regards
stancecoke
thanks, but from what I understood, you can also flash using openocd. Or am I wrong?
Also where do I get the stm8 files I need as they are not in the official openocd directory. I found this openOCD clone (https://github.com/ntfreak/openocd/tree ... tcl/target). Is this where you guys get them? Should I install the clone, or just copy over the missing scripts?

thanks

User avatar
Aquakitty   100 W

100 W
Posts: 122
Joined: Jun 10 2017 3:07pm

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

Post by Aquakitty » Sep 04 2019 9:34pm

Hi, using this firmware, can I reprogram my 12 mosfet controller to a lesser amperage? I think the version I purchased is too much for my battery, but not entirely clear yet on why. Like could I limit it using the amperage setting to 20 amps?
Rans Enduro Sport w/Sturmey-Archer XFRD8, TSDZ2 open source mod 48v
GT Verb Comp f/s TSDZ2 open source 48v
Diadora Ampio bargain f/s TSDZ2 48v
2020 Diamant 247 belt drive 1000w 9C 48v
Hardtail made from random bits I had laying around, ginormous old Marzocchi fork, BBS02

geofft   1 kW

1 kW
Posts: 346
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 » Sep 05 2019 9:39am

Aquakitty wrote:
Sep 04 2019 9:34pm
Hi, using this firmware, can I reprogram my 12 mosfet controller to a lesser amperage? I think the version I purchased is too much for my battery, but not entirely clear yet on why. Like could I limit it using the amperage setting to 20 amps?
As long as your controller is a suitable type for the firmware you can configure limits in both battery and motor phase current. Have a read through the guide here:-

https://github.com/stancecoke/BMSBatter ... mware/wiki

...you'll find all the info you need there.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

Powerhour   100 µW

100 µW
Posts: 7
Joined: Sep 08 2019 11:33am

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

Post by Powerhour » Sep 08 2019 12:47pm

Thanks for all the time spent on this
Last edited by Powerhour on Sep 11 2019 10:28am, edited 1 time in total.

cnrd   10 mW

10 mW
Posts: 25
Joined: Apr 12 2019 5:47am

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

Post by cnrd » Sep 09 2019 2:41am

Hi

So before I order, is this controller compatible? https://s.click.aliexpress.com/e/OD09IRG8

Also I have a KT-LCD3, which currently has the TSDZ2 FW on it, any way to use it with a KT controller on this FW?

Powerhour   100 µW

100 µW
Posts: 7
Joined: Sep 08 2019 11:33am

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

Post by Powerhour » Sep 14 2019 1:12pm

This awesome new color lcd states that it has the communication protocol supporting the tongsheng controller.. could the firmware be loaded onto one of these?

C$ 109.95 | colored TFT LCD display 24v36v48v52v60v72v 3.5 inch IPS screen vertical/horizontal middle type+controller electric bike parts
https://s.click.aliexpress.com/e/BPA08yFI

geofft   1 kW

1 kW
Posts: 346
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 » Sep 15 2019 2:50am

Powerhour wrote:
Sep 14 2019 1:12pm
This awesome new color lcd states that it has the communication protocol supporting the tongsheng controller.. could the firmware be loaded onto one of these?
The o/s firmware is actually loaded into the controller not the display. The display you mention isn't supported by the fw and even if the comms protocol was similar you would probably have some other issues. Best to stick with a supported display, the lcd3 is the obvious choice here.

I see from other threads you are keen to use a torquesensor, I'm using the Sempu T4 t/s with this firmware and can confirm it works well with Stancecoke's branch. Be aware though that setting up the hardware and fw to get everything working well takes some time and patience, this is not a plug and play solution. Also developement of the fw seems to have pretty much finished and it can sometimes be difficult nowadays to get help when you run into trouble, however the wiki contains lots of good info.

In your situation I would be taking a long hard look at the TSDZ2..... :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

casainho   1.21 GW

1.21 GW
Posts: 3520
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Sep 15 2019 4:46am

geofft wrote:
Sep 15 2019 2:50am
Powerhour wrote:
Sep 14 2019 1:12pm
This awesome new color lcd states that it has the communication protocol supporting the tongsheng controller.. could the firmware be loaded onto one of these?
The o/s firmware is actually loaded into the controller not the display. The display you mention isn't supported by the fw and even if the comms protocol was similar you would probably have some other issues. Best to stick with a supported display, the lcd3 is the obvious choice here.

I see from other threads you are keen to use a torquesensor, I'm using the Sempu T4 t/s with this firmware and can confirm it works well with Stancecoke's branch. Be aware though that setting up the hardware and fw to get everything working well takes some time and patience, this is not a plug and play solution. Also developement of the fw seems to have pretty much finished and it can sometimes be difficult nowadays to get help when you run into trouble, however the wiki contains lots of good info.

In your situation I would be taking a long hard look at the TSDZ2..... :wink:
I hope someday to use the 3kw Bafang BBSHD mid drive motor drive (for my future cargobikes when I will have baby) with KT motor controller and this firmware, then, I will want to add support for the 850C and SW102 as on the TSDZ2 firmware.

The Bafang BBSHD, we can't simple develop firmware for it, so, must be with an external controller.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

geofft   1 kW

1 kW
Posts: 346
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 » Sep 15 2019 6:56am

casainho wrote:
Sep 15 2019 4:46am

I hope someday to use the 3kw Bafang BBSHD mid drive motor drive (for my future cargobikes when I will have baby) with KT motor controller and this firmware, then, I will want to add support for the 850C and SW102 as on the TSDZ2 firmware.

The Bafang BBSHD, we can't simple develop firmware for it, so, must be with an external controller.
...as discussed elsewhere, the torquesensor is the key to turning the BBS02/HD into the brilliant drive that it could be. Hopefully a solution that fits the bill will come along, I'm keeping an eye out for possibilities. I might see if I can get a pair of those pedal pressure sensors to work with the existing KT fw, it would be interesting to see how they perform...
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

Post Reply