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

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?
 
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:
 
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?
 
szkuba said:
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
 
stancecoke said:
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?
 
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
 
Black6spdZ said:
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:

[youtube]F43oqj1Zlww[/youtube]
 
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
 
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.
 
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?
 
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
 
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
 
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 said:
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:
		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 said:
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
 
stancecoke said:
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 said:
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 said:
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!
 
Corrida victim said:
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
 
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 :(
 
Slipy said:
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 :(

Can't you just monitor the voltage on the brake sensor cable using an arduino nano and some high value resistors? Or even connect a logic level mosfet in series with a 10k resistor directly to it?
Seems a lot easier than messing with the code
 
stancecoke said:
Corrida victim said:
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

Both values are correct and calculated using the Tq sensor manual ((x/5)*255).
I fixed the floating point value! Motor is still braking when pedaling slowly. I'll expriment with some values tomorrow. Thanks!
 
stancecoke said:
Corrida victim said:
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.
Can it be because the screen has more/different parameters depending on when/where it is bought ?

While we are on the screens, are there KT-LCD8 users ?
There are more parameters (L1->4) so I'm not sure if it would be supported by the firmware (of course it can be added).

I'm ordering a direct drive motor (MXUS XF40C) for a solar recumbent trike.
I will use this firmware and maybe change a few things as a virtual freewheel like the phaserunner controllers (inject a small power even if not pedaling if the motor is running).
 
Slipy said:
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 :(
Hm, this is quite trivial, you have to define PA1 as a digital output in the GPIO init function and then use the GPIO_WriteHigh and GPIO_WriteLow commands to switch the output.

See the gpio.h for the pin definitions and the gpio.c for the init and switch functions.

regards
stancecoke
 
stancecoke said:
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.

Hi, I logged the uart message using Hterm, as I saw you recommended that in another post.
Not sure if you're interested in seeing the logs?
best regards,
Inse


uart.png
 
Corrida victim said:
Not sure if you're interested in seeing the logs?
Thank you for the log! First thing: you are logging at 2400 BAUD?! The LCD3 and the controller are using 9600 BAUD. Therefore your logged communication says nothing to me.

Regards
stancecoke
 
stancecoke said:
Thank you for the log! First thing: you are logging at 2400 BAUD?! The LCD3 and the controller are using 9600 BAUD. Therefore your logged communication says nothing to me.

Not sure why I thought it'd be 2400 baud. Here it is again at 9600 baud. I logged from startup:

uart.png
 
Hi, there seems to be a problem with the CRC compute code, see S-LCD to S12S controller communication protocol hacked:
zlabs67 said:
jbs said:
...
The final xor 2 required in the crc calculation varies, even for exactly the same message but at different sessions/times - sometimes an even number in the final xor is required and sometimes an odd number.
....

to compute checksum correctly, start with crc=0x0E, and not include first byte
Code:
    crc = 0x0e
    for i, v in enumerate(rxbuffer):
        if i != 5 and i != 0:
            crc ^= v

I only checked the first packet and this formula is good.
But the implementation must have changed because it does not work with the data at the top of this file https://opensourceebikefirmware.bitbucket.io/development/EmbeddedFiles/7-LCD3_to_S12SN-1.txt
 
Corrida victim said:
Here it is again at 9600 baud. I logged from startup:

As expected the last XOR value is out of the checked range, it's 14, we test only from 1 to 9. :)

https://onlinegdb.com/Bk9HMKP3I

So you have to add the 14 to the display.c :)

Code:
// see if CRC is ok
		if (((ui8_crc ^ 10) == ui8_rx_buffer [5]) || // some versions of CRC LCD5 (??)
				((ui8_crc ^ 1) == ui8_rx_buffer [5]) || // CRC LCD3 (tested with KT36/48SVPR, from PSWpower)
				((ui8_crc ^ 2) == ui8_rx_buffer [5]) || // CRC LCD5
				((ui8_crc ^ 3) == ui8_rx_buffer [5]) || // CRC LCD5 Added display 5 Romanta
				((ui8_crc ^ 4) == ui8_rx_buffer [5]) ||
		    		((ui8_crc ^ 5) == ui8_rx_buffer [5]) ||
		    		((ui8_crc ^ 6) == ui8_rx_buffer [5]) ||
		    		((ui8_crc ^ 7) == ui8_rx_buffer [5]) ||
		    		((ui8_crc ^ 8) == ui8_rx_buffer [5]) ||
				((ui8_crc ^ 9) == ui8_rx_buffer [5])) // CRC LCD3

I've added this information to the FAQs

regards
stancecoke
 
Back
Top