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

Where did you get the information, that the LSW1599-4M is a LD-SS03? The ones from Yose power are square wave for sure.
Ah, sorry. I directly compared the parameters of the LSW1599-4M to the product catalog on Lishuis website. Didn't suspect that Lishui did custom orders 😓.

Thank you for the heads up. I alsmot wasted 60€.
Do you happen to know any place to buy the sinewave variant?
 
It has been a long time since I looked into this forum. I see some people have issues with the motor having resistance on coasting. I also noticed this and found this irritating. You need to look at the dutycycle your motor runs at versus the speed and then you can calculate the constant. Originally it is 1.5 and I have it set at 1.85.
I also wanted the controller to be able to restart at speed and I just added the uptime variable in acasetpoint.c and I have restarted my controller at speeds plenty of times.
if ((ui16_aca_experimental_flags & PWM_AUTO_OFF) == PWM_AUTO_OFF) {
controll_state_temp += 512;
//disable PWM if enabled and no power is wanted
if (uint_PWM_Enable && uint32_current_target == ui16_current_cal_b || ui8_BatteryVoltage < (ui8_s_battery_voltage_min-2)) {
TIM1_CtrlPWMOutputs(DISABLE);
uint_PWM_Enable = 0;
}
//enable PWM if disabled and voltage is 6.25% higher than min, some hysteresis and power is wanted
if (ui8_uptime >= 1 && !uint_PWM_Enable && ui8_BatteryVoltage > (ui8_s_battery_voltage_min + (ui8_s_battery_voltage_min >> 4)) && (uint32_current_target != ui16_current_cal_b)) {
TIM1_CtrlPWMOutputs(ENABLE);
uint_PWM_Enable = 1;
}
}
I am now interested in getting a bit more speed out of my bike and I want to select the third harmonic wavetable, as I think this is corresponds to/emulates SVPWM with min/max injection. With that technique your line-line voltage on the motor can be increased by 15% compared to a pure sine wave, without distortion (provided there is an ungrounded starpoint), but I do not know if the wavetable truly represents that. Where can I find more documentation on the wavetables?
 
Anyone without the issue of DD motor resistance at coasting on KT?

Reason to ask is that in my custom FOC controller (nothing related to KT) w/ DD, after board rework, similar issue happens, which was not present earlier.

DC-DC converter of this board did a suicide that killed gate drivers as well. Gate drivers were replaced & board resurrected, controller now works okay, except for the resistance at standstill. At the time of fault, current was very high, which might have caused overvoltage to current shunt amplifier input. Now phase current waveforms have more noise as compared to earlier. Suspecting the issue in my case to be either with the quality of hand soldering or degradation of current shunt amplifier.

EDIT: Slightly rephrased
 
Last edited:
Noise issue in my case is due to processor ADC, and not due to CSA or hand soldering quality.

Attached phase current waveform with different processors on the same board.

Phase current (for 180 degrees) at a certain load & speed as seen by the processor 1 in uP1.png. This one doesn't have resistance at coasting, current waveform is relatively smooth (for the issue at hand, ignore the current not being a proper sinewave, hall interpolation inaccuracy is causing it, it needs improvement)

For the same condition, phase current as seen by processor 2 is in uP2.png. This have resistance at coasting, it have a lot of noise in the current.

Note that current waveform observed in scope is similar (w.r.t noise) in both the cases, i.e. they were smooth.

In my case, processor is STM32F103, both were clones, verified by reading processor JTAG id. On KT, IIUC, processor is STM8.

So there is a possibility that the KT STM processor (clone?) is the culprit for resistance at coasting.
 

Attachments

  • uP1.png
    uP1.png
    22 KB · Views: 2
  • uP2.png
    uP2.png
    46.1 KB · Views: 2
It's been a few years since I've looked at this thread. Can anybody tell me what the overall stability is of this software these days or is it still in a very experimental stage? I would primarily be interested in it for its field strength weakening as a possibility to increase my speed maybe 10% at the top end on my direct drive 20 inch hub motor.
Have there been actual road tests of the field strength weakening for affecting top speed on a direct drive hub motor? I'm talking about actual GPS experimental results with just turning on and turning off field strength weakening.
 
So there is a possibility that the KT STM processor (clone?) is the culprit for resistance at coasting.
That's a great observation! The new "as" clones are probably not as good as their original. I should have a 9 FET KT controller with the original stm8 mcu laying around somewhere. I'll solder a makeshift adapter for my dd motor and see if the resistance is as noticeable on the 9 FET.

EDIT:
If I should judge based on the effort I have to put in by turning the shaft of the dd motor about half a turn, then my 6 FET with the (as) clone seems to have a slightly higher resistance than the original 9 FET.
 
Last edited:
Where did you get the information, that the LSW1599-4M is a LD-SS03? The ones from Yose power are square wave for sure.
index.php
Hi, we also have e-bike conversion kits with integrated sine wave controller. If there is anything we can assist you with, please do not hesitate to reach out to us at service@yosepower.com. Thank you very much.
 
Someone made a fork with support for the LCD8, and combines nice features from different forks aswell. It does work! awesome
I would be very interested in this (esp for BluOsec App use and for the "all fixed point arithmetic conversion) - but if I download the linked repository, the included OSEC Parameter Configurator.jar (from folder "tooling") does not even start. Also, the entire file structure looks a bit different. @vastLos: Can you give some insight how to get this running?
PS: I tried this on Windows (W8 32bit and W11 64bit)
 
Last edited:
Hi, we also have e-bike conversion kits with integrated sine wave controller.
Yes, I know, but they seem to be only available in the UK shop?! And they seem to have simple speed levels, not power levels.

The JYT controllers are clones of the Lishui FOC controllers. There is a branch of the EBiCS firmware for the JYTs.

regards
stancecoke

index.php
 
Last edited:
Yes, I know, but they seem to be only available in the UK shop?! And they seem to have simple speed levels, not power levels.

The JYT controllers are clones of the Lishui FOC controllers. There is a branch of the EBiCS firmware for the JYTs.

regards
stancecoke

index.php
Hello Stancecoke,

This shop has e-bike kits with integrated sine wave controller as well.
For any questions regarding our products, please feel free to contact the technical support team at service@yosepower.com. We appreciate your understanding and cooperation.

Kindest regards
 
This shop has e-bike kits with integrated sine wave controller as well.
Can you ask JYTCon for a firmware, that controls the current with the levels, not the speed. Or make this option settable in the display, like Kunteng does with the parameter P3
Screenshot_20240427-080004~2.png
 
Last edited:
Someone made a fork with support for the LCD8, and combines nice features from different forks aswell. It does work! awesome

I would be very interested in this (esp for BluOsec App use and for the "all fixed point arithmetic conversion) - but if I download the linked repository, the included OSEC Parameter Configurator.jar (from folder "tooling") does not even start. Also, the entire file structure looks a bit different. @vastLos: Can you give some insight how to get this running?
PS: I tried this on Windows (W8 32bit and W11 64bit)

If anyone could give a hint - as stated I can not get the java Configurator (of the above linked fork) to run.
(I also went to the fork owners GitHub Page, but see no way to contact the creator or raise an issue there.)
Any help would be appreciated.
Maybe this gives a hint to someone more knowledgeable:
When I run it from command line, I get this output:

Code:
C:\BMSBattery_S_controllers_firmware_1st\tooling>java -jar "OSEC Parameter Configurator.jar"
java.lang.NullPointerException
        at OSEC.<init>(OSEC.java:360)
        at OSEC$1.run(OSEC.java:162)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$500(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
 
Thanks @stancecoke . I tried using the bat file, but it throws a bunch of errors after compiling.
(Just to clarify - I talk about the fork from 'consp' - compiling your version works w/o issues)
-> I guess I stay with the 'Torque from X4' Version in your github for my BlusOsec setup.
(I was curious about this new Fork, because 'Power based Control' does not work in the X4 Version and I was hoping that that was fixed in consp's fork)
 
OK, you will have to update the windows makefile I guess. We had a discussion at GitHub, if someone will maintain this project in future, but nobody was found. :(
 
Last edited:
That is sad, if there will be no maintainer - esp w/ the last improvements by consp, which will be then lost for the public.
I am too clueless with c and github to volunteer myself.
 
Thanks @stancecoke . I tried using the bat file, but it throws a bunch of errors after compiling.
(Just to clarify - I talk about the fork from 'consp' - compiling your version works w/o issues)
-> I guess I stay with the 'Torque from X4' Version in your github for my BlusOsec setup.
(I was curious about this new Fork, because 'Power based Control' does not work in the X4 Version and I was hoping that that was fixed in consp's fork)
I got rid of the errors from the compiling bat file from consp's Fork:
It looks like that in Start_Compiling.bat the path for STMicroelectronics\st_toolset and SDDC is differently defined compared to your fork / compared to the initial recommendations where to install these programs
(see BMSBattery_S_controllers_firmware-master\scripts\Start_Compiling.bat)
This is the path in consp's fork:
Code:
PATH = %PATH%;C:\Program Files\STMicroelectronics\st_toolset\stvp;C:\Program Files (x86)\STMicroelectronics\st_toolset\stvp;C:\SDCC\usr\local\bin
and this is the adjusted one (for installation paths as originally recommended as per your fork) :
Code:
PATH = %PATH%;C:\STMicroelectronics\st_toolset\stvp;C:\Program Files\SDCC\usr\local\bin

(I am not home for some weeks, so I can not test this with actually programming a controller, but the errors are gone and the output looks reasonable to me)

Hope this helps others as well who want to try consp's Fork:

.... However - the one thing I wanted to try this for is switching on "Power based control" (instead of std. Current based control).
But it turns out that that setting is not visible in the config.h
It seems to be hidden somewhere in (one of) these settings:
#define ACA 13440
#define EEPROM_INIT_MAGIC_BYTE 155
#define ACA_EXPERIMENTAL 128

Oh well. -> I will stay with stancecoke X4 branch. (Never change a running system......)
 
Last edited:
Hi,

I've just started using the 'stancecoke/BMSBattery_S_controllers_firmware' software, and after some initial difficulties, I've managed to achieve very pleasing results. I particularly like that the motor is silent (completely quiet). I have the KT48ZWSRL controller (rated current 17A). After numerous tests, I've found what seems to be the best set of settings. I'm aware that some of them go against recommendations, but in my opinion, they make the controller operate smoothly.

However, I still can't solve one problem. Specifically, despite setting the speed limit to 100km/h, the controller starts reducing power at around 40km/h.

Interestingly, this issue was present even with the original firmware. That was one of the reasons for switching to open source, but unfortunately, the problem still persists. I'd like to know why this is happening. I have other controllers (the same models), and each one behaves slightly differently. Some cut power starting at 40 km/h, others at 45 km/h, and some maintain speed up to the set limit. I have no idea what the cause might be.

Is it possible to eliminate this problem with this software at all? Any suggestion on where the issue might lie? Has anyone encountered a similar problem?

I'm attaching a screenshot of my settings from the configurator and a graphical representation of power output versus speed for reference. Adding also my "config.h"

OSEC_PC.PNG

speed_vs_power.PNG
Have a nice day!
Pablos
 

Attachments

  • config.h
    1.4 KB · Views: 3
I got rid of the errors from the compiling bat file from consp's Fork:
It looks like that in Start_Compiling.bat the path for STMicroelectronics\st_toolset and SDDC is differently defined compared to your fork / compared to the initial recommendations where to install these programs
(see BMSBattery_S_controllers_firmware-master\scripts\Start_Compiling.bat)
This is the path in consp's fork:
Code:
PATH = %PATH%;C:\Program Files\STMicroelectronics\st_toolset\stvp;C:\Program Files (x86)\STMicroelectronics\st_toolset\stvp;C:\SDCC\usr\local\bin
and this is the adjusted one (for installation paths as originally recommended as per your fork) :
Code:
PATH = %PATH%;C:\STMicroelectronics\st_toolset\stvp;C:\Program Files\SDCC\usr\local\bin
Oops, I changed that.... I can help you with other things too if you like, but I don't want to maintain the project
 
Yes that would be great! I.e.is there a way to get the java configurator to run?
Consp's fork works differently with some of the flags; stancecoke's system used bit values for ACA flags(the features you can switch enable and disable). consp's fork uses data structs which are more human readable, and instead of a magic number like in stancecoke's config.h( kind #include ACA number), consp sets the flags in include/ acacontrollerstate.h with clearer names representative of the names in the OSEC configurator. I hope I have been clear, but I don't think rewriting the OSEC configurator to work with this is not worth it since it is human readable configuration right now.
 
Consp's fork works differently with some of the flags; stancecoke's system used bit values for ACA flags(the features you can switch enable and disable). consp's fork uses data structs which are more human readable, and instead of a magic number like in stancecoke's config.h( kind #include ACA number), consp sets the flags in include/ acacontrollerstate.h with clearer names representative of the names in the OSEC configurator. I hope I have been clear, but I don't think rewriting the OSEC configurator to work with this is not worth it since it is human readable configuration right now.
Thanks for the response. I do not need the java configurator to work when I can edit a human readable configuration file.
However, I do not understand exactly what you are saying, as when I check "include/acacontrollerstate.h" I see variable NAME definitions, but not VALUE definitions. -> where would I find that? I e. I would like to enable 'Power based control' (as listed in the old setup in the Java configurator) Where do I have to edit what to enable that? (Also: Is the config.h not used at all anymore, or are only certain things migrated elsewhere - and if so - what and where to?)
Sorry for all the questions.....


Edit: Maybe, I understand parts now... is the following correct:

When I want to enable POWER_BASED_CONTROL (and leave the rest as is), I need to change the following line in include/acacontrollerstate.h:
from
#define ACA_HIGH (DYNAMIC_ASSIST_LEVEL | ANGLE_CORRECTION_ENABLED)
to
#define ACA_HIGH (DYNAMIC_ASSIST_LEVEL | ANGLE_CORRECTION_ENABLED | POWER_BASED_CONTROL)
Is that correct?
 
Last edited:
That is correct.
When I want to enable POWER_BASED_CONTROL (and leave the rest as is), I need to change the following line in include/acacontrollerstate.h:
from
#define ACA_HIGH (DYNAMIC_ASSIST_LEVEL | ANGLE_CORRECTION_ENABLED)
to
#define ACA_HIGH (DYNAMIC_ASSIST_LEVEL | ANGLE_CORRECTION_ENABLED | POWER_BASED_CONTROL)
Is that correct?
 
Back
Top