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

Electric Motors and Controllers
Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 09 2020 3:56pm

stancecoke wrote:
May 09 2020 9:44am
Black6spdZ wrote:
May 09 2020 3:13am
I do not understand how the halls are bad when they test good with a meter.. what am I missing?
The Halls are not in 120° position
If you get only 3 and 4 all three halls are switching at the same time :shock:
3 - - > 011
4 - - > 100

Image

regards
stancecoke
thanks for the reply back. my motor is an old 9C 2706, 46 magnets, 51 poles.. are you saying it is still a potential hardware issue or just software configuration? I'd really like to get this newer controller with sine and regen over the caveman sunwin

quick update.. so when I connect the halls with a 10k pull-up to my two channel scope I get the normal pattern, the same as I see connected to the sunwin, but when I connect the scope to the KT I get the halls turning on for a shorter interval with never any overlap.. wth?
not sure why but continuity on KT hall input between + to sensor is ~46k and sensor to - is ~2.8k whereas the sunwin is 2.8M and 4k
there definately is some hardware issue or compatibilty problem with these halls and the KT..any resistor trickery I could do to make it work?

shellton   1 mW

1 mW
Posts: 14
Joined: Apr 27 2020 1:04pm

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

Post by shellton » May 10 2020 1:59pm

Look at schematic. Hall sensors must go to PINS 38-40 of CPU.

https://opensourceebikefirmware.bitbuck ... ematic.pdf

If pins are wrong , you can define them in gpio.h

BR , Linas

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 10 2020 4:06pm

shellton wrote:
May 10 2020 1:59pm
Look at schematic. Hall sensors must go to PINS 38-40 of CPU.

https://opensourceebikefirmware.bitbuck ... ematic.pdf

If pins are wrong , you can define them in gpio.h

BR , Linas
Its the standard 18-fet PCB.. Maybe they used different value resistors on the supporting circuitry, or maybe a problem with the controller, or maybe the halls in my motor are flaky.. Just not sure how to narrow it down further. The fact that the halls test OK not connected to the KT and work with another controller lead me to believe the motor is OK. But i m not sure if I need another controller or replace the motor halls "which will be a major PITA" at this point

User avatar
stancecoke   100 kW

100 kW
Posts: 1220
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 » May 11 2020 12:48am

Black6spdZ wrote:
May 09 2020 3:13am
I pulled up the phase monitor in bluosec
Do you have an external +5V power supply for the BT-module? The controller internal +5V supply is known to be very weak, it can't handle any additional load. You can try to supply the hallsensors with external +5V, too.

regards
stancecoke

shellton   1 mW

1 mW
Posts: 14
Joined: Apr 27 2020 1:04pm

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

Post by shellton » May 11 2020 2:07am

Trying to review code , to find max ERPMS ;

Code: Select all

#define PWM_CYCLES_COUNTER_MAX 3000 // higher values assume motor is at standstill.
#define PWM_CPS_NORMAL_SPEED 15625L
#define PWM_CPS_HIGH_SPEED 20833L
Do i understand correctly , that max eRPM is 15625/30 and 20833/30 ?
Last edited by shellton on May 12 2020 8:59am, edited 1 time in total.

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 11 2020 1:13pm

stancecoke wrote:
May 11 2020 12:48am
Black6spdZ wrote:
May 09 2020 3:13am
I pulled up the phase monitor in bluosec
Do you have an external +5V power supply for the BT-module? The controller internal +5V supply is known to be very weak, it can't handle any additional load. You can try to supply the hallsensors with external +5V, too.

regards
stancecoke
That's what I thought at first so I moved the hall power lead to the 5v pad next to the hall inputs that had a solid 5v but still the same results

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 12 2020 1:27am

ok.. unbelievable.. two of my halls were shorted in the controller connector that looked fine from the exterior. go figure! i had to swap phases wires around but got correct and smooth rotation.. finally! so i've been playing with settings and so far the lowest current freewheel is at 233deg motor angle correction with rotor correction angle on, or 250deg with it off. sine wavetable seems less efficient from a power standpoint with just a slight improvement in audible motor noise. I changed out the rail caps with rubicon 1000uf, 100v instead of the cheap 470uf ones along with a flash pigtail and 10ga power wires. just waiting on some new XT90 connectors to finish up.
on a side note, there is a problem with bluosec app, it's voltage cal only allows up to 100 whereas my 72v controller needs it set to 136. i clicked on it in the app and it changed it to less than 100 again so it looks like i'll have to erase and reflash again to get that right

Vbruun   10 W

10 W
Posts: 80
Joined: Sep 26 2019 8:42am

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

Post by Vbruun » May 13 2020 3:56am

Are there any plans to implement field weakening in this firmware? I could really use it ;)

User avatar
stancecoke   100 kW

100 kW
Posts: 1220
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 » May 13 2020 4:30am

Vbruun wrote:
May 13 2020 3:56am
Are there any plans to implement field weakening in this firmware?
I will not implement that, but of course everybody is invited to do it :wink: .
It's very easy, you just have to increase the ui8_assumed_motor_position with the speed. You have to do the angle correction procedure later (or earlier, I don't know exacty, just try it... :o ) within the electric revolution. Tune the ui8_correction_at_angle with the speed, see line 271 of the motor.c

Code: Select all

if ((ui8_foc_enable_flag) && ((ui8_assumed_motor_position) >= (ui8_correction_at_angle + (ui16_motor_speed_erps>>factor))) &&(ui8_assumed_motor_position) < (ui8_correction_at_angle + (ui16_motor_speed_erps>>factor) + 4))) {
		// make sure we just execute one time per ERPS, so reset the flag
		ui8_foc_enable_flag = 0;

		updateCorrection();
	}
Of course it would be better to activate the additional angle only at very high erps, to keep the best efficieny at lower erps.

regards
stancecoke

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 16 2020 3:10pm

took the bike out for it's maiden voyage today. first off I'm a little confused on some values.. I have the Current cal a set to 50 "18-fet 72v controller" but the actual current was only about 8a with the max current set to 45 in bluosec < is this just a 0-255 value used to calculate actual? so I bumped max current to 180 and then was seeing ~25a which felt better but not near the power i got from the old sunwin. Then I was riding along, hit a bump and lost power.. no problems with external connections so I pedaled home and popped top case off. one of the voltage regulator power resistors desoldered itself and fell out.. a 150 ohm. it was in series with a 180 ohm so figures it ran the hottest and fell out first. these look to be only 2w parts, should i just replace them both with a 5-10w 330 ohm or is there a better solution?

AlexDaniel   1 µW

1 µW
Posts: 4
Joined: Oct 18 2019 8:37pm

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

Post by AlexDaniel » May 18 2020 7:25pm

Heads up to anyone who wants to use my tweaked firmware that I shared in this post, just letting you know that I uploaded the wrong file initially and have now fixed it. :oops:

szkuba   100 µW

100 µW
Posts: 9
Joined: Nov 26 2018 2:56pm

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

Post by szkuba » May 19 2020 1:55am

I havent found the answer in the docs so the basic question:

would the firmware work with both the LCD4 and bluetooth adapter?

I would use it to program/monitor the perimeters but when released the bike to 10y kid i would only let him use the LCD :wink:

Is it possible?

User avatar
stancecoke   100 kW

100 kW
Posts: 1220
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 » May 19 2020 2:09am

szkuba wrote:
May 19 2020 1:55am
would the firmware work with both the LCD4 and bluetooth adapter?
No. If you want to use the LCD Display you have to adapt most settings in the Java-Tool. You can use the LCD for the basic settings max speed and wheel size.

You could do the settings in BluOSEC and than flash the controller to LCD-Mode with disabling the EEPROM init function, but that's much more complicated than setting the parameters directly in the Java-Tool.

regards
stancecoke

szkuba   100 µW

100 µW
Posts: 9
Joined: Nov 26 2018 2:56pm

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

Post by szkuba » May 19 2020 9:52am

stancecoke wrote:
May 19 2020 2:09am

No. If you want to use the LCD Display you have to adapt most settings in the Java-Tool. You can use the LCD for the basic settings max speed and wheel size.
Thanks, so the PAS levels work as well i suppose? Would the walk assist and lights activation work as well?

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 21 2020 10:39am

any coders here willing to work on an ESP8266/32 with a stand-alone web interface and logging capabilities? This would open up an opensource portable config option for iphone users as well

casainho   10 GW

10 GW
Posts: 4457
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 » May 23 2020 12:07am

Black6spdZ wrote:
May 21 2020 10:39am
any coders here willing to work on an ESP8266/32 with a stand-alone web interface and logging capabilities? This would open up an opensource portable config option for iphone users as well
There is a standard for a wireless ebike, that means connecting wirelessly displays and buttons to the ebike motor. This is a standard that follows the other popular wireless sensors on cycling like speed and cadence sensors, pedal power meters up to sensors like tire pressure sensors - I am talking about ANT+ LEV (Light Electric Vehicle) profile and commercial ebikes like the popular Specialized Turbo Levo ebike.

I am starting a project of a simple DIY electronic board to connect to the motor instead of the display cable, that will give Bluetooth for connecting with mobile phone and ANT+ LEV and other cycling sensors, making the ebike motor fully wirelessly and following the standards -- see here:

Fully wireless ANT+ BLE TSDZ2 mid drive motor (like Specialized Turbo Levo) -- Flexible OpenSource firmware]

And the magic is that there are many ebike displays cycling computers that will work, and they have fully map navigation and advanced cycling fitness metrics - now you can also control your ebike with them and receive you ebike data on them also to record included with your fitness data -- an example:

- TSDZ2 FAQ: issues and repairs, etc
- TSDZ2 OpenSource firmware

Developer of OpenSource knowledge and technology for ebikes: Wireless Ebike boar ANT+ and Bluetooth, Flexible OpenSource firmware for EBikes: TSDZ2 mid drive motor, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.

If you like my work, please consider making a donation to help my developments: paypal.me/jorgecasa

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 23 2020 2:32am

Very interesting.. Will it allow the advanced configuration of the osec firmware? I was thinking something similar to bluosec but as its own standalone logger as well.. Long term averages of motor correction angle to allow for fine tuning of the motor.. Don't see any reason it couldn't have a web front end along with the ANT+LEV support as well.. Might need the more powerful wemos esp32 d1 mini. how about this? https://github.com/rumpeltux/esp-stlink could flash the controller directly with the esp

transposon   100 W

100 W
Posts: 109
Joined: Nov 24 2011 4:37pm
Location: Massachusetts

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

Post by transposon » May 24 2020 12:58am

Does anyone have working settings for a S12SNN controller and a leaf 1500W motor? I just unlocked the controller, but am not sure what settings to use.

DoniDsi   1 µW

1 µW
Posts: 4
Joined: Apr 30 2020 2:24pm

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

Post by DoniDsi » May 24 2020 2:11pm

do i need to know hall angels or will they stay the same if i just want to change the top speed and regen settings?

Black6spdZ   1 W

1 W
Posts: 63
Joined: Jul 29 2011 5:59pm
Location: Waterford, MI
Contact:

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

Post by Black6spdZ » May 25 2020 6:50pm

well damn.. after about 30km of riding today i was about to roll the bike into my garage to charge and I gave it some throttle from a standstill and it jerked a bit and i let off the throttle and felt it still wanting to pull a bit just as i looked down and saw smoke coming out of the controller. I had headphones on or i'm sure i would have heard some arcing going on. half the board is charred black, its a gonner for sure. now i'm not sure if i want to buy the same controller and risk running this firmware, run the stock firmware or get an entirely different one. any suggestions for a 72v ~18fet unit?
So I just ordered a hallomotor/sabvoton 72v 100a.. got a good taste of a decent ebike build and now just want something that works and wont fry and leave me to pedal a direct hub drive bike 30km home

Corrida victim   1 mW

1 mW
Posts: 16
Joined: Feb 27 2020 8:45am

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

Post by Corrida victim » May 31 2020 10:25am

I honestly bought this kunteng controller just so I could use this project, and I must say, I'm super impressed!

My setup:
- 18mosfet controller
- ±2000w direct drive hub motor
- lcd3
- erider t9 torque sensor

There are a couple things still beyond my knowledge though:

- The lcd3 display seems to not be communicating with the controller at all (except for turning it on). Other than that, the speed, wattage and brake indicator are not shown.
I also don't think changing the assist levels has any effect on the controller (motor still gives assist when assist is set to 0).

- The software seems to ignore the torque sensor as long as it hasn't detected PAS input. I read a post that claimed this is a new safety feature. Is there an easy way for me to alter the code to allow this?
I got used to this feature because my street legal brand name speed pedelec allowed this.
Unfortunately, the extremely high gearing on my new bike makes departure (almost) impossible without this feature. In addition to that I'd like my bike to function without a throttle for now, as that makes it less legal in Europe. For my build I'm using a speed pedelec frame with registration, and my insurance is willing to insure it if it's street legal (no throttle, torque sensor and 45km/h limit).

- The motor seems to be braking when the bike is moving and PAS is not yet detected (making high gear departure even more challenging). I could not find a setting related to this, and the brake sensor is working fine (regen is AMAZING with this software!)

If anyone could send me in the right direction I would very much appreciate!

Edit: Settings:
settin.png
settin.png (118.31 KiB) Viewed 190 times

User avatar
stancecoke   100 kW

100 kW
Posts: 1220
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 » May 31 2020 11:41am

First, welcome to the project and thank you for the feedback!
I think many users (in Germany) would be interested, how you get an agreement with the insurance for a self build "S-Pedelec" :D !
Corrida victim wrote:
May 31 2020 10:25am
Is there an easy way for me to alter the code to allow this?
If you are keen on burning your mosfets, you can disable this safety feature of course. Remember, torque at standstill will produce nothing than heat and doesn't help you to accelerate faster. The very first PAS-Pulse will give you the full torque override power. To get the defined maximum current by torque override, you should disable the checkbox ASSIST_LVL_AFFECTS_THROTTLE

Line 279 of the ACAsetPoint.c:

Code: Select all

		if ((uint32_t) float_temp > uint32_current_target) {
			if (((ui16_aca_flags & TQ_SENSOR_MODE) == TQ_SENSOR_MODE)) {
				if (uint32_current_target > ui16_current_cal_b){
					//override cadence based torque with torquesensor-throttle only if there is cadence based contribution
					uint32_current_target = (uint32_t) float_temp;
				}
			}else{
				//override torque simulation with throttle
				uint32_current_target = (uint32_t) float_temp; 
			}
			controll_state_temp += 16;
		}
Corrida victim wrote:
May 31 2020 10:25am
The lcd3 display seems to not be communicating with the controller at all
This is very strange, we have several feedback, that the KT-displays are working without problems. To analyze this problem, you have to log the UART-message that is sent by the display to the controller. Perhaps newer displays are using a different XOR value in the checksum.

regards
stancecoke

Corrida victim   1 mW

1 mW
Posts: 16
Joined: Feb 27 2020 8:45am

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

Post by Corrida victim » May 31 2020 12:50pm

stancecoke wrote:
May 31 2020 11:41am
I think many users (in Germany) would be interested, how you get an agreement with the insurance for a self build "S-Pedelec" :D !
Thank you! The most important part is getting a donor S-pedelec (I used a broken bulls green mover). Then find a good insurer (enra). After this throw some bullshit story about how your motor broke down and the manufacturer is bankrupt (it's true :lol:). Then nicely ask them if it is OK if you use a motor from a different brand ;)
stancecoke wrote:
May 31 2020 11:41am
If you are keen on burning your mosfets, you can disable this safety feature of course. Remember, torque at standstill will produce nothing than heat and doesn't help you to accelerate faster. The very first PAS-Pulse will give you the full torque override power. To get the defined maximum current by torque override, you should disable the checkbox ASSIST_LVL_AFFECTS_THROTTLE
Ohhh so the assistance should normally kick in at the first PAS pulse? That would be fantastic!! I guess something is wrong with my setup in that case. At departure, I have to turn the pedals at least 4 rounds before the motor kicks in, during that time, the motor is actually holding me back (regen fully activated?).

I'm not looking for more torque at startup, just some assistance to get me going :D (Half throttle from kunteng software would be more than plenty)
Unchecking ASSIST_LVL_AFFECTS_THROTTLE doesn't risk burning my mosfets, right?
stancecoke wrote:
May 31 2020 11:41am
This is very strange, we have several feedback, that the KT-displays are working without problems. To analyze this problem, you have to log the UART-message that is sent by the display to the controller. Perhaps newer displays are using a different XOR value in the checksum.
I indeed read very positive feedback about lcd3 compatibility. XOR values and such are beyond my knowledge, but I will throw my trusty arduino UART converter on the display and report back to you asap!
Best regards and thanks a lot!

User avatar
stancecoke   100 kW

100 kW
Posts: 1220
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 » May 31 2020 1:50pm

Corrida victim wrote:
May 31 2020 12:50pm
I guess something is wrong with my setup in that case
I just looked at your throttle (torque in your case) min and max setting. You have to use integers here, no floating points. And you should check both values, if the max value is too high, you will never get full power.

regards
stancecoke

Slipy   1 mW

1 mW
Posts: 11
Joined: Mar 19 2020 6:22pm

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

Post by Slipy » May 31 2020 2:11pm

Hi, can you help me with stop light, i want use gpio A1 pin how output to connect N mosfet to control stop light from brake pin. I tried modifying the code, but nothing works for me :(

Post Reply