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

Electric Motors and Controllers
casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery Sxxx/Kuteng controllers S

Post by casainho » Jun 19 2017 1:17pm

Blue line: hall sensor signal.
Yellow line: phase B current signal.
The next series of screenshots were taken with motor at different speeds, starting at motor low speed up to max speed.

I was expecting to have a sinusoidal current waveform... anyway, as we can see, there is a synchronization between both signals - and they need to be so we can have the motor best efficiency.
Image

Image

Image

I didn't measured yet the lack of phase, but I know it changes with dynamic variables: motor current and motor speed. And fixed variables: motor coils resistance and inductance.

Image
(in Shane Colton documentation)

For the screenshots, I think the algorithm can be like looking at current max or min value and will be the time where current vector I is - then I need to adjust the timing of motor voltage I already prepare, to displace the I vector 90 degres over rotor flux (yellow vector on the picture). Let's see if I can do it and have good results....

Image
(in Shane Colton documentation)
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.

Njay   10 kW

10 kW
Posts: 836
Joined: Sep 09 2010 10:43am
Location: Portugal

Re: OpenSource firmware BMSBattery Sxxx/Kuteng controllers S

Post by Njay » Jun 20 2017 12:20pm

Nice work :)! I see you keep on loving motor control stuff :D

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery Sxxx/Kuteng controllers S

Post by casainho » Jun 20 2017 12:47pm

Njay wrote:Nice work :)! I see you keep on loving motor control stuff :D
Thanks!! :-)
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
parabellum   10 MW

10 MW
Posts: 2067
Joined: Nov 19 2010 9:55am
Location: Dominican Republic, north.

Re: OpenSource firmware BMSBattery Sxxx/Kuteng controllers S

Post by parabellum » Jun 20 2017 2:57pm

Cool stuff. Subscribed! :)

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery Sxxx/Kuteng controllers S

Post by casainho » Jun 21 2017 5:05am

I quit the try to have phase current at 90º -- there is no processing power available. I am pretty sure the original firmware also don't implement such feature. I will move on to the other features. Anyway, the code for my tries is on a specific branch that can be visited later: https://github.com/OpenSource-EBike-fir ... le_control
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.

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 21 2017 11:44am

Just implemented cruise control and also brakes activation cancel cruise control as expected.
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.

Njay   10 kW

10 kW
Posts: 836
Joined: Sep 09 2010 10:43am
Location: Portugal

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by Njay » Jun 21 2017 1:57pm

I was looking at your map() and I have a great integer calculation coding tip for you :D

When doing integer divides you should round the result to the nearest value. The integer division always drops the fractional part, which means for example that if both x and y are integer values and x / y = 1.9999, then x div y = 1 when the closest result is 2. As a simple implementation example, if your numbers are all positive, you can do (x + y/2) / y .

I don't know if this will actually have any relevant impact on your application, but I can assure you that in computer graphics and sound, it does have. It introduces a kind of a "sudden step" in the results that are visible/audible.

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 21 2017 2:28pm

I did borrow the map() from stackexchange and shame on me because I didn't saves the link reference.

Are you interested in participating in the 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.

Njay   10 kW

10 kW
Posts: 836
Joined: Sep 09 2010 10:43am
Location: Portugal

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by Njay » Jun 21 2017 6:20pm

No thanks, already have a full dish :)

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 22 2017 9:25am

casainho wrote:Just implemented cruise control and also brakes activation cancel cruise control as expected.
Forgot to say that cruise control I implemented is like the one on 1st Gen KU63 controllers and not like on S controllers.

What I implemented:
- user need to keep throttle at a constant position during 5 seconds; after this time enters in cruise control mode that will maintain the same throttle value while the user can release the throttle to the default position (zero value)
- cruise control mode will exit when the user brake or when the user increase the throttle

The original firmware S series controller cruise control will start only when the user press holds the DOWN button on the LCD -- this seems less practical than the way 1st Gen KU63 controllers does.
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.

Steu851   1 mW

1 mW
Posts: 13
Joined: Nov 07 2016 10:52am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by Steu851 » Jun 22 2017 1:41pm

What about PAS sensor? Is it in the plan? Trottle is not legal in Europe.

Sent usingTapatalk

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 23 2017 4:12am

Steu851 wrote:What about PAS sensor? Is it in the plan? Trottle is not legal in Europe.
I am not using PAS although I am in Europe. Do you want to use the firmware? If so I can add PAS because for now is not a priority -- throttle and cruise control is helpful for development and so I add it.

I just added a PAS to my little son ebike and tried it -- and works very well with this Gen2 conrollers.
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.

Steu851   1 mW

1 mW
Posts: 13
Joined: Nov 07 2016 10:52am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by Steu851 » Jun 23 2017 10:54am

There are some issues in original firmware, if I want a 100 % legal ebike using S06S in torque simulation mode, so if this firmware can solve them I'll try.
First issue is the speed limit parameter, it works only in speed gear mode, not in power gear mode (they call it torque simulation)
Power gear mode is much more natural, but sometime Police stop and check if trottle works without pedals and max speed.
And this is the second issue of original firmware, I can setup non zero startup for trottle, but once started I can run using only trottle, as a moped, without pedaling, and this is not legal, what I like is this: if I don't use trottle I have 5 power level, but limited to 25 km/h, as I use trottle, power is defined by trottle, but if pedals stop turning motor stop, and always with speed limit of 25 km/h.

Sorry for my english.

Sent usingTapatalk

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 23 2017 12:27pm

Steu851 wrote:There are some issues in original firmware, if I want a 100 % legal ebike using S06S in torque simulation mode, so if this firmware can solve them I'll try.
First issue is the speed limit parameter, it works only in speed gear mode, not in power gear mode (they call it torque simulation)
Power gear mode is much more natural, but sometime Police stop and check if trottle works without pedals and max speed.
And this is the second issue of original firmware, I can setup non zero startup for trottle, but once started I can run using only trottle, as a moped, without pedaling, and this is not legal, what I like is this: if I don't use trottle I have 5 power level, but limited to 25 km/h, as I use trottle, power is defined by trottle, but if pedals stop turning motor stop, and always with speed limit of 25 km/h.

Sorry for my english.

Sent usingTapatalk
Thanks!! So I know I need to work on these speed controller and current(torque) controller. Speed for user be able to limit max speed as original firmware and current control for that 5 levels of assistance/acceleration power.

Maybe cruise control for max speed as an alternative to original firmware cruise control power/torque... Well, never tried cruise control of original firmware - are you able to describe it??
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.

Steu851   1 mW

1 mW
Posts: 13
Joined: Nov 07 2016 10:52am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by Steu851 » Jun 23 2017 4:01pm

Sorry never used cruise control.
I believe I was not so clear in my description, what I would like to have is a configurable speed limiter, which work in every condition, even in torque mode or using trottle.

Sent usingTapatalk

nollkolltroll   1 µW

1 µW
Posts: 2
Joined: Jun 24 2017 10:50am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by nollkolltroll » Jun 24 2017 11:11am

First post to the forum, just had to register to encourage the development of this firmware.
I converted an old MTB about a month ago, and was lucky enough to get the S06S-controller that I really like. Even happier when I found this thread!
I care about open source, and would like to make some changes to the function of the original controller. Mainly acceleration profiles, that are too fast for my liking. Hopefully I can make some contributions. My plan is to get another controller after my vacation, so I can have one working and one for debugging.
It really is great to see how far this project has progressed in such a short time!

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 25 2017 8:45pm

Steu851 wrote:Sorry never used cruise control.
I believe I was not so clear in my description, what I would like to have is a configurable speed limiter, which work in every condition, even in torque mode or using trottle.
Ok, simple to understand now. Let's see what we will get.
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.

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 25 2017 8:48pm

nollkolltroll wrote:Hopefully I can make some contributions. My plan is to get another controller after my vacation, so I can have one working and one for debugging.
It really is great to see how far this project has progressed in such a short time!
Help on development is super welcome!!
Thanks.
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.

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 26 2017 6:40am

Working on measure phase B current for later use on motor current control loop.

The wave shape should be a sinewave but it is not a perfect one. When the motor is near max speed the shape is even worst but the bottom side keeps good so I decided to read the minimum value each cycle and consider that value. See the next images -- yellow line is the phase B current and blue line is a signal for debug. The current value is read once every PWM cycle and the value is compared to last one to see if is lower, this way to find the minimum value. Debug signal is enabled and disabled every time the new read value is lower and stops at the minimum value - it is also reseted every cycle.

Picture 1:
01.png
01.png (22.34 KiB) Viewed 3575 times
Picture 2:
02.png
02.png (22.9 KiB) Viewed 3575 times
For my measurements, I think the current sensor on S06S is ACS711KEXLT-15AB-T, that measures +-15.5 amps.

On picture 2, I tried to brake the motor with my hand. Voltage minimum is about 0.75v (subtracted from 2.5V that is 0 amps), that should translate to 4.65 amps peak and the RMS value (the one we should consider) should be 3.3 amps -- makes sense for me!!

Next step should be the make some filtering to this measure and clean up the code, so finally I can implement the current control loop.
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.

MisterMint   1 mW

1 mW
Posts: 19
Joined: Aug 12 2015 2:42am
Location: Germany

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by MisterMint » Jun 28 2017 9:21pm

Hi Casainho, great to see you digging into this deeper.
My BMS battery controller, lets call it S06S-B (for bottle) - I must say that its very silent and
powerful once I am driving faster than maybe 10 km/h with my Q100C 201RPM.
On lower speeds its sounds a bit nasty, pretty much like the spikes you observed
would sound when put on a speaker. Make sure to test under different loads,
in my experience the controllers seems to adapt somehow.Anyhow, not an expert.
From what I read you will do anyways.. :-)

Now my wishes - just in case chrismas comes sooner this year. They might be shared by others living in the EU. As you know we all suffer from stupid laws here. Some living in the southern EU countries may have more freedom as police has more important things to do than stopping fun loving criminals from breaking their own neck, but where i live they are pretty bored, thus they are very strict..

This really means:
-must not drive faster than 25kmh
-must not pull stronger than 1/4 old mule (shortly before its dying)
-must not drive without annoying (pseudo) pedaling
otherwise: punish!

What I did until now: Take this small motor, push overvolted 900W into it. No PAS, no break sensors, just pedal like stupid, go WOT and 40kmh where possible. Maybe slow a little and smile when they are watching. Works nice until hills get steep (building 2WD now) or worse -you get into a crash. Than it might become a big trouble...

As nobody likes trouble, it would be great if we had a firmware that would start in "street legal" mode, so throttle is only working up to 6 km/h unless some kind of pedaling is received (can be slow pedaling..) Maximum speed setting is set to value X and is respected even if throttle is pushed to the max..
Maximum Wattage is limited to Y (and is not overridden by throttle as its now). Cruise mode might be implemented but resets to zero after about 3 second without any pedaling (or on break sensors.for sure.)

Now: Just in case one would like to drive around private property with the bike, there could be a special "user code" one could enter (like a combo in playstation: up,up,up, pedal once, down,up,down..).
This sets the machine back to the "basic mode" explained above...(aka WOT). For limited time, 60 minutes would be fine I guess. Shortly hitting the power button, turning off the bike - or self power off after 15 min (not like 5 like its set now please..) resets back to "street legal" for sure. So one does not accidently keeps "basic mode" on after leaving private property... or some uneducated person tries the bike and gets injured because he expects it to be 1/4 mule that needs some kicking before it starts moving.. The code could be user defineable (in firmware by hex editor even?), so nobody accidently can activate "basic mode" on a bike he does not own. Less injuries, good thing!

Thats my two cents, it would raise the value of these controllers in EU alot. If there is better motor control algo, giving it more torque, more speed, keep it cooler and silent - that would actually make it pretty amazing. If you could connect two of these controllers via UART, as VESC does via CAN, (so without any LCD) so it can detect if front wheel is lifted and starts spinning up to a high speed to serve you a facepalm of death once its touching ground again, i would become a very, very happy munster. Or if you tell me to run it without LCD (they stole the one for my second controller).


Anyhow, the mule thing is really the most important one imho. :roll:

edit: this is the kit https://bmsbattery.com/controller/698-s ... results=32

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 29 2017 7:51am

MisterMint wrote:Hi Casainho, great to see you digging into this deeper.

Or if you tell me to run it without LCD (they stole the one for my second controller).
Thanks for your feedback. I am pretty sure there will be possible to have "standard mode" and "unlimited mode" and changing between them with some combination of inputs.

As for LCD, you should be able to use bluetooth instead. Just add a cheap serial/UART bluetooth module, that ones used on Arduino. Takes GND and +5volts from brake signal or such and wire the TX and RX line of the LCD connection. Then we just need to do an Android app to process and show the information as the original LCD -- the documentation for data structure to/from LCD is here: https://opensourceebikefirmware.bitbuck ... tocol.html
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.

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jun 30 2017 8:17pm

On the last days I found 2 big issues:
1. my code had a BUG and wasn't doing the angle interpolation
2. my Cute 85/Q85 motor hall sensors signals aren't exactly at 60º each change!!

1. I just rectified my code and finally the motor runs quieter and the phase current wave is now much near to a sinewave. With the bug, it was running more like 6 steps and not sinewave:
BEFORE
Image

NOW
Image

2. my Cute 85/Q85 motor hall sensors signals aren't exactly at 60º each change!! The time between each pulse have some relevant difference and I was considering on the firmware that the time was always equal --> 60º... so after I found this issue, I decided to depend only of one pulse that happens at every 360º, and works well!! The motor is quitter, I think more than the original firmware and the power supply voltage don't change/rise like what happens with the original firmware!!! I bet original firmware is doing as I was, considering every pulse of 60º while they aren't.

I will keep testing this way to drive the motor and next I need to work on the MAX motor total current (for the case were the motor get stuck and in almost short circuit). Then I will need to work on the phase current controller and speed controller... There is a very important thread about throttle modes: https://endless-sphere.com/forums/viewt ... 30&t=78882

I think I will investigate the "torque plus speed":
Some high end controllers have "torque plus speed" control. This would probably be close to an ICE throttle. I think Sevcon has this, but the programming is reportedly complicated. I haven't tried programming a Sevcon myself.

For PAS, I think PAS as a kind of emulation of a throttle and so first I will implement the throttle to finally implement PAS.
Attachments

[The extension bmp has been deactivated and can no longer be displayed.]

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
KingQueenWong   100 mW

100 mW
Posts: 39
Joined: Dec 18 2016 7:07am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by KingQueenWong » Jul 06 2017 3:54am

What do you think about this board?
What i know is that:
1.two phase current amplifier;
2.Support 36V-84V;
3.Up to 1500W;
4.STM32F031C6T6;

https://www.sgshop.com/taobao/tao-bao/s ... 4557726531
Last edited by KingQueenWong on Jul 06 2017 11:02pm, edited 1 time in total.

casainho   1.21 GW

1.21 GW
Posts: 3596
Joined: Feb 14 2011 2:43pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by casainho » Jul 06 2017 8:11am

KingQueenWong wrote:What do you think about this board?
What i know is that:
1.two phase current amplifier;
2.Support 36V-84V;
3.Up to 1500W;
3.STM32F031RCT6;

https://www.sgshop.com/taobao/tao-bao/s ... 4557726531
For what you say, it should do FOC and be comparable to the MicroWorks 30B4!! As disadvantages: difficult to buy and no ones knows that company. On the other side, Kunteng controllers are well known and used in many ebike kits, even on other brand kits.

Anyway, I would be interested to see some detailed pictures of that boards.

The link you sent is nice, for that service that ones like me in EU or USA can buy...!! Thanks.
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
KingQueenWong   100 mW

100 mW
Posts: 39
Joined: Dec 18 2016 7:07am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers

Post by KingQueenWong » Jul 06 2017 8:32pm

:D :D :D :D
Attachments
201707071499390788595ee344959f1.jpg
201707071499390844595ee37c5e2ea.jpg
201707071499391026595ee432e6766.jpg

Post Reply