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

Electric Motors and Controllers
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 » May 15 2019 10:25am

So those resonances seem to be a commutation issue after all, although I have no idea what might cause them.
not only the interpolation, but the angle assorted to the hall events, too. In reverse direction, 60° is followed by 0°, not 120°.
Ofc iterpolation has to go backwards then and maybe also you'd have to add -120° (or -60°?) to the table lookup (also not sure if motor angle would be the same for forward and backward rotation)

But the (virtual) angle itself assorted to the hall events doesn't change!?

kkm   1 mW

1 mW
Posts: 10
Joined: Sep 27 2018 3:22pm

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

Post by kkm » May 15 2019 3:20pm

stancecoke wrote:
May 15 2019 6:21am

It's a mecanical problem, you can try to increase/decrease the tension of the spokes, but that might just shift the resonance range...
No, this is not a "mechanical" problem, it is absolutely exactly a software problem. Or, perhaps, hardware problems (signal filtering, interference) of the KT controllers themselves.
I tested the original KT firmware (sine and square version) on 7 different gear (rear :)) motors - Bafang, Mxus, and Shengyi. They all had the same problem - the resonances and vibrations of the bike frame and equipment of the bike at a speed of 5-8 km / h, and at a speed of 11-13 km / h. Exactly the same problem with open source firmware. Which is a bit strange.
BTW - Mxus XF15R has good mechanics and an absolute lack of even the slightest vibrations and resonances on a cheap "trapezoid" chinese DMHC controller (I quoted the link above). My other motors also work smoothly without vibration. All this is easy to check - just take another (not KT) controller and check the operation of the motors. Vibration will not be
All this is very sad.
P.S. My KT controllers s have 25 kOhm resistors, instead of "standard" 2.2-2.5 kOhm between + 5V and the signal output of the hall sensors(open collectors). Perhaps - the problem is this, the signals are too "dirty" - the pulses from the motor windings can distort the signals from the hall sensors....

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 » May 15 2019 4:02pm

Does this cheap "trapezoid" even do PWM?

I recently added a trapezoid wavetable, you could test that by changing a few lines in motor.c

But ofc this "trapeziod" ist still generated via PWM. Maybe it's simply the PWM frequency on the KT controllers.

Can we change that at all? Edit yes we can and we did, high speed setting, which btw. doesn't change anything as well :(

So many questions, so few answers ;-)

Edit: You can almost certainly exclude hall sensor problems. I experimented a lot, tested 360° interpolation (basically disabling them), logged jitter, implemented anti jitter. All this had minimal to zero effect. There isn't much jitter btw.

Edit2: anyone tested PWM dead times >1us? the comment "hardware nees a dead time of 1us" might be for a 24V 6fet controller? Dead time distortion shouldn't become a problem, if dead time is < 1% of PWM frequency, right?

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 » May 16 2019 2:13am

kkm wrote:
May 15 2019 3:20pm
No, this is not a "mechanical" problem, it is absolutely exactly a software problem. Or, perhaps, hardware problems (signal filtering, interference) of the KT controllers themselves.
OK, but it can't be a software problem. I have a buck converter for supplying the head- and rearlights on my bike. Even if the battery is not installed at all and the controller is switched off, the resonaces appear when the lights are switched on. The direct drive motor is working as a generator via the body diodes of the mosfets in this case. So it can't be a matter of PWM or commutation.

This leaves only a hardware problem as the cause of the resonances.
Capacity and inductivity may be in an unfavourable relation.

regards
stancecoke

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 » May 16 2019 4:52am

Then the remaining question is: Can we do something about it via software.

If we can that would be great, because then we're better than the original FW in yet another area.

I don't have the equipment to even figure out what's going on. If someone has a fancy oscilloscope he could probably just hook up a motor to it (3 phases and hall sensor signals), apply some resistance to the motor, twist and fix the throttle until resonances appear and then create a few dumps/screenshots so we at least know what might be going on.

Pegazus   1 mW

1 mW
Posts: 15
Joined: May 18 2019 8:40am

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

Post by Pegazus » May 18 2019 10:00am

Hi Folks,

I'm very interested in the KT controller specially if it can support the Bafang SW102 display device (also have G310 rear hub motor).

https://www.amazon.com/BAFANG-Display-A ... ay&sr=8-11

Does someone know if this display is or could be supported by a KT controller ?

davideserin   1 W

1 W
Posts: 53
Joined: Feb 01 2016 7:57am

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

Post by davideserin » May 18 2019 10:50am

Hi, i'm trying to set this software up and finding it super confusing. I've followed the links in the website linked at the beginning of this thread and can't find what is mentioned for a few links. Where are the most up to date and simple step by step instructions for getting set up? I can use Mac, Windows XP or Windows 10, whichever is better for this. Thanks!

I've had trouble finiding the correct SDCC files. I download the linked files and the setup Install.txt file tells me to click sdcc-3.9.0-setup.exe but it's not in the downloaded files.

I've installed Java Runtime, but can't launch OSEC Parameter Configurator.jar

Thanks!

davideserin   1 W

1 W
Posts: 53
Joined: Feb 01 2016 7:57am

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

Post by davideserin » May 18 2019 12:48pm

davideserin wrote:
May 18 2019 10:50am
Hi, i'm trying to set this software up and finding it super confusing. I've followed the links in the website linked at the beginning of this thread and can't find what is mentioned for a few links. Where are the most up to date and simple step by step instructions for getting set up? I can use Mac, Windows XP or Windows 10, whichever is better for this. Thanks!

I've had trouble finiding the correct SDCC files. I download the linked files and the setup Install.txt file tells me to click sdcc-3.9.0-setup.exe but it's not in the downloaded files.

I've installed Java Runtime, but can't launch OSEC Parameter Configurator.jar

Thanks!
I was trying to install in XP and failed. Tried in Wiindows 10 and it was straight forward. Solved!

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 » May 18 2019 12:55pm

Pegazus wrote:
May 18 2019 10:00am
if it can support the Bafang SW102 display device
You can use a eggrider display, it uses the same hardware and is available with Kunteng protocol, as far as I know.

davideserin wrote:
May 18 2019 10:50am
Where are the most up to date and simple step by step instructions for getting set up?
See my signature.

regards
stancecoke

Nixunen   1 mW

1 mW
Posts: 18
Joined: Aug 27 2018 11:54am

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

Post by Nixunen » May 20 2019 12:00am

I use EggRider and yes it works with KT protocol. So i assume it can work also in this open source firmware ? Can i change assist levels, and settings (some c and p values?). EggRider uses just same settings than LCD3 display

Pegazus   1 mW

1 mW
Posts: 15
Joined: May 18 2019 8:40am

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

Post by Pegazus » May 20 2019 2:39am

I contacted them. Can't wait to have their answer, I really love that display !

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 » May 20 2019 4:44am

I pedaled a little hard when the controller was turned on , without throttle and PAS. the motor maybe working,are there some setting to avoid that? :D

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 » May 20 2019 5:30am

Nixunen wrote:
May 20 2019 12:00am
So i assume it can work also in this open source firmware ?
@Xnyle has implemented all parameters of the protocol in the display.c code, but as both of us don't like LCD displays very much, only very basic functions, like assist level, are really used. Just for showing speed, power and switching the assist levels, the EggRider will work with the open source firmware.

haiyi911 wrote:
May 20 2019 4:44am
I pedaled a little hard when the controller was turned on , without throttle and PAS. the motor maybe working,are there some setting to avoid that? :D
Can you explain again, please, I don't understand what the problem is.

regards
stancecoke

casainho   1.21 GW

1.21 GW
Posts: 3519
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 » May 20 2019 6:03am

stancecoke wrote:
May 20 2019 5:30am
Nixunen wrote:
May 20 2019 12:00am
So i assume it can work also in this open source firmware ?
@Xnyle has implemented all parameters of the protocol in the display.c code, but as both of us don't like LCD displays very much, only very basic functions, like assist level, are really used. Just for showing speed, power and switching the assist levels, the EggRider will work with the open source firmware.
I think what you guys are missing here is that SW102/EggRider LCD is a small LCD AND Bluetooth communication.
You don't have this LCD fully working because you are missing the Bluetooth communication.

You can join us here to have the Bluetooth communication on the OpenSource firmware for KT motor controllers: https://github.com/OpenSource-EBike-fir ... -LCD-SW102
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.

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 » May 20 2019 6:19am

Regarding C and P Parameters, they are being processed, but not bound. Wheelsize currently can not be bound, cause its one of the few options not yet changable at runtime. P1 could be bound now. The remaining P and C values have limited value ranges (you have to look at the logical and shift operators) and could be bound to something. But as long as people don't come up with suggestions on what to bind them to, nothing will happen ;-)

Code: Select all

			lcd_configuration_variables.ui8_assist_level = ui8_rx_buffer [1] & 7;
			lcd_configuration_variables.ui8_max_speed = 10 + ((ui8_rx_buffer [2] & 248) >> 3) | (ui8_rx_buffer [4] & 32);
			lcd_configuration_variables.ui8_wheel_size = ((ui8_rx_buffer [4] & 192) >> 6) | ((ui8_rx_buffer [2] & 7) << 2);

			lcd_configuration_variables.ui8_p1 = ui8_rx_buffer[3];
			lcd_configuration_variables.ui8_p2 = ui8_rx_buffer[4] & 0x07;
			lcd_configuration_variables.ui8_p3 = ui8_rx_buffer[4] & 0x08;
			lcd_configuration_variables.ui8_p4 = ui8_rx_buffer[4] & 0x10;
			lcd_configuration_variables.ui8_p5 = ui8_rx_buffer[0];

			lcd_configuration_variables.ui8_c1 = (ui8_rx_buffer[6] & 0x38) >> 3;
			lcd_configuration_variables.ui8_c2 = (ui8_rx_buffer[6] & 0x37);
			lcd_configuration_variables.ui8_c4 = (ui8_rx_buffer[8] & 0xE0) >> 5;
			lcd_configuration_variables.ui8_c5 = (ui8_rx_buffer[7] & 0x0F);
			lcd_configuration_variables.ui8_c12 = (ui8_rx_buffer[9] & 0x0F);
			lcd_configuration_variables.ui8_c13 = (ui8_rx_buffer[10] & 0x1C) >> 2;
			lcd_configuration_variables.ui8_c14 = (ui8_rx_buffer[7] & 0x60) >> 5;

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 » May 20 2019 9:00am

stancecoke wrote:
May 20 2019 5:30am
[
Can you explain again, please, I don't understand what the problem is.
the controller was powered off,rotating motor was easy.
the controller was powered on, i felt resistance when i rotated motor by hand ,
so i think the motor should be rotated smoothly without resistance even thought the controller was powered on(didnot rotate throttle).
I had tested,but :(
//#define DISABLE_PWM_CHANNELS_1_3 rotating resistance,throttle was valid
#define DISABLE_PWM_CHANNELS_1_3 rotating easy, throttle was invalid

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 » May 21 2019 1:04am

@Xnyle has implemented the experimental function PWM off in the Java-tool.
You can try this setting. But rotating the wheel by hand is not a normal use case, while riding or pushing your bike you won't recognize a resistance, as the control loop will keep the current at zero fast enough.

regards
stancecoke

davideserin   1 W

1 W
Posts: 53
Joined: Feb 01 2016 7:57am

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

Post by davideserin » May 21 2019 2:04am

Hi stancecoke,

You mention using a Buck converter to power the HC-05 bluetooth module, which needs around 30ma at 5v. My current meter shows 40ma from the controller and I have only a PAS running directly from the battery, so would it be ok to run the bluetooth module if it's the only 5v sensor and no display?

Thanks for your work on the project and support!

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 » May 21 2019 2:19am

You can try it of course, but I don't recomment to do it. The big resistor and the voltage regulator will get very hot. Perhaps the voltage will drop and you'll get a very strange behaviour of the whole system.

regards
stancecoke

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 » May 21 2019 4:29am

Display is not running on 5V rail, so there is no current you're saving if you don't have it. For every mA the BT mod uses, the regulator will burn 10 times more, not a good idea.
Last edited by Xnyle on May 21 2019 12:26pm, edited 1 time in total.

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 » May 21 2019 10:27am

stancecoke wrote:
May 21 2019 1:04am
@Xnyle has implemented the experimental function PWM off in the Java-tool.
You can try this setting. But rotating the wheel by hand is not a normal use case, while riding or pushing your bike you won't recognize a resistance, as the control loop will keep the current at zero fast enough.
I can recongnize a obvious resistance while riding or pushing my bike(the controller was powered on) .
i exchanged another controller and the motor without resitance(the controller was powered on).
So i choose “diagnosis” mode to konwn the controller state,when the controller was powered on and the bike was standstill,
the information was 17,0,0,321,0,7 ,17 were PAS RAMP and throttle/torquesensor currently override.
if the 17 affected the resistance?
when the controller powered on ,should the controller state be 0 not 17???

davideserin   1 W

1 W
Posts: 53
Joined: Feb 01 2016 7:57am

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

Post by davideserin » May 23 2019 6:01am

stancecoke wrote:
May 21 2019 2:19am
You can try it of course, but I don't recomment to do it. The big resistor and the voltage regulator will get very hot. Perhaps the voltage will drop and you'll get a very strange behaviour of the whole system.

regards
stancecoke
Thanks, i've ordered a little DCDC.

I'm all set and ready to flash the controller, but was a little confused by these instructions:

"Before deleting, please find out the correct phase and Hall sensor assignment on the complete system with the original firmware. This ensures that the controller in principle harmonizes with the engine."

Does this simply mean finding the right cable combinations for the phase and halls, or does it relate to some software parameters?

davideserin   1 W

1 W
Posts: 53
Joined: Feb 01 2016 7:57am

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

Post by davideserin » May 23 2019 9:17am

Xnyle wrote:
Oct 21 2018 9:45am
Besides: I think we desperately are in need for someone to create a "how to get this thing running" flowchart /cheat sheet/youtube tutorial, something like that. So anyone who want's to contribute is welcome. What's not so welcome are ppl that produce a constant stream of support requests :)
I'm up for putting some work into this, like updating the documentation perhaps, or maybe a simple video.

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 » May 24 2019 3:42am

davideserin wrote:
May 23 2019 6:01am

"Before deleting, please find out the correct phase and Hall sensor assignment on the complete system with the original firmware. This ensures that the controller in principle harmonizes with the engine."

Does this simply mean finding the right cable combinations for the phase and halls, or does it relate to some software parameters?
This is, as you suspect, simply making sure that the phase/hall combo is correct before flashing the new firmware. If your motor runs cleanly with the stock fw you should be ok.. :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

kkm   1 mW

1 mW
Posts: 10
Joined: Sep 27 2018 3:22pm

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

Post by kkm » May 25 2019 1:55am

haiyi911 wrote:
May 20 2019 9:00am

the controller was powered off,rotating motor was easy.
You are lucky that the motor stops after releasing the throttle stick :). In my case (9-fet hailong-integrated controller) when you release the throttle (without pressing the brake lever), the motor never stops completely and rotates at a speed of 2.4 km/h with sufficient power (do not stop with your hands). Of course, if the switch inside brake lever has been activated, the motor stops completely. But still this is a problem. I remembered the old "bad workaround"
https://endless-sphere.com/forums/viewt ... d#p1387010

and changed

Code: Select all

adc.c
79:  ui16_current_cal_b -= 1: 
to
ui16_current_cal_b -= 2: 
Now the motor (MXUS XF15R) stops completely without brake switch, but kt-lçd3 shows 9W power instead of 0W, when the controller is turned on and after the motor is completely stopped.

https://github.com/stancecoke/BMSBatter ... 0c313f9baf

Regarding the latest commits: I discovered a strange problem - with active driving, my stupid "throttle pressed when power on" protection

Code: Select all

main.c

while (ui8_adc_read_throttle ()> = ADC_THROTTLE_MIN_VALUE);

         // ITC_SetSoftwarePriority (ITC_IRQ_TIM1_OVF, ITC_PRIORITYLEVEL_2);
is triggered, and I have to turn off the controller and turn it on again.

I could not understand what was the matter, until I realized that it was the watchdog that was triggered by restarting the firmware. Programmers know better, but I suppose that the processor is already a bit "overloaded" by interrupt handling or something similar..
Latest version without this trouble i checked (and may be +1-2 commts "up", not tested)
https://github.com/stancecoke/BMSBatter ... 0c313f9baf
Who can get debug logs when traveling - please check if there are "System initialized" messages if you didn’t turn off and on the controller again
Regarding the resonances of the rear gear motors ... I replaced the unnamed Chinese hall sensors (marked "613" on the case) in XF15R with Infineon TLE4935L (latch), the best option for motors with an unstable magnetic field (different gaps between magnets, chipped magnets and etc)). And shortened the signal wires from the hall PCB.
https://photos.app.goo.gl/1n3eJMYQQB9qTJN78
The result ... Not so much. The peaks of the resonance at a speed of 7.2 km/h and 11.4 km/h have decreased, but only that. There is almost no difference with the Bafang SWX02 motor ...
Friends who ask to ride my bike with the original or open source KT firmware, exclaim "Wow, did you buy at the nearest sex shop?". I take offense, install a cheap Chinese DMHC controller (STM8S903K3, "unprotected" (downloadable from controller) firmware) with its poor and primitive LCD display, and go further... Without vibrations and resonances ...

Post Reply