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: 3722
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 » Dec 14 2018 11:23am

haiyi911 wrote:
Dec 14 2018 10:23am
Hi,stancecoke
whats the following lines meaning? calculate average? and how to calculate it?
in ACAsetPoint.c
“”ui32_erps_accumulated -= ui32_erps_accumulated >> 3;
ui32_erps_accumulated += ui16_motor_speed_erps;
ui32_erps_filtered = ui32_erps_accumulated >> 3;“”
I did that code and I can explain:
1. ui32_erps_accumulated = ui32_erps_accumulated - (ui32_erps_accumulated / 8 );
2. ui32_erps_accumulated = ui32_erps_accumulated + ui16_motor_speed_erps;
3. ui32_erps_filtered = ui32_erps_accumulated / 8;

Yes, it is the average using fast shifting register operations -- you know, it is very important to save the very limited processor time.

First we remove 1/8 of the accumulator and then we add our new value, finally the average value is 1/8 of the accumulator.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and displays (Bafang 850C color, SW102 Bluetooth and KT-LCD3).

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.

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Dec 14 2018 11:55am

casainho wrote:
Dec 14 2018 11:23am
haiyi911 wrote:
Dec 14 2018 10:23am
First we remove 1/8 of the accumulator and then we add our new value, finally the average value is 1/8 of the accumulator.
this is what i cannot understand.
1:why is 1/8?why not 1/16?
2:
a. ui32_erps_accumulated = ui32_erps_accumulated - (ui32_erps_accumulated / 8 )=ui32_erps_accumulated*7/8
b. ui32_erps_accumulated = ui32_erps_accumulated + ui16_motor_speed_erps;
c. ui32_erps_filtered = ui32_erps_accumulated / 8=ui32_erps_accumulated*7/64 + ui16_motor_speed_erps/8
i still couldnot understand how to find out the average when ui32_erps_accumulated is not equal to 0. :(

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Dec 16 2018 5:51am

Hi,
the motor didnot run smoothly when the motor was overspeed.[youtube]https://youtu.be/FXm6dFyo3hI[/youtube]
maybe it is strange when i ride the bicycle. so i want to keep the speed(the limit speed) as the default speed ,when the motor is overspeed,the speed is still keep as the limit speed.
which code should i do some change? Thanks!

geofft   1 kW

1 kW
Posts: 351
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 » Dec 16 2018 6:21am

haiyi911 wrote:
Dec 16 2018 5:51am
Hi,
the motor didnot run smoothly when the motor was overspeed.[youtube]https://youtu.be/FXm6dFyo3hI[/youtube]
maybe it is strange when i ride the bicycle. so i want to keep the speed(the limit speed) as the default speed ,when the motor is overspeed,the speed is still keep as the limit speed.
which code should i do some change? Thanks!
Running the motor in the test stand, completely unloaded, will not give you any useful or meaningful results. I suggest that you get the motor installed into a wheel and repeat your tests on the road. You'll find the results will then be completely different and will probably work as you expect. :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Dec 16 2018 11:18pm

Hahahaha....Thanks, geofft! Its a good suggestion,the motor kept running smoothly :D :D

j bjork   1 kW

1 kW
Posts: 320
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 » Jan 05 2019 4:56pm

Hi, it has been a bit silent in this tread for a while :wink:
Has there been any progress?

A question, how is the trottle response compeared to the standard fw? I think it is a bit slow on the kt fw.
I have got the most parts for a conversion, but it seems i have bought a bluetooth module without the blutooth bord..
It is still winter with snow and ice here, and I want to try the controller a bit more before changing fw, so it has been slow at my end.

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Jan 06 2019 9:41am

Hi,stancecoke.
Did you drive by direct drive motor ?when i started the motor,there were some noise and the motor was shaking . then i changed the "motor special angle " as "160"(the best number),but i could still feel that the motor is shaking.are there any parameters to adjust? :D

geofft   1 kW

1 kW
Posts: 351
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 » Jan 07 2019 3:59am

j bjork wrote:
Jan 05 2019 4:56pm
Hi, it has been a bit silent in this tread for a while :wink:
Has there been any progress?

A question, how is the trottle response compeared to the standard fw? I think it is a bit slow on the kt fw.
I have got the most parts for a conversion, but it seems i have bought a bluetooth module without the blutooth bord..
It is still winter with snow and ice here, and I want to try the controller a bit more before changing fw, so it has been slow at my end.
From my experience the throttle (with both Casainho's and Stancecoke's fw) works well with smooth and progressive response. I seem to remember stock fw throttle was rather jerky? The open source fw is a great improvement on this.

I don't think there has been any further progress lately, but both Casainho's and Stancecoke's fw work very well in thr/pas mode and could probably be perceived as 'finished' products. I'm currently running a Sempu T4 torquesensor using Stancecoke's fw in tqsr mode and this also works extremely well, pretty much faultless in fact.

Please bear in mind that my comments only apply to my gearmotor setup, I have no experience with direct drive motors.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   100 kW

100 kW
Posts: 1048
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 » Jan 07 2019 11:13am

haiyi911 wrote:
Jan 06 2019 9:41am
Did you drive by direct drive motor ?when i started the motor,there were some noise and the motor was shaking . then i changed the "motor special angle " as "160"(the best number),but i could still feel that the motor is shaking.are there any parameters to adjust?
I'm using the BionX IGH3 with our firmware. It's completely quiet except small resonance vibrations in the range of 12-14 km/h.
You can finetune the angles corresponding to the hall events. Xnyle has done this successfully, he implemented a function to show the details in BluOsec.
If there is massive noise, please swap the hall-sensor / phase wires to find the correct scheme.
geofft wrote:
Jan 07 2019 3:59am
I'm currently running a Sempu T4 torquesensor using Stancecoke's fw in tqsr mode and this also works extremely well, pretty much faultless in fact.
Nice to hear you finally got it going! :D

regards
stancecoke
Last edited by stancecoke on Jan 07 2019 1:37pm, edited 1 time in total.

j bjork   1 kW

1 kW
Posts: 320
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 » Jan 07 2019 12:32pm

Thank you, I have not noticed any jerkyness in the throttle. But I have not tried very much. What I mean is more the power from standstill. Even if I hold brake and full throttle, and relese the brake I think it is a little slow the first meter or so. I don`t know, maby that is how it always is. It is my first e-bike, so I don´t really have anything to compare to. I have a dd hub and 18fet controller.

geofft   1 kW

1 kW
Posts: 351
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 » Jan 08 2019 5:10am

j bjork wrote:
Jan 07 2019 12:32pm
Thank you, I have not noticed any jerkyness in the throttle. But I have not tried very much. What I mean is more the power from standstill. Even if I hold brake and full throttle, and relese the brake I think it is a little slow the first meter or so. I don`t know, maby that is how it always is. It is my first e-bike, so I don´t really have anything to compare to. I have a dd hub and 18fet controller.
This sounds like you may not be getting a full throttle signal - I think most of these controllers require around 4v on the thr signal line to achieve somewhere near full throttle. I guess you may have already checked this, but if not maybe worth doing a quick meter check on your full throttle voltage?

geofft wrote:
Jan 07 2019 3:59am
I'm currently running a Sempu T4 torquesensor using Stancecoke's fw in tqsr mode and this also works extremely well, pretty much faultless in fact.
Nice to hear you finally got it going! :D

Yeah, I gave up with the T2 type. Although I got it working ok I just didn't like the fact that just resting your feet on the pedals would propel you up the road, so I went for the T4. This gives a much nicer riding experience and they aren't much more expensive than the T2 really...
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

glebor   1 µW

1 µW
Posts: 3
Joined: Feb 07 2018 4:41pm

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

Post by glebor » Jan 08 2019 5:08pm

Hi. Which line of code to remove if you want to program the ZWS controller to work properly?

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Jan 09 2019 12:35am

thanks ,stancecoke.

Hi,Xnyle
i want to aviod the motor startup noise,so i follow "Diagnosing motor startup problems using the app”step,
is my motor angle 105-180=-75??
and how to adapt the number -->Hall Angle 4,Hall Angle6.....Hall Angle5 with different motor?
Attachments
20190109131920.png
20190109131920.png (6.66 KiB) Viewed 1634 times
20190109131845.jpg

User avatar
stancecoke   100 kW

100 kW
Posts: 1048
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 » Jan 09 2019 2:43am

glebor wrote:
Jan 08 2019 5:08pm
Hi. Which line of code to remove if you want to program the ZWS controller to work properly?
Just disable the option "Enable rotor angle correction" in the Java tool.

regards
stancecoke

geofft   1 kW

1 kW
Posts: 351
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 » Jan 09 2019 4:37am

i want to aviod the motor startup noise,so i follow "Diagnosing motor startup problems using the app”step,
is my motor angle 105-180=-75??
I think (with angular measurement) -75deg equates to +285deg? I'm sure someone will correct me if I'm wrong.. :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Jan 13 2019 8:03am

geofft wrote:
Jan 09 2019 4:37am
i want to aviod the motor startup noise,so i follow "Diagnosing motor startup problems using the app”step,
is my motor angle 105-180=-75??
I think (with angular measurement) -75deg equates to +285deg? I'm sure someone will correct me if I'm wrong.. :wink:
:bigthumb: Thanks,you are right!

User avatar
Xnyle   10 W

10 W
Posts: 74
Joined: Sep 03 2018 1:05pm

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

Post by Xnyle » Jan 13 2019 7:11pm

Erm, your hall order goes in the wrong direction, as if you are pedaling backwards. Order has to be clockwise. I'm not quite able to spontaneously wrap my head around that, I guess in this case you have to look at the rising edge.

As your Sinus curve also looks like shit :) I'd say maybe 250°, so motor angle ~175? Id suggest you first fix the order and then look at the diagram.

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Jan 16 2019 7:42am

Maybe my direct motor hall order is counterclockwise .when the order was clockwise on app,the motor run reverse even though exchange the phase wrie or “motor.c"--hall order.

User avatar
stancecoke   100 kW

100 kW
Posts: 1048
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 » Jan 17 2019 12:15pm

haiyi911 wrote:
Jan 16 2019 7:42am
Maybe my direct motor hall order is counterclockwise
Don't give up. Try to find the right wire combination, otherwise the firmware can't work properly. (No firmware can work properly, if the wires aren't connected in the right order...)

regards
stancecoke

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Jan 18 2019 6:29am

stancecoke wrote:
Jan 17 2019 12:15pm
Don't give up. Try to find the right wire combination, otherwise the firmware can't work properly. (No firmware can work properly, if the wires aren't connected in the right order...)
Thanks.
I'v changed the hall order in the code three times,(such as 1-3-2-6-4-5,2-6-4-5-1-3,4-6-2-3-1-5)
switch (hall_sensors) {
case 2://rotor position 180 degree
case 6:
.
and also exchanged the wire combination,so motor was forward(cw)and quiet every situation,but the hall order was still counterclockwise on the APP.It's strange.when the hall order was clockwise on the APP,the motor was backward and noise.maybe my motor hall order is ccw. :oops:

when i started the motor,i could hear the noise maybe the commutation voise and feel the motor shake. with the speed increased,the niose disappered.is it normal?
[youtube]https://youtu.be/WtBDmOn0-nE[/youtube]

User avatar
Valopallo   100 mW

100 mW
Posts: 48
Joined: May 29 2018 1:37pm

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

Post by Valopallo » Jan 18 2019 8:55am

Hello. I'm having this annoying feature at the moment so that when I start pedaling, the motor assistance kicks in pretty close to my liking(about 1 sec). But when I stop pedaling and the assistance shuts off, my DD motor slows dramatically and makes the ride a bit like push and pull. What settings should I change at the BluOSEC app to smooth the assistance? The problem wasn't that bad when my throttle was working because I could just smooth the assistance with it.

EDIT: Ramp end and Ramp start are the settings I suppose? So, can I just start to try different values freely or are there any limits or some setting that can damage my system if not correct?
BluOSEC@36V|15A|S06S|rear DD|MTB|Hardtail|Tunturi

User avatar
stancecoke   100 kW

100 kW
Posts: 1048
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 » Jan 19 2019 4:56am

haiyi911 wrote:
Jan 18 2019 6:29am
when i started the motor,i could hear the noise maybe the commutation voise and feel the motor shake. with the speed increased,the niose disappered.is it normal?
yes, that's normal, as the motor starts in 6-Step mode and switches to 60° interpolation at 3erps.

Code: Select all

} else if (ui16_motor_speed_erps > 3
						) {
					ui8_motor_state = MOTOR_STATE_RUNNING_INTERPOLATION_60_DEGREES;
				} else {
					ui8_motor_state = MOTOR_STATE_RUNNING_NO_INTERPOLATION_60_DEGREES;
				}
Valopallo wrote:
Jan 18 2019 8:55am
... my DD motor slows dramatically and makes the ride a bit like push and pull....
EDIT: Ramp end and Ramp start are the settings I suppose?
No, this seems to be a matter of the current cal b value, that is set automatically at startup. Please check battery current and current target, in the situation, when the motor should turn free.

regards
stancecoke

haiyi911   1 W

1 W
Posts: 58
Joined: Oct 13 2017 5:35am

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

Post by haiyi911 » Jan 19 2019 7:14am

stancecoke wrote:
Jan 19 2019 4:56am
yes, that's normal, as the motor starts in 6-Step mode and switches to 60° interpolation at 3erps.
ok,i see. How to understand the following formula? 256->360°?
ui8_interpolation_angle = (ui16_PWM_cycles_counter_6 << 8 ) / ui16_PWM_cycles_counter_total;

User avatar
Valopallo   100 mW

100 mW
Posts: 48
Joined: May 29 2018 1:37pm

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

Post by Valopallo » Jan 20 2019 4:18am

stancecoke wrote:
Jan 19 2019 4:56am

No, this seems to be a matter of the current cal b value, that is set automatically at startup. Please check battery current and current target, in the situation, when the motor should turn free.

regards
stancecoke
Ok. So BluOSEC screen shows;
Battery current = 0,2A(46/314) when standstill, and when motor is running freely(pedaling tire at air) battery current is 3,6 ~ 4,6A and changing. When rotaing the wheel without pedaling the reading is 0,2-0,4A.

Current target = -0,2A(314) when standstill, and when rotating freely(pedaling tire at air) current target is 32A.

Battery current cal a = 46
Battery current cal b = 314

Obviously this is not correct. My bms current is limited to 15A and single cells are 5A.
What should I do to make this correct?

I also thought to make a video for the upcoming(?) BluOSEC User's manual. :D
https://youtu.be/ydwLHxxih28

Also my State is 250|1 when not pedaling if it helps.
BluOSEC@36V|15A|S06S|rear DD|MTB|Hardtail|Tunturi

User avatar
stancecoke   100 kW

100 kW
Posts: 1048
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 » Jan 20 2019 8:24am

Valopallo wrote:
Jan 20 2019 4:18am
Current target = -0,2A(314) when standstill, and when rotating freely(pedaling tire at air) current target is 32A.
Battery current cal a = 46
Battery current cal b = 314
I think your video is in Torque-Simulation mode with highest assist level?!
Cal b seems to be correct. For a S06S Cotroller cal a has to be something about 100.
I've added this information in the Wiki Pages. I'm not sure about the 12 FET, if somebody has reliable information, please let me know, or directly edit the Wiki.
Battery Current cal a: Factor a in the calibration function. 1A = a/10 * ADC value. Required for internal calculation of the current from the 10bit ADC value. For a 6FET and 12FET controller the value has to be something around 100, for the 18FET about 50.
regards
stancecoke

Post Reply