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

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


002.png


003.png


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.

004.png

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

005.png

(in Shane Colton documentation)
 
Njay said:
Nice work :)! I see you keep on loving motor control stuff :D
Thanks!! :)
 
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-firmware/BMSBattery_S_controllers_firmware/tree/SVM_try_rotor_angle_control
 
Just implemented cruise control and also brakes activation cancel cruise control as expected.
 
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.
 
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?
 
casainho said:
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.
 
What about PAS sensor? Is it in the plan? Trottle is not legal in Europe.

Sent usingTapatalk
 
Steu851 said:
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.
 
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
 
Steu851 said:
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??
 
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
 
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!
 
Steu851 said:
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.
 
nollkolltroll said:
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.
 
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:
View attachment 1

Picture 2:
02.png

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.
 
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-sine-wave-controller-for-09-case-controller.html?search_query=sine&results=32
 
MisterMint said:
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.bitbucket.io/Controllers--BMSBattery_S06x--LCD_control_panel--LCD_protocol.html
 
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
file.php


NOW
file.php


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/viewtopic.php?f=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.
 
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/show-details?cid=122674003&tbid=544557726531
 
KingQueenWong said:
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/show-details?cid=122674003&tbid=544557726531

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

Attachments

  • 201707071499390788595ee344959f1.jpg
    201707071499390788595ee344959f1.jpg
    462.1 KB · Views: 6,035
  • 201707071499390844595ee37c5e2ea.jpg
    201707071499390844595ee37c5e2ea.jpg
    276.2 KB · Views: 6,035
  • 201707071499391026595ee432e6766.jpg
    201707071499391026595ee432e6766.jpg
    371.6 KB · Views: 6,035
Back
Top