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

Thanks to both of you, really appreciated. :thumb:
Do you know what the normal ratio is on a stock controller? Or is it different on each one?
I really want to know how much phase current my stock 60V 45A KT controller has.
 
Marv1337n said:
Thanks to both of you, really appreciated. :thumb:
Do you know what the normal ratio is on a stock controller? Or is it different on each one?
I really want to know how much phase current my stock 60V 45A KT controller has.
You should ask to Kunteng and then configure that value on the firmware. Also please share with us the answer from Kunteng.
 
casainho said:
Marv1337n said:
Thanks to both of you, really appreciated. :thumb:
Do you know what the normal ratio is on a stock controller? Or is it different on each one?
I really want to know how much phase current my stock 60V 45A KT controller has.
You should ask to Kunteng and then configure that value on the firmware. Also please share with us the answer from Kunteng.

I've wrote them an eMail, I'll let you guys know when I've got an answer.
 
I have just tested the firmware yesterday and it works great!
The app is also very usefull to get it up and running.
I have the 18fet controller with an ebay 48v 1kw hub.
I used the following settings:
motor angle 215
current calibration 50
battery current 120
battery voltage cal 140
Might not be optimal but it starts and runs really well.

For others, trying to get it working I would strongly recommend to get the bt adapter and app and make sure the hall sensor sequence is correct by rotating the wheel slowly.

Is there an explanation how to change the hall angles in order to get equal pwm cycle counts on all of them? With my motor they are slightly different (sometimes +-10) but I don't notice any issue in the motor operation.
Also am I right in thinking these angles only make any sense when its doing 60 degree interpolation and after it goes to 360deg interpolation they wont make a difference?

I've looked at the svm table and I am wondering what tool is used to generate it?
Also would it be more efficient to disable pwm on the low phase? Because now all fets are switching all the time, while if the low portion is all 0s then the phase would be low and there will be no switching on that phase?
pwm.jpg
 
Interesting, it seems like we have a very simular setup apple2.

But some settings are very different, I have battery current 500 (as I understood in the instructions should mean 50A) and battery voltage cal 70.
Did you have to swap any phase or hall wires with the new firmware?

For me the bluosec app freezes all the time, so I don´t really get any live numbers. I can mostly try to have the bike running stedy for a while, and then look at the values after some time.
 
I wanted to have low current limit in the beginning so I set it to something very low then gradually increased it..
I didn't have to swap any wires, all colours match as with the original firmware.
I think the app is really helpful so maybe you should try another bluetooth module or phone..
 
Yes, I have a HC-06 bluetooth module, that was what I could find locally. I bought a HC-05, but there vas no bluetooth module on it.. Maby I can take the bluetooth module from the HC-06 and put on the HC-05 if that is better?

I tried 215 motor angle, but it cogged badly and blew the fuse. So I think I have to go higer, it behaved better at about 230 where I was before.
 
apple2 said:
I've looked at the svm table and I am wondering what tool is used to generate it?
Also would it be more efficient to disable pwm on the low phase?

There are several approaches how to calculate the SVPWM pattern.
You can't switch off any channel as we are using center aligned PWM. Zero in the lookup table does not mean zero DutyCycle on the phase wire. Look at the figure 31 of ST's User Manual 1052.

Glad to hear, that you are happy with our firmware :D

regards
stancecoke
 
stancecoke said:
j bjork said:
So it should still be speed throttle, not torque?
The throttle controls the current (= torque), that's the "normal" behaviour of every throttle in any motorcycle or car.
Xnyle has build in the option assist lvl affects throttle, with this you can reduce the max amps of full throttle for low speeds. (I
Yes, but not "normal" for e-bike (good only for PAS mode, not for throttle) :)
As I already mentioned, almost all other controllers control PWM, not current. Some "good" opensource firmware has 2 throttle mode:

Vesc - PWM and Current throttle:

PWM
https://www.youtube.com/watch?v=W4Nr3D08dQE
Current:
https://www.youtube.com/watch?v=EyiqdzYbGxc

BTW - about "regen". For gear motors, this is nonsense (the same as using the throttle "like a motorcycle" for an e-bike :)) - this only shortens the life of the battery and the motor itself.

But ... If you disable regen by setting
REGEN_CURRENT_MAX_VALUE 0L
And release throttle/press brake lever - motor (I checked, securing only the motor on the table, not in the wheel) will slow down for a long time, but it will not stop completely even in 10 seconds.
The same situation when you press the brake lever. This is fraught with breakdowns gears during emergency braking. And yes, other controllers (include KT original firmware) instantly (1sec.) stop the rotation of the motor when the brake is pressed or the throttle is released - without using regen. And it is right.
 
Hi all, new here and looking for some direction. So I'm building a ~3-4kW peak BHT style mid drive direct drive ebike and am hoping to use a KT controller with this firmware, however I am not sure what kind of phase amps I could squeeze out of it.

My goals would require about 120A phase Amps. I see the Nucular controllers from Vasili can do 120A with 12 fets, so I am assuming a KT 18 fet might be able to stretch it to 120A?

Cheers
 
@kkm: feel free to implement all your suggested improvements in our code and present us your result here in the thread. :D
Perhaps on your way you will learn how a PI-control works and why it makes no sense to test the system with no load / wheel in the air.

regards
stancecoke
 
j bjork said:
I tried 215 motor angle, but it cogged badly and blew the fuse. So I think I have to go higer, it behaved better at about 230 where I was before.

@j bjork, I've just remembered that I had similar issues to this (cogging, blown fuse, etc) when I had the 'Gain I' factor of the PI controller set too high. I found reducing this to 0.1 (from the default 0.2) cured this issue for me. Not sure if it has anything to do with your problem but easy to test, so maybe worth a try..?
 
MercyFlush said:
Hi all, new here and looking for some direction. So I'm building a ~3-4kW peak BHT style mid drive direct drive ebike and am hoping to use a KT controller with this firmware, however I am not sure what kind of phase amps I could squeeze out of it.

My goals would require about 120A phase Amps. I see the Nucular controllers from Vasili can do 120A with 12 fets, so I am assuming a KT 18 fet might be able to stretch it to 120A?

Cheers

I have set my 18fet for 120 phase amps. But I don´t know if I get it, or if it works. Btw. nuculars 12 fet does 200 phase amps, and 120 battery amps. I have only set 50 battery amps, my battery can´t handle much more.

It does´nt look too hard to beef up the controller board with some copper wire, and there are extra holes for wires to the motor and power wires. So it would be easy to run double wires, or beefier wires and split them in to 2 holes. There are room for one more, and bigger capacitors on the bord too. If you want to go for more amps I mean :wink:

Others seem to not have much luck with changing to better mosfets from what I have read though.
 
casainho said:
Marv1337n said:
Thanks to both of you, really appreciated. :thumb:
Do you know what the normal ratio is on a stock controller? Or is it different on each one?
I really want to know how much phase current my stock 60V 45A KT controller has.
You should ask to Kunteng and then configure that value on the firmware. Also please share with us the answer from Kunteng.

I've just got an answer from them, either they didn't understand me or they don't know it lol.
Hi,
Glad to receive your email, we are dealer of KT company,
45A is the max current of the controller, but for the motor we know little, we never measure the current of the motor, if you want to know the motor, may be the motor supplier will give you a better answer, thanks

Regards
Gene
 
Today I added a disgusting, stupid code (my C # knowledge is close to zero) in main.c to protect against an emergency - when the gas knob is accidentally pressed when the controller is turned on, or the hall sensor in the gas knob burned (4.3-5V on the control pin in this case)
Code:
main.c
 
display_init();
#endif
//
while (ui8_adc_read_throttle() >= ADC_THROTTLE_MIN_VALUE);
It would be a great idea to add the indication ui16_error "Err 01" (0x22) to KT-LCD3, but my knowledge is not enough.

during the tests, the motor suddenly stopped responding to the throttle (only showed an increase in power on the KT-LCD3 display), then the smell of burning insulation on the phase wires began to be felt ...The reason is the accidental disconnection of the hall sensor connector from the motor. In the “old good” casainho code, this problem was solved:
Code:
ebike_app.c

 case EBIKE_APP_STATE_MOTOR_STARTUP:
 if (ui8_motor_startup_counter++ >= 30) // 30 * 100ms; 3 seconds max time
 {
   motor_controller_set_state (MOTOR_CONTROLLER_STATE_MOTOR_BLOCKED);
   motor_disable_PWM ();
   ebike_app_set_error (EBIKE_APP_ERROR_06_SHORT_CIRCUIT);
   ebike_app_cruise_control_stop ();
   ui8_ebike_app_state = EBIKE_APP_STATE_MOTOR_COOL;
   break;
 }

But with my "knowledge" it is difficult to implement this necessary code in a new firmware. :(

Today also uncomment line in main.c
// pwm_set_duty_cycle ((uint8_t) ui16_sum_throttle);
(and commented out the previous one) and made a test trip ... This is amazing. Perfectly. I can ride stable on a dirty, skid unpaved road at a speed of 4-8 km/h, and the bike does not slow down, or the rear wheel does not start to slip and rotate quickly. I was happy.
But there is a problem - in this mode there is no reaction to pressing the brake (if the throttle is not released), as in "current mode". And it is very disappointing ....
 
stancecoke said:
apple2 said:
I've looked at the svm table and I am wondering what tool is used to generate it?
Also would it be more efficient to disable pwm on the low phase?

There are several approaches how to calculate the SVPWM pattern.
You can't switch off any channel as we are using center aligned PWM. Zero in the lookup table does not mean zero DutyCycle on the phase wire. Look at the figure 31 of ST's User Manual 1052.

Glad to hear, that you are happy with our firmware :D

regards
stancecoke

Ok, I read the document and although I didn't understand all of it it seems that all phases are centered around 50% duty cycle when the commanded duty is 0. Is there any good reason behind this?
I actually tried changing this so that 0 duty is actually 0 duty on the phase and the controller seems to work fine. That way 1/3 of the mosfets are not switching which should increase efficiency... I have tested this on a 6 fet (because I didn't want to mess up my 18fet) and tried it up to 20A and works ok. So I have ben getting good results from the firmware on both 6 fet and 18fet. The pwm off when idle feature also works fine although its mentioned as experimental.

Another thing I tried is decreasing the dead time (from 16 to 8) which happily didn't cause burnt mosfets but caused something strange that I have no explanation for: the duty cycle (setpoint) never drops below 20 even with no torque request and throttle at 0. Requested current and actual current values are both 0 (or -0.1) so I don't see where that duty is coming from. The wheel is actually rotating slowly.. until I stop it with the brakes and duty goes to 0. Then after the next throttle application it is stuck at 20. I am only using throttle and no pas or torque sensor. Any ideas why that could be happening or how to debug?
 
apple2 said:
stancecoke said:
apple2 said:
I've looked at the svm table and I am wondering what tool is used to generate it?
Also would it be more efficient to disable pwm on the low phase?

There are several approaches how to calculate the SVPWM pattern.
You can't switch off any channel as we are using center aligned PWM. Zero in the lookup table does not mean zero DutyCycle on the phase wire. Look at the figure 31 of ST's User Manual 1052.

Glad to hear, that you are happy with our firmware :D

regards
stancecoke

Ok, I read the document and although I didn't understand all of it it seems that all phases are centered around 50% duty cycle when the commanded duty is 0. Is there any good reason behind this?
I actually tried changing this so that 0 duty is actually 0 duty on the phase and the controller seems to work fine. That way 1/3 of the mosfets are not switching which should increase efficiency... I have tested this on a 6 fet (because I didn't want to mess up my 18fet) and tried it up to 20A and works ok. So I have ben getting good results from the firmware on both 6 fet and 18fet. The pwm off when idle feature also works fine although its mentioned as experimental.

Another thing I tried is decreasing the dead time (from 16 to 8) which happily didn't cause burnt mosfets but caused something strange that I have no explanation for: the duty cycle (setpoint) never drops below 20 even with no torque request and throttle at 0. Requested current and actual current values are both 0 (or -0.1) so I don't see where that duty is coming from. The wheel is actually rotating slowly.. until I stop it with the brakes and duty goes to 0. Then after the next throttle application it is stuck at 20. I am only using throttle and no pas or torque sensor. Any ideas why that could be happening or how to debug?
Read all the tecnhical information here: https://opensourceebikefirmware.bitbucket.io/development/

https://opensourceebikefirmware.bitbucket.io/development/Motor_control--FOC--Shane_Colton_documentation_and_firmware.html
 
kkm said:
Today also uncomment line in main.c
// pwm_set_duty_cycle ((uint8_t) ui16_sum_throttle);

You are really brave :shock: With this you put the throttle input directly to the PWM. With no safety feature like battery- or phase current limitation active....

regards
stancecoke
 
j bjork said:
Interesting, it seems like we have a very simular setup apple2.

But some settings are very different, I have battery current 500 (as I understood in the instructions should mean 50A) and battery voltage cal 70.
Did you have to swap any phase or hall wires with the new firmware?

For me the bluosec app freezes all the time, so I don´t really get any live numbers. I can mostly try to have the bike running stedy for a while, and then look at the values after some time.

Hello at all,

i have a simmular setup with a 1000W 48V 28inch rear hub and the KT36/48 6 FET 10A Controller with the custom firrmware.
At the moment i have only a KT-LCD3 Display, but i habe ordered a bluetooth modul and a 5V DC voltage regulators.

Can you send me your config ini from the java tool. So, that i have a base for my settings.

At the moment the drive is running smooth, but it is pulsing very strong to the max speed then stop and start again. Also the controller will be handwarm after 2 or 3 Minutes run. My second Kt36/48 with the original firmware is cold after 5 Minutes.

best regards
Sascha
 
You guys may be interested, as seems we may have a Bluetooth LCD that is small, "cheap" and flexible:

casainho said:
Tiny LCD with bluetooh

PSWPower is selling the SW102 LCD for Bafang that seems a version of the eggrider LCD, for 45€. Seems a decent price.

Eggrider seems to use a Nordic microcontroller that includes Bluetooth.

SW102 listing on PSWPower and other online shops on aliexpress never mention Bluetooth but I found only a listing saying:

At present, this display does not have bluetooth function. If the bluetooth function is needed, it can only be customized with a batch order

Since they use a Nordic microcontroller that includes Bluetooth, I guess all this LCDs supports Bluetooth but it may be disabled/not implemented in firmware on some models.

I am being developing firmware for another ebike LCD (commercial project, not OpenSource) that uses Nordic microcontroller with Bluetooth, so I am familiar with this systems. They support the ARM GCC compiler, so would be more or less easy for me to develop for this LCD.

But the programming using bootloader on this LCD should be locked like on 850C so I think the only option is open the LCD and try solder the programming wires... let's see if is possible... I just bought 1 unit from PSWPower and should take 2 weeks to arrive.

This LCD has some characteristics many has being asking:
- small size
- Bluetooth
- cheap/medium price

Let's see if we can program it....

HTB1cjYbX2vsK1Rjy0Fiq6zwtXXaS.jpg
 
sascha121985
I don´t think my setup is much use for you, I have an 18fet controller and my setup does´nt really work very good.
I have violent cogging if I´m not very gentle at the trottle until I am up at maby 20km/h.

It is nice weather here today, and I was able to test outside. That is how I noticed it seems to be ok at speed. It was a bit weak, but it was only using about 25A. I set the batt amp value to 500, but it seems to have changed itself to 244. Changing PID Gain I to 0.1 did not seem to make much differens.( on the cogging)

If you still want my settings, I presented them a page or 2 back
 
@j bjork

Thanks for your answer. I found your setting 2 pages before.
You write there, that you have no function with the KT-LCD3. Did you solve this problem?
I have the same issue. Only the voltages is displayed. No Battery Symbol,.. and the assistant value has no effect.


@apple2

Are you happy with your settings for the 6fet controller?
Can you share them?

best regards
Sascha
 
No, I don´t know anything about programming. So I have no idea where to start to solve that problem.

I tried to use casainho:s fw yesterday, it seems to write, but there did not seem to be any differens. It still ran about the same, LCD3 did not work and so on.
Then I tried to just use the erase original fw on that tool, but the motor still ran after. So I guess it did not work. I don`t know if I can´t have both on the computer at the same time or something?
 
@sascha

the settings are basically what the wiki says..

Untitled.jpg


The max current is a bit high and goes >20A at max throttle, when the controller is rated at 17A peak..
If you experience push- pull, or other "instability" try lowering the undervoltage limit, raising the phase current limit, and raising the speed limits to make sure you are not hitting any of these "restrictions".
Also to test different motor angles, what I do is disable angle correction and try starting from standstill (not at full throttle) and check how much cogging I get.. then change and try again, no need to get up to speed because the motor angle related cogging is most evident at start. Once you get smooth starts, reenable angle correction and it should change the angle automatically when it picks up speed.. thats good and you shouldn't change the motor angle any more trying to match anything..
 
Back
Top