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

Electric Motors and Controllers
Valopallo   10 W

Posts: 74
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

stancecoke wrote:
Feb 04 2020 5:54am
Valopallo wrote:
Feb 04 2020 5:16am
Ok, so as it seems I have 21 teeth on the drive gear and 36 teeth on each driven gears.
no, I guess, you have a planetary gear. So number of teeth of the planet gears is irrelevant, important is the ratio from the sun gear to the ring gear.

regards
stancecoke
Ok. I found this calculator; http://www.mekacademy.com/
It shows 93 teeth ring gear, with 21 teeth sun gear and 3 x 36 teeth planetary gears and so the calculation is: 93/21= 4.4. And multiplying that by 10 gives 4.4 x 10 = 44
Correct?
Attachments
gear_calculator.jpg (184.85 KiB) Viewed 1563 times
BluOSEC@36V|AWD|2xS06S|15A rear DD|10A front geared|Hardtail|Tunturi

stancecoke   100 kW

Posts: 1165
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

Valopallo wrote:
Feb 04 2020 6:29am
Correct?
Yes, if the gear has only one stage. I guess, it has more stages, as the displayed speed is that much to high. But you can easily check it by comparing the shown speed with a speedometer.
If you have the external speedsensor set active, make sure, that the number of pulses per wheel revolution is correct.

regards
stancecoke

Valopallo   10 W

Posts: 74
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

stancecoke wrote:
Feb 04 2020 7:23am
Valopallo wrote:
Feb 04 2020 6:29am
Correct?
Yes, if the gear has only one stage. I guess, it has more stages, as the displayed speed is that much to high. But you can easily check it by comparing the shown speed with a speedometer.
If you have the external speedsensor set active, make sure, that the number of pulses per wheel revolution is correct.

regards
stancecoke
Before I get to open the motor plate again, I'm driving external speedsensor set as active, because then there's no "jittering"(and speedometer is accurate), if that's the right word. One thing I came across though is the voltage sag of the throttle. Seems like the rear motor starts to do all sorts of odd behaviours, for example the throttle doesn't shut the rear motor every time when braking. Apparently there's a gas leak I'm thinking about ways to get rid of the voltage sag. Could I just power the throttle with external +5V from for example the +5V generated by the DC-DC controller for the Bluetooth module? I actually use my bluetooth module with +6V input because there's two small 6V lights in parallel with it. I mean if I give the +5-6V from this to throttle input and share the signal output to both controllers, should I run to any problems? If this doesn't work, what other options do I have; thicker throttle wires? A second throttle with it's own input voltage and signal?
BluOSEC@36V|AWD|2xS06S|15A rear DD|10A front geared|Hardtail|Tunturi

stancecoke   100 kW

Posts: 1165
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

Valopallo wrote:
Feb 06 2020 3:47am
what other options do I have
You could remove the big resistor and feed the LM317 with 17V from an extra DC/DC converter...

regards
stancecoke

edit: fixed typo
Last edited by stancecoke on Feb 07 2020 1:33am, edited 1 time in total.

john61ct   1.21 GW

Posts: 3595
Joined: Dec 18 2018 2:06pm

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

LM417? tried googling. . .

kristof645   10 µW

Posts: 5
Joined: Feb 10 2020 11:32am

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

Hi,
I plan to write the stancecoke/BMSBattery_S_controllers_firmware on a KT ZWS controller as my motor is sensorless.
I read the wiki and the forum but I still have some doubs, If someone can help me.

1- Concerning this notes about the ZWS controller "You can disable FOC ... but the motor will not run with best efficiency in this case. Some energy will be wasted as heat."
--> Does it mean that this firmware give worst results than the original one ?
--> I know the answer "you can try" but from a more technical point of vue ? Is there a useffull answer ? Some one has tested it for a long period ?

2 - Do I have to write the firmware on the display too ? I think that not but I read some confusings posts for me.

3 - Does the informations displayed by KT-LCD 5 et KT-LCD3 remain the same after flashing the controller ?

Thanks for the job, I hope I could help.
Christophe

stancecoke   100 kW

Posts: 1165
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

kristof645 wrote:
Feb 10 2020 12:00pm
as my motor is sensorless
The open source firmware does't work in sensorless mode. The motor has to have Hall-sensors.

regards
stancecoke

fratto   10 µW

Posts: 5
Joined: Jan 17 2020 2:18am

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

Hello Christophe,

I'm not an expert on the matter, but your case is very similar to mine, so I can tell you my own experience :

I have installed the @Stancecoke BMSBattery_S_controllers_firmware on my KT ZWS motor controller with a KT LCD-3 display and also used it with the Android App ( developed by @Xnyle ) via Bluetooth. Now, about your questions :
1- Concerning this notes about the ZWS controller "You can disable FOC ... but the motor will not run with best efficiency in this case. Some energy will be wasted as heat."
--> Does it mean that this firmware give worst results than the original one ?
--> I know the answer "you can try" but from a more technical point of vue ? Is there a useffull answer ? Some one has tested it for a long period ?
On page 151 of this thread, you can read the reply @Stancecoke gave me about how to disable FOC in the code, before compiling and downloading the firmware to your KT ZWS ( you should also mark "disable interpolation" on the Java Configuring Tool )
This does not mean you will get worse results than using KT stock firmware ( in fact, I would say the contrary! ). The problem is KT ZWS , unlike the BMS S06S / KT SVP controllers, does not come with the phase current sensor, so you can not implement a FOC to get a better efficiency ( by phase angle and power factor correction ). Remember that your original KT ZWS firmware does not implement FOC or any other kind of PF correction, as it is not bundled with the necessary sensor in hardware ( you can see the place for the sensor in the PCB is empty , so you can solder it if you want to use FOC anyway: more info here )
2 - Do I have to write the firmware on the display too ? I think that not but I read some confusings posts for me.
At least in my experience, for using KT LCD-3 you dont need to change the original firmware that comes with it ( maybe you got confused with the Open Firmware for LCD-3 developed for other brand of controllers named TSDZ2 : see that project here ).
For KT controllers, you can select among 3 display options in the Java config Tool : KT-LCD3 , Kingmeter J-LCD , BlueOSEC App (not really a commercial display, but an android device instead, running the app and connected via bluetooth ).
3 - Does the informations displayed by KT-LCD 5 et KT-LCD3 remain the same after flashing the controller ?
Apparently yes... and you still use the push buttons to power on the system , active the LCD backlight and navigate throghout the menues and pages ... But in reality, after installing OSEC firmware ( and deleting original KT firmware ) the LCD-3 loses all its capabilities to set or change parameters values in the controller data memory: it mostly serves only as displaying unit ( actual speed, instant power, battery level, and not much more... ). I think you can still change assist level and wheel diameter but you can not change anything else except you connect with the Java Config Tool or the BlueOSEC App.
Offroad speed limit can be activated by a "cheat" that involves moving the brake lever in a special sequence to activate the offroad mode ( and after that , just keep pressing the brake lever for 5 seconds if you want to deactivate it).
Last edited by fratto on Feb 29 2020 12:29am, edited 2 times in total.

fratto   10 µW

Posts: 5
Joined: Jan 17 2020 2:18am

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

Hi all,

I want to thank specially Stancecoke for helping me last time, and also my congrats to Xnyle for his BlueOSECApp , the info it gives is really great!!!

Sorry for bothering again, but it seems I must ask for your help yet another time...

All went really good after replacing my original KT stock firmware and running the tests via BlueOSECApp to fine tune the parameters in Java Config Tool, till I found that... my eTricycle did not respond anymore to the "reverse" order ...

Of course, that should not be a surprise for anyone, if we agree this project is aimed mainly to ebikes ( where you dont ever want to drive your motor backwards )

In case of my electric tricycle, the "reverse march" is a must , so my KT controller came from factory bundled with that functionality.

Basically, the hardware is like this : an input connector ( with a pair of white cables ) that, when closed, gives GND to the "X8" point in my KT48ZWS PCB . After going through a resistor, the signal enters the STM8 in its 43 pin ( PD2 ).

Is there a simple way to assign that pin as an input in the code and then, if it goes low, make it invert direction of the wheel ?

I've been looking at the source code, but could not find anything related with reversing direction of rotation ( though I know that changing the phase secuence, should cause the desired effect, is that right? )-

Hope someone can guide me in doing the neccesary changes in code or give me their suggestions,
Thanks and Regards

stancecoke   100 kW

Posts: 1165
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

fratto wrote:
Feb 11 2020 2:40am
In case of my electric tricycle, the "reverse march" is a must
There were several requests for reverse direction before in the german forum, e.g. from Xiongda-Users, where the motor direction changes the gear ratio.

I have to think about it

regards
stancecoke

kristof645   10 µW

Posts: 5
Joined: Feb 10 2020 11:32am

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

fratto wrote:
Feb 11 2020 1:41am
I'm not an expert on the matter, but your case is very similar to mine, so I can tell you my own experience :
...
Hello Fratto,
I really thank you for your explanations!
I can't simply modify the controller as my OZO FREERIDER motor no have hall sensors but I'm very impatient to try the firmware without FOC!!
I'll will give a feedback of my experience.
Regards,
Christophe

kristof645   10 µW

Posts: 5
Joined: Feb 10 2020 11:32am

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

Hi all,

I'm waiting for all the stuff to write the firmware and debug but I would appreciate some help in finding the optimal settings.

I just need torque because I use the assistance to climb hills and my maximum speed assistance is currently set at 17 km / h.

I understand the "battery current limit" but how can I determine the optimal maximum current phase for my use and not fry my controller ??

My configuration is:
- 36V battery, nominal current 20A, max current 30A
- KT 36 / 48ZWS 6FET, nominal current 8A, max current 17A
- Hub geared motor without hall sensor, certified for 48v / 25a / 1350w controller

Christophe

obcd   100 W

Posts: 137
Joined: Jul 16 2019 3:45pm

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

I am a bit confused here as the mounting of the planet wheels is rotating as well.
If I remember well, in my front wheel geared hub motor, they are fixed to the axis and frame...?
So, can't I just take the teeth ratio to figure out motor speed / wheel speed proportion?

Sorry for it being a bit off topic. I just stumbled upon it in here.

Valopallo   10 W

Posts: 74
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

kristof645 wrote:
Feb 18 2020 4:05pm
- Hub geared motor without hall sensor, certified for 48v / 25a / 1350w controller
As stancecoke already stated, you cannot use this firmware with sensorless motor.
BluOSEC@36V|AWD|2xS06S|15A rear DD|10A front geared|Hardtail|Tunturi

kristof645   10 µW

Posts: 5
Joined: Feb 10 2020 11:32am

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

Hello,
Fratto does use it with a ZWS sensorless controller after disabling FOC/interpolation.

EDIT : OK, I didn't see previous answer of Stancoke, but I still don't understand how it could work with Fratto's ZWS which is sensorless controller without adding sensor module.

Regards,
Christophe

stancecoke   100 kW

Posts: 1165
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

„ZWS“ says block commutation, there are versions that have the hall-connector and the additional sensorless-board in parallel.
So they can work in sensored and in sensorless mode with the stock firmware.
regards
stancecoke

Valopallo   10 W

Posts: 74
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

kristof645 wrote:
Feb 20 2020 4:39am
EDIT : OK, I didn't see previous answer of Stancoke, but I still don't understand how it could work with Fratto's ZWS which is sensorless controller without adding sensor module.
Yes, but he/she doesn't mention anything about his/her motor which obviously is HALL sensored to be able to use this firmware. Now what I've understood here is that you have a HALL sensorless motor(no HALL wires) and KT-S06SZWS controller that does not have a phase current sensor. I think you're mixing two different sensors here. All you need to get is either a HALL sensored motor(to use this firmware) or KT-S06SZWS version that operates also on sensorless motor -mode(and use the stock KT firmware). To use this open source firmware you need to have HALL sensored motor and to be able to use FOC with it, you need a KT-S06SSVP controller that has a phase current sensor on board or as Fratto mentioned, you can post install the sensor to the empty pin of KT-S06SZWS and use that.
Last edited by Valopallo on Feb 21 2020 5:55am, edited 1 time in total.
BluOSEC@36V|AWD|2xS06S|15A rear DD|10A front geared|Hardtail|Tunturi

stancecoke   100 kW

Posts: 1165
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

obcd wrote:
Feb 18 2020 5:34pm
I am a bit confused here as the mounting of the planet wheels is rotating as well.
the german wikipedia-page gives detailed information:
https://de.wikipedia.org/wiki/Umlaufr%C3%A4dergetriebe

regards
stancecoke

john61ct   1.21 GW

Posts: 3595
Joined: Dec 18 2018 2:06pm

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

Valopallo wrote:To use this open source firmware you need to have HALL sensored motor and to be able to use FOC with it, you need a KT-S06SSVP controller that has a phase current sensor on board
I have found this topic

"what defines true sinewave FOC?"

a challenge to nail down.

Confirmed examples: Sabvoton, as with Borg Cromotor
PhaseRunner
Zero electric motorcycle

gathered so far:

current sensor **on each phase connection** in the motor, to provide
direct real-time sensing of motor current amps
instantaneous CPU-intensive analysis of that data, high bandwidth calculations to predict the rotor angle / position in real-time

Now, I thought that Hall sensors were a compromise, that the phase sensing with True FOC was done via shunts?

As in "sinusoidal commutation, interpolating from the hall sensors" as opposed to "true sinewave FOC".

Where does a S06SSVP controller running the FOSS firmware,

with just a single Hall phase current sensor

Fit into this "true FOC" vs "pseudo FOC mode" continuum?

stancecoke   100 kW

Posts: 1165
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

john61ct wrote:
Feb 21 2020 5:56am
Now, I thought that Hall sensors were a compromise, that the phase sensing with True FOC was done via shunts?
You are mixing up things.
The hall sensors in the motor are detecting the rotor position (but only 6 states per revolution) This has nothing to do with sinusoidal or FOC commutation.

Sinusoidal commutation means, that the phase currents are shaped sinusoidal. You can put a sinusoidal voltage on the coils and you will get a sinusoidal current. (even if the motor isn't spinning ) But you have to syncronize the voltage with the rotor position to make the motor run.

With FOC you can control the voltage (and current as a result) in a way, that you get most torque and minimum heat from the motor. (or do field weakaning e.g....)
You need at least two phase current sensors (as the sum of the three currents is always zero, you don't need to measure the third phase current)

For sensorless FOC you need an "observer" that predicts the rotor position.

The STM8 processor in the Kunteng SVPR is too slow to do all the calculations for FOC, let alone the additional rotor position prediction.
The Kunteng SVPR uses only one phase current sensor (based on the hall effect , not a simple shunt+opamp ) and we are doing what we called "simplyfied FOC". We syncronize the rotorposition with the zero-crossing of the one phase current signal. The rotor position is extrapolated from the motor-hall signals.

There are several open source examples how sensorless FOC can work on cheap e-bike controllers e.g. the vesc or my lishui project.

regards
stancecoke
Last edited by stancecoke on Feb 21 2020 8:09am, edited 10 times in total.

Valopallo   10 W

Posts: 74
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

john61ct wrote:
Feb 21 2020 5:56am

Where does a S06SSVP controller running the FOSS firmware,

with just a single Hall phase current sensor

Fit into this "true FOC" vs "pseudo FOC mode" continuum?
Well, can the "true FOC" be achieved with the components of the KT controllers?
If not, then I guess this is irrelevat to this thread and we have to live with the "woke as FOC" we have here
BluOSEC@36V|AWD|2xS06S|15A rear DD|10A front geared|Hardtail|Tunturi

kristof645   10 µW

Posts: 5
Joined: Feb 10 2020 11:32am

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

Valopallo wrote:
Feb 21 2020 3:53am
...All you need to get is either a HALL sensored motor(to use this firmware) or KT-S06SZWS version that operates also on sensorless motor -mode(and use the stock KT firmware)...
Thank's to Valopallo and Stancecoke for your explanations.
Regards,
Christophe

john61ct   1.21 GW

Posts: 3595
Joined: Dec 18 2018 2:06pm

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

stancecoke wrote:The hall sensors in the motor are detecting the rotor position (but only 6 states per revolution) This has nothing to do with sinusoidal or FOC commutation.
OK thanks, I'll do some more reading / research to try to understand more of that than I do now.

qwerkus   1 kW

Posts: 479
Joined: Jul 22 2017 4:00am

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

Here I am trying to install the opensource firmware on a KT controller. Hardware has been prepped and I'm ready to hit the magic button. Only thing bothering me is this line on page 4 of the online instructions:
https://opensourceebikefirmware.bitbuck ... ndex4.html
Please make sure to find out the correct phase and Hall sensor assignment on the complete system with the original firmware before deleting.
How do I find out phase wire assignment and hall sensor angle for my motor with the original firmware ? Motor is RH212. I don't see a debug / test function on the KT firmware.

cnrd   100 mW

Posts: 36
Joined: Apr 12 2019 5:47am

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

Does anyone here know what X5 is used for? On my controller it seems to be connected to the white wire on the 9 pin waterproof connector.