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   10 kW

10 kW
Posts: 946
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 » Feb 05 2019 5:41am

keep the correction (at) angle at 127. Play around with the motor specific angle. Sorry the function of correction (at) angle is not dokumented in the wiki yet.

regards
stancecoke
Last edited by stancecoke on Feb 07 2019 2:47am, edited 1 time in total.

j bjork   100 W

100 W
Posts: 108
Joined: Aug 31 2018 3:01pm
Location: Linköping, Sweden

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

Post by j bjork » Feb 06 2019 1:20am

Thanks. I will try to play around with that some more, but so far not much luck. In the 170:s the wheel is stuck. I beleve I ended up in the 230:s, then I had very low correction angle.
But the bike behaves rather strange. If I pull the throttle it can take off ok, but then start to cogg badly. Sometimes there is no reaction to throttle, on maby the third try it reacts. But then it does not react to the release of trottle ither, I have to keep it still with the brakes for a few seconds.


User avatar
Marv1337n   1 W

1 W
Posts: 54
Joined: Jul 07 2018 5:16am
Location: Germany

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

Post by Marv1337n » Feb 07 2019 3:38am

Figured I ask here because I guess the developers of this firmware knows this best.
Does the standard KT controllers come with a higher Phase Amps than Battery Amps? e.g. 45A from the Battery but 70A goes to the motor?

User avatar
stancecoke   10 kW

10 kW
Posts: 946
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 » Feb 07 2019 3:27pm

Marv1337n wrote:
Feb 07 2019 3:38am
Does the standard KT controllers come with a higher Phase Amps than Battery Amps?
This is not Kunteng specific, but normal behaviour of any controller, that uses pulse width modulation for driving the motor.

Code: Select all

Iphase = Ibattery/duty cycle
regards
stancecoke

casainho   100 MW

100 MW
Posts: 2868
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 » Feb 07 2019 3:33pm

Marv1337n wrote:
Feb 07 2019 3:38am
POST A REPLY

Post icon:
None
Subject:

Re: KT motor controllers -- Flexible OpenSource firmware for BMSBattery S/Kunteng KT motor controllers (0.25kW up to 5kW
| |
Smilies
:bigthumb: :thumb: :es: :kff: :lowbatt: :bolt: :flame: :warn: :banana:
Figured I ask here because I guess the developers of this firmware knows this best.
Does the standard KT controllers come with a higher Phase Amps than Battery Amps? e.g. 45A from the Battery but 70A goes to the motor?
I think you mean a limiter for both type of currents. Yes, Kunteng hardware permits that limit and my code does that, even because I think we should limit motor/phase current to protect the controller. I think Stancecoke code does not implement this limit.

Here is the configuration on config.h file:

Code: Select all

// *************************************************************************** //
// MOTOR CONTROLLER

// Choose your controller max current and max regen current
//
// S06S controller holds 15 amps as max current
#define ADC_MOTOR_CURRENT_MAX		43 // each unit = 0.35A; 43 = 15A (tested on S06S motor controller)
#define ADC_MOTOR_REGEN_CURRENT_MAX	28 // CAN'T be more than 66 units!! each unit = 0.35A; 20 = 10A but the brake/regen must be only for a few seconds!!

// *************************************************************************** //
// BATTERY

#define ADC_BATTERY_CURRENT_MAX		42 // each unit = 0.35A | in this example, 42 * 0.35 ~= 15 amps
#define ADC_BATTERY_REGEN_CURRENT_MAX	5 // CAN'T be more than 66 units!! each unit = 0.35A
Here is the piece of code that implements that:

Code: Select all

/****************************************************************************/
  // PWM duty_cycle controller:
  // - limit battery overvoltage
  // - limit battery undervoltage
  // - limit battery max current
  // - limit battery max regen current
  // - limit motor max current
  // - limit motor max regen current
  // - limit motor max ERPS
  // - ramp up/down PWM duty_cycle value

  if ((UI8_ADC_BATTERY_CURRENT > ui8_adc_target_battery_current_max) || // battery max current, reduce duty_cycle
      (ui8_adc_motor_current > ui8_adc_target_motor_current_max) || // motor max current, reduce duty_cycle
      (ui16_motor_speed_erps > MOTOR_OVER_SPEED_ERPS) || // motor speed over max ERPS, reduce duty_cycle
      (UI8_ADC_BATTERY_VOLTAGE < ((uint8_t) ADC_BATTERY_VOLTAGE_MIN))) // battery voltage under min voltage, reduce duty_cycle
  {
    if (ui8_duty_cycle > 0)
    {
      ui8_duty_cycle--;
    }
  }
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
stancecoke   10 kW

10 kW
Posts: 946
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 » Feb 08 2019 1:13am

casainho wrote:
Feb 07 2019 3:33pm
I think Stancecoke code does not implement this limit.
Sorry, you are not up to date, the phase current limitation is implemented since several month :D

regards
stancecoke

casainho   100 MW

100 MW
Posts: 2868
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 » Feb 08 2019 2:55am

stancecoke wrote:
Feb 08 2019 1:13am
casainho wrote:
Feb 07 2019 3:33pm
I think Stancecoke code does not implement this limit.
Sorry, you are not up to date, the phase current limitation is implemented since several month :D

regards
stancecoke
Sorry, I remember now. I remember that you did implement like I did on TSDZ2 firmware.
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
Marv1337n   1 W

1 W
Posts: 54
Joined: Jul 07 2018 5:16am
Location: Germany

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

Post by Marv1337n » Feb 08 2019 11:51am

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.

casainho   100 MW

100 MW
Posts: 2868
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 » Feb 08 2019 11:53am

Marv1337n wrote:
Feb 08 2019 11:51am
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.
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
Marv1337n   1 W

1 W
Posts: 54
Joined: Jul 07 2018 5:16am
Location: Germany

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

Post by Marv1337n » Feb 08 2019 11:58am

casainho wrote:
Feb 08 2019 11:53am
Marv1337n wrote:
Feb 08 2019 11:51am
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.

apple2   100 µW

100 µW
Posts: 8
Joined: Mar 28 2016 8:08am

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

Post by apple2 » Feb 09 2019 7:33am

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?
Image

j bjork   100 W

100 W
Posts: 108
Joined: Aug 31 2018 3:01pm
Location: Linköping, Sweden

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

Post by j bjork » Feb 09 2019 8:26am

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.

apple2   100 µW

100 µW
Posts: 8
Joined: Mar 28 2016 8:08am

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

Post by apple2 » Feb 09 2019 1:34pm

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..

j bjork   100 W

100 W
Posts: 108
Joined: Aug 31 2018 3:01pm
Location: Linköping, Sweden

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

Post by j bjork » Feb 09 2019 3:25pm

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.

User avatar
stancecoke   10 kW

10 kW
Posts: 946
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 » Feb 09 2019 4:02pm

apple2 wrote:
Feb 09 2019 7:33am
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

kkm   10 µW

10 µW
Posts: 6
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 » Feb 09 2019 6:29pm

stancecoke wrote:
Jan 23 2019 1:55pm
j bjork wrote:
Jan 23 2019 11:49am
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.

MercyFlush   1 µW

1 µW
Posts: 1
Joined: Dec 30 2018 1:27am

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

Post by MercyFlush » Feb 10 2019 3:22am

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

User avatar
stancecoke   10 kW

10 kW
Posts: 946
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 » Feb 10 2019 4:39am

@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

geofft   1 kW

1 kW
Posts: 324
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 » Feb 10 2019 6:09am

j bjork wrote:
Feb 09 2019 3:25pm
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..?
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

j bjork   100 W

100 W
Posts: 108
Joined: Aug 31 2018 3:01pm
Location: Linköping, Sweden

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

Post by j bjork » Feb 10 2019 12:00pm

geofft: absolutly, I will give that a try. Thank you.
I have only been adjusting the angles so far, I thougt I should be able to get it running smooth before fine tuning other settings.

j bjork   100 W

100 W
Posts: 108
Joined: Aug 31 2018 3:01pm
Location: Linköping, Sweden

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

Post by j bjork » Feb 10 2019 1:02pm

MercyFlush wrote:
Feb 10 2019 3:22am
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.

User avatar
Marv1337n   1 W

1 W
Posts: 54
Joined: Jul 07 2018 5:16am
Location: Germany

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

Post by Marv1337n » Feb 12 2019 9:41am

casainho wrote:
Feb 08 2019 11:53am
Marv1337n wrote:
Feb 08 2019 11:51am
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

kkm   10 µW

10 µW
Posts: 6
Joined: Sep 27 2018 3:22pm

Re: OpenSource firmware BMSBattery Sxxx/Kuteng controllers S

Post by kkm » Feb 12 2019 12:30pm

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: Select all

 
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: Select all

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 ....

apple2   100 µW

100 µW
Posts: 8
Joined: Mar 28 2016 8:08am

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

Post by apple2 » Feb 12 2019 5:29pm

stancecoke wrote:
Feb 09 2019 4:02pm
apple2 wrote:
Feb 09 2019 7:33am
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?

Post Reply