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

I will try to find proper controller with original STI MCU.
Not sure about the specifications of this MCU or what the real difference between this fake and the original is, but I've yet not been able to spot any problems with the firmware on my controller which has the same "substitute" MCU.
 
So what you mean is that it is safe to flash this replacement MCU version?
I mean that according to my experience of flashing my own "replacement MCU" and the absence of posts about failed "replacement MCU" flashes we can assume that it should be safe to program. If it bothers you that the MCU isn't original you could replace it yourself.
 
Hello, I have the same problem with starting after a standstill. I can rule out that with a strong voltage drop.

During this time, the marked symbol appears in the BluOSec app. After a short activation of the brake the motor starts immediately.
Best Regards
View attachment 339101
I am working on new conversion. The brake activation does not help or help on random basis. I have changed displayed perimeters to see the statuses and it shows 140 that is phase current limiting - 128 + 8 + 4. After weekend i will flash higher values and report if it helps.
 

Attachments

  • IMG_20231104_100054.jpg
    IMG_20231104_100054.jpg
    455.7 KB · Views: 5
So i have increased phase current to the target values (2,5 x battery current), i have also changed SDCC from 4.0 to 4.1 version. Now it works on the stand. Today road test..
 

Attachments

  • IMG20231107081805.jpg
    IMG20231107081805.jpg
    3.7 MB · Views: 12
  • Screenshot_2023-11-07-08-09-43-44_ae09a353f12d123e55918495f84f92b5.jpg
    Screenshot_2023-11-07-08-09-43-44_ae09a353f12d123e55918495f84f92b5.jpg
    304.3 KB · Views: 12
So the test were succesfull. I have fine tuned my invention wich is effort mode that actually is evolution of torque override/hibryd mode but about that some other day later .. :) (need graphs etc.) . The front wheel can experience some skid but it is very short and easy to control. Actually even i started to like it as easier to implement than rear drive and very convient for city/touring riding
 
Hallo, vielen Dank erstmal, für die tolle Firmware die ihr hier zur Verfügung gestellt habt.
Ich bin jetzt mit der App fleißig am Testen. Eine frage habe ich. Was bedeutet es wenn in der App sich ab und zu Die Schrift in Gelb Angezeigt wird. Viele Grüße Martin
 
Do we have somewhere in the code a protection from the motor stall/ blocked? like if the motor is blocked for >1sec it will set the current to zero?
 
Hallo, vielen Dank erstmal, für die tolle Firmware die ihr hier zur Verfügung gestellt habt.
Ich bin jetzt mit der App fleißig am Testen. Eine frage habe ich. Was bedeutet es wenn in der App sich ab und zu Die Schrift in Gelb Angezeigt wird. Viele Grüße Martin
You mean the mobile app "BluOsec" or something else?
 
Problematik mit X4 Regen behoben. Jetzt Reagiert auch die Regeneration mit dem Daumengas. Habe den gelb eingekreisten Widerstand ausgelötet. Von ca. 5Volt am Pin X4 ist die Spannung auf ca.1,2 Volt gesunken. In der Blue Osec App kann man die X4-Werte gut kontrollieren und die Werte bei Betätigung des Daumengas sich verändern.
Die Regeneration wird nur bei Daumengas aktiv, wenn man den Bremsschalter aktiviert.
 

Attachments

  • CAP_20231202_203249.jpg
    CAP_20231202_203249.jpg
    814.2 KB · Views: 21
  • CAP_20231202_203304~2.jpg
    CAP_20231202_203304~2.jpg
    865.7 KB · Views: 21
  • IMG_20231202_232323.jpg
    IMG_20231202_232323.jpg
    2.2 MB · Views: 21
Last edited:
Ist es möglich in der Blueosec Android App die up und down Taste mit einer Bluetooth Fernbedienung zu Steuern? So das man mit beiden Händen am Lenker per Taster die Leistung einstellen kann. Hat da jemand Erfahrungen gemacht. VG Martin
 
The bluetooth app has not been developed for quite long time. People reported it crashing at certain circumstances. Personally i am using it only for calibration and testing procedures.
 
The bluetooth app has not been developed for quite long time. People reported it crashing at certain circumstances. Personally i am using it only for calibration and testing procedures.
Tried that and there was no way to get it properly working enough to even get the calibration data from it since the curve was all over the place and almost unreadable. For some kind of reason the baud rate is limited to 9k6 which severely limits the data thoughput but spp can achieve much more when used with a proper bluetooth module which is handy for testing purposes.

I'm working on a python program which can do the calibration without the app, but then you need a uart to usb converter (and the github version is currently partially broken, I have a fix but it's untested since I'm waiting for new hall sensors to arrive). It basically dumps the current state of the hall sensor input and v-phase current over uart and outputs the angles for you by measuring the arrival times of the data. Since my original motor had an unknown offset in one of the sensors this was quite helpful, and if I fixed the calculation the motor angle should also come out. Use the repo at your own peril, it's only tested on linux and contains code from all over the place.
 
The App works totally reliable - if you pick the correct branch ofStancecoke‘s Github KT OSF. That branch avoids floating point calculations and is therefore faster.
The branch is called „torque from x4“
I use it since years and it did not crash once
 
Die App funktioniert absolut zuverlässig – wenn Sie den richtigen Zweig von Stancecokes Github KT OSF auswählen. Dieser Zweig vermeidet Gleitkommaberechnungen und ist daher schneller.
Der Zweig heißt „Drehmoment von x4“
Ich benutze es seit Jahren und es ist kein einziges Mal abgestürzt
Kann man in der App die up and down taste für Leistung mit einer Bluetooth Fernbedienung Steuern. Hast du da Erfahrung ?
 
Kann man in der App die up and down taste für Leistung mit einer Bluetooth Fernbedienung Steuern. Hast du da Erfahrung ?
No idea. Even if possible, probably not worthwhile - you have to have the App running plus some sort of BT device which interacts with the phone. Also, since the App is based on connecting to these HC-… BT modules, which are not capable of BLE, this setup consumes a lot of power from the phone.
 
On the topic of the app crashing:

For my testing setup I connected the controller to a pc over uart and linked it directly to a SPP rfcomm interface and then connected my phone to the pc. This way you can snoop in on the uart and store some data for tinkering. I've never gotten te app to crash out of itself, unless I killed the rfcomm interface (and thus left the spp connection dangeling) on the pc. I'm pretty sure most crashes come from the app eating itself by sending data and not receiving anything or unhandled bluetooth errors only present in later android versions. Having a very bad clone of the HC05 clones might be cause for issues as well.
Still can't use the app for calibration properly but that is most likely just me using it wrong.

The App works totally reliable - if you pick the correct branch ofStancecoke‘s Github KT OSF. That branch avoids floating point calculations and is therefore faster.
The branch is called „torque from x4“
I use it since years and it did not crash once
Hmm, interesting. Time to measure the difference, though for my setup it won't matter much. The branches everywhere are a mess though ... (yes I'm starting out late with this, so reading and comming up to speed takes a while). I'll have a look at it to see if the speedup is worth the effort of merging it.

Also, since the App is based on connecting to these HC-… BT modules, which are not capable of BLE, this setup consumes a lot of power from the phone.
Using Bluetooth SPP is simple but pretty bad on your battery even communicating with properly configured modules. And the default settings of the HC05's are not helping one tiny bit.

Also, switching to BLE is not a drop in replacement, but since the default is very limited by the 9k6 baud rate a standard GATT "postbox" characteristic could replace it with respect to bandwidth and ease of implementation. But someone also needs to rewrite the app...
 
Keine Ahnung. Selbst wenn möglich, lohnt es sich wahrscheinlich nicht – Sie müssen die App ausführen und ein BT-Gerät haben, das mit dem Telefon interagiert. Da die App außerdem auf der Verbindung mit diesen HC-… BT-Modulen basiert, die nicht BLE-fähig sind, verbraucht dieses Setup viel Strom vom Telefon.
Danke für die Rückmeldung, Ich werde es mal Testen.
 
Time to measure the difference, though for my setup it won't matter much.
That branch avoids floating point calculations and is therefore faster.
Conclusion: about half the time, bit less than that actually (uint32 vs float). Altering the map function to use uint16/uint8's for values under 255 can speed up those parts by almost an order of magnitude, I also redid some other float parts and that also gets the same result in speedup, you basically can do fixed point math in most places by using 16.16bit ints instead of floats without too much loss in rounding errors and a minimum 50% speedup. Do note to not forget proper casting, or you get division by zero or aliasing very quickly.

edit: I redid the PI as well and the slow loop in my code base now takes about 1ms when not receiving data from the display. The brake calculation now also only takes about 1 ms instead of 3+ms. Also, don't make the same mistake I did by forgetting to shift when dealing with fixed point integers. I now know how fast my motor can run from standstill to full speed ...
 
Last edited:
Hello!
I seem to have gotten myself into trouble. Recently I decided to fine tune my controller to work better with my motor. I erased the firmware from the microcontroller to start fresh and followed the exact same steps as I did when I initially flashed the firmware, but this time something is off. I selected the same config preset I used on my first flash and only changed the display from KT-LCD3 to Blueosec for easier adjusting. After connecting everything together I pushed the throttle but nothing happened, luckily I soon realised that the option bytes in the java tool not only unlock the controller but also alters the B3,B2,B1 and B0 pins on the MCU. So I flashed the option bytes and tried again, but now I have another strange issue.

The wheel has what it feels like magnetic resistance to it when i try to spin it by hand (no pas or throttle applied). At the same time, everything works as intended. The resistance seems to disappear when throttle or pas is applied or when I turn on the "PWM off @ coast" option in Blueosec.

To me this seems like the regen somehow works while standing still, as Blueosec is registering negative current when I spin the wheel fast enough. But I cannot find any reason to why it would be on, as all regen options are turned off and the "Regen Current Max" is set to 0.

What can I be missing? I've read through the whole wiki and can't really seem to find any hints about this exact behaviour.
 
...

The wheel has what it feels like magnetic resistance to it when i try to spin it by hand (no pas or throttle applied). At the same time, everything works as intended. The resistance seems to disappear when throttle or pas is applied or when I turn on the "PWM off @ coast" option in Blueosec.

To me this seems like the regen somehow works while standing still, as Blueosec is registering negative current when I spin the wheel fast enough. But I cannot find any reason to why it would be on, as all regen options are turned off and the "Regen Current Max" is set to 0.

What can I be missing? I've read through the whole wiki and can't really seem to find any hints about this exact behaviour.
Try wiping the EEPROM, maybe some old settings are overwriting something. If you somehow enabled ZERO_DC in the aca experimental settings this would also happen. Though unlikely for what you describe as the throttle would not work (I think). Also you might try disabling the throttle and see if the problem still persists.
 
Last edited:
Back
Top