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

Electric Motors and Controllers
casainho   100 MW

100 MW
Posts: 2802
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 » Jun 15 2018 7:43am

stancecoke wrote:
Jun 15 2018 5:55am
Hmm, still you have no chance for a second try or to put in the code after first braking. You have to switch off/on the system each time, for a new try :-(
Why do you use all the constants?! The simple numbering was much easier to follow....
I think should be very easy to enter on the offroad mode by mistake. I changed to: once throttle or PAS are active for the first time, don't check anymore for offroad mode.

Constants because the numbering is fast to change when I need to change that number on all the code, which I had a few times. Also with a good name should make more clear what that state means.
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: 926
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 » Jun 15 2018 8:14am

Hm, that's not my prefered solution, as you have to stop, swtich off, switch on try to morse, fail, switch off, switch on, try again..... It is quite difficult to find the right rythm and I see no danger to activate the offroad-mode randomly...

But no problem, it's easy for me to modify it in the way I like :-)

regards
stancecoke

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 15 2018 8:31am

stancecoke wrote:
Jun 15 2018 8:14am
Hm, that's not my prefered solution, as you have to stop, swtich off, switch on try to morse, fail, switch off, switch on, try again..... It is quite difficult to find the right rythm and I see no danger to activate the offroad-mode randomly...
I see, the issue is that we don't have an indication for user that offroad mode was activated. If we had, would then be ok for you? If so, how it would be? Maybe motor accelerating to max power full speed? :-)
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: 926
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 » Jun 15 2018 9:09am

Hm, I would prefer to activate the offroad mode while riding, without the need of switching off/on the system.
As feedback for the user, we could set the speed-display to 99km/h for three seconds e.g.

regards
stancecoke

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 15 2018 1:06pm

Something good I achieved: our firmware on LCD3 + our firmware on TSDZ2 motor controller, where we can defined max power on LCD:
casainho wrote:
Jun 15 2018 1:03pm
Done!! Although there is a bit of oscillation on the wheel and power that I wans't expecting, anyway, very good for the first iteration.

The throttle at my left hand was always at max position. My lab power supply was setup for 45V and it can't give much more than 5 amps, so max power could not be more than 225W, that is why I didn't tested with a higher value.

So, on LCD I was setting the target max power (when we see the value blinking and I increase/decrease in steps of 50) and the throttle was at full/max position, although as we can see, the firmware on the motor controller controls the motor current and hence the motor power in a way the power don't pass (to much) the defined max value:

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.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Jun 15 2018 3:49pm

stancecoke wrote:
Jun 15 2018 8:14am
Hm, that's not my prefered solution, as you have to stop, swtich off, switch on try to morse, fail, switch off, switch on, try again..... It is quite difficult to find the right rythm
Why not 5 really fast clicks on the lever, even while running, (you cant accidentaly hit the lever 5 times so fast) then when active show 99 and when not show 25 or whats set..

This is much faster way and you will not fail to activate.

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 16 2018 2:52am

honya96 wrote:
Jun 15 2018 3:49pm
Why not 5 really fast clicks on the lever,
Good idea! Very easy to program. But you will loose the possibility to define you own individual morse-code...
Is anyone seriously interested in using it in this way?

regards
stancecoke

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 16 2018 3:37am

stancecoke wrote:
Jun 16 2018 2:52am
honya96 wrote:
Jun 15 2018 3:49pm
Why not 5 really fast clicks on the lever,
Good idea! Very easy to program. But you will loose the possibility to define you own individual morse-code...
Is anyone seriously interested in using it in this way?
I also prefer that way, because I think must be something hard to change the state and not happen by mistake.
I also like the idea of showing the 99km/h for some seconds when offroad mode is activated and maybe 25km/h when it is deactivated.

Also, there is a state machine on the firmware to detect when ebike is stopped (wheel is stopped) and I think is a good idea to putor call there this piece, so the offroad state can be changed only with ebike stopped.

Do you want to implement that Stancecoke? If so, please try using the switch case as is better to understand than a big number of ifs.
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.

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 » Jun 16 2018 3:46am

honya96 wrote:
Jun 15 2018 3:49pm
Why not 5 really fast clicks on the lever, even while running, (you cant accidentaly hit the lever 5 times so fast) then when active show 99 and when not show 25 or whats set..

This is much faster way and you will not fail to activate.
This seems a good method, and at this time will probably be good enough for our purposes.

I think however, when the authorities get serious about checking ebikes they will soon get wise to possible 'cheat' systems. A simple system like this may be a little too easy to uncover, so stancecoke's method of a selectable code may be a better long term solution....?
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 16 2018 5:31am

casainho wrote:
Jun 16 2018 3:37am
Do you want to implement that Stancecoke? If so, please try using the switch case as is better to understand than a big number of ifs.
In this case, with no individual durations of the morse code, there is no need for a switch case, it's just counting up one variable in one if-structure...
But as geofft wrote: Is that way of activating the offroad-mode too easy?!

regards
stancecoke

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 16 2018 6:03am

stancecoke wrote:
Jun 16 2018 5:31am
casainho wrote:
Jun 16 2018 3:37am
Do you want to implement that Stancecoke? If so, please try using the switch case as is better to understand than a big number of ifs.
In this case, with no individual durations of the morse code, there is no need for a switch case, it's just counting up one variable in one if-structure...
But as geofft wrote: Is that way of activating the offroad-mode too easy?!
I see the implementation as being the same as previous but now with 5 steps and the time between them much more short. And if so, will still be customizeable, so we can get the best of both worlds.
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: 926
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 » Jun 16 2018 7:23am

Hm, but then we can keep the three steps, that's diffcult enough to hit....
Or we take more steps, but increase the tolerance, it's half a second recently.

regards
stancecoke

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 16 2018 7:34am

stancecoke wrote:
Jun 16 2018 7:23am
Hm, but then we can keep the three steps, that's diffcult enough to hit....
Or we take more steps, but increase the tolerance, it's half a second recently.
3 steps are few to me, as when I am waiting stopped on a cross section of the road, I always have my hand at brakes and sometimes I hesitate to start so I hit brakes a few time in sequence, but not very fast sequence - I really like the idea of being fast and long sequence.
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.

John in CR   100 GW

100 GW
Posts: 13535
Joined: May 20 2008 12:58am
Location: Paradise

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

Post by John in CR » Jun 16 2018 7:46am

On the street I often hit the brake lever 3 times quickly when I see cars in front stopping hard. That's because I use brake lights and want to signal to cars behind. 5 times is a far better sequence for switching mode.

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 16 2018 7:48am

So, we can make the duration of 5 steps and the tolerance user-settable.

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 » Jun 16 2018 8:50am

stancecoke wrote:
Jun 16 2018 7:48am
So, we can make the duration of 5 steps and the tolerance user-settable.

regards
stancecoke
Seems fine to me, I can comfortably make 5 operations in about 2 seconds, so user selectable 1.5 - 3.0 seconds should do the trick..
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 16 2018 2:03pm

I've pushed the 5-step-version to a new branch now.
https://github.com/OpenSource-EBike-fir ... ode_5_step

I left the initial values for the step-durations at one second. The tolerance is now settable in the main.h. It is set to 0.8s now.

You can start the code at any time. To make sure, to begin from the start, pull the lever for a few seconds first.

I'll try it in hardware tomorrow.

regards
stancecoke

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 17 2018 7:42am

I've tested it on the workbench now. It works :-)
I've added print commands to each step temporaribly to show the progress at the screen.
If the speed limit is really disabled on a real ride is not tested yet...



regards
stancecoke

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 17 2018 8:22am

stancecoke wrote:
Jun 17 2018 7:42am
I've tested it on the workbench now. It works :-)
Good!! And maybe you can try finish the feature, by adding the feedback to user. Maybe showing a specific velocity is hard becaise it depends on wheel size, etc. Much more simple is to use signal using the brake symbol on LCD - an idea is to make it flash, and it wound be to use a counter variable, maybe even expanding the switch structure to add this.
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.

-dg   1 kW

1 kW
Posts: 454
Joined: Jun 01 2012 4:38am
Location: Oakland, CA USA

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

Post by -dg » Jun 17 2018 8:28am

stancecoke wrote:
Jun 15 2018 1:55am
We should use the value that's defined by the user on the LCD. I think in US the legal limit is 20mph (32km/h).
In California there are 3 classes of electric bicyle plus motorized bicyles and mopeds. The electric bike rules that are interesting are classes 1&2 vs class 3. Classes 1&2 are limited to 20 mph. Class 3 permits assist up to 28mph provided the rider is pedaling and the assist is pedal activated.
If simplicity worked, the world would be overrun with insects.

casainho   100 MW

100 MW
Posts: 2802
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 » Jun 17 2018 8:37am

-dg wrote:
Jun 17 2018 8:28am
stancecoke wrote:
Jun 15 2018 1:55am
We should use the value that's defined by the user on the LCD. I think in US the legal limit is 20mph (32km/h).
In California there are 3 classes of electric bicyle plus motorized bicyles and mopeds. The electric bike rules that are interesting are classes 1&2 vs class 3. Classes 1&2 are limited to 20 mph. Class 3 permits assist up to 28mph provided the rider is pedaling and the assist is pedal activated.
Well, maybe we are doing a kind of redundancy because user already can define max speed on LCD and is relatively fast for user to do it.

Even the motor power can be changed on LCD.
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: 926
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 » Jun 17 2018 10:11am

casainho wrote:
Jun 17 2018 8:22am
And maybe you can try finish the feature, by adding the feedback to user.
I've added a confirmation signal now. The display shows something about 80 km/h for three seconds, if the morse code was correct. The shown velocity differs due to the chosen wheel circumference, but I think that doesn't matter.

I can't test this in hardware, as I have no LCD3, perhaps someone else can try!
And we have to comment out the print commands :wink:

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 » Jun 18 2018 11:47am

stancecoke wrote:
Jun 17 2018 10:11am
casainho wrote:
Jun 17 2018 8:22am
And maybe you can try finish the feature, by adding the feedback to user.
I've added a confirmation signal now. The display shows something about 80 km/h for three seconds, if the morse code was correct. The shown velocity differs due to the chosen wheel circumference, but I think that doesn't matter.

I can't test this in hardware, as I have no LCD3, perhaps someone else can try!
And we have to comment out the print commands :wink:

regards
stancecoke
Just tried this in the garage (not on road) but can't get any display indication of offroad mode being triggered.
Sorry to be dumb but I'm not quite sure what I should be inputting via the brake lever to trigger this - could you just clarify the precise sequence needed, 5 quick operations doesn't seem to work for me.... :(
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 18 2018 12:46pm

You have to "morse" in the same way as in the video, one second for each step. You can change the duration for each step in the main.h
The value is in 0.1s steps, "10" means one second.

Code: Select all

#define OFFROAD_TIME_1 10	//duration of first pull of break lever
#define OFFROAD_TIME_2 10	//duration of first release
#define OFFROAD_TIME_3 10	//duration of second pull
#define OFFROAD_TIME_4 10	//duration of second release
#define OFFROAD_TIME_5 10	//duration of third pull
regards
stancecoke

User avatar
stancecoke   10 kW

10 kW
Posts: 926
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 » Jun 19 2018 6:36am

for the improvement of the commutation implementation it is useful to have a look at the code of the VESC perhaps. I had a short look at it, but I think it would take some days to understand the firmware structure.
- Sensored and sensorless FOC wich auto-detection of all motor parameters is implemented since FW 2.3.
- When the current limits are hit, a soft back-off strategy is used while the motor keeps running. If the current becomes way too high, the motor is switched off completely.
- The RPM limit also has a soft back-off strategy.
- Commutation works perfectly even when the speed of the motor changes rapidly. This is due to the fact that the magnetic flux is integrated after the zero crossing instead of adding a delay based on the previous speed.
- When the motor is rotating while the controller is off, the commutations and the direction are tracked. The duty-cycle to get the same speed is also calculated. This is to get a smooth start when the motor is already spinning.
Of course there are some differences in the hardware, especially the phase current sensors, but the "auto-detection of all motor parameters" sounds very interesting...

regards
stancecoke

Post Reply