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

Electric Motors and Controllers
Slipy   10 mW

10 mW
Posts: 24
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 » Apr 17 2020 12:29pm

Yess THANK YOU, it's fully working, i have a last question, interpolation disable its bldc mode (trapezoidal) or sine?
And problem with controller was with one resistor on KingQween's scheme, on brake is two resistor 10k to 5v and 10k to gnd, and last is wrong, if i pull-up to gnd its automatically triggered brake

transposon   100 W

100 W
Posts: 128
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 » Apr 19 2020 9:29am

Has the BMSBattery bluetooth adapter been implemented yet?
https://bmsbattery.com/parts/920-17236- ... oltage-36v

They have versions for different voltages, so it looks like anything above 48V is out. Has anyone tried this for higher voltages?

Slipy   10 mW

10 mW
Posts: 24
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 » Apr 19 2020 7:30pm

transposon wrote:
Apr 19 2020 9:29am
Has the BMSBattery bluetooth adapter been implemented yet?
https://bmsbattery.com/parts/920-17236- ... oltage-36v

They have versions for different voltages, so it looks like anything above 48V is out. Has anyone tried this for higher voltages?

Differences only on dc-dc converter, if you want higer voltage, you can buy hc05 or hc06 Bluetooth module and
https://a.aliexpress.com/_Bf93RnzW
https://a.aliexpress.com/_dY7aYI8
Or what's similar and solder it together


But s06s controller can't operate with higer voltage because Lm317 inside

transposon   100 W

100 W
Posts: 128
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 » Apr 19 2020 8:10pm

Slipy wrote:
Apr 19 2020 7:30pm
transposon wrote:
Apr 19 2020 9:29am
Has the BMSBattery bluetooth adapter been implemented yet?
https://bmsbattery.com/parts/920-17236- ... oltage-36v

They have versions for different voltages, so it looks like anything above 48V is out. Has anyone tried this for higher voltages?

Differences only on dc-dc converter, if you want higer voltage, you can buy hc05 or hc06 Bluetooth module and
https://a.aliexpress.com/_Bf93RnzW
https://a.aliexpress.com/_dY7aYI8
Or what's similar and solder it together


But s06s controller can't operate with higer voltage because Lm317 inside
Thanks Slipy,

Do you think it's easier to go totally homebrew for this as you described, or to buy the adapter and modify it to handle high voltages?

sascha121985   1 mW

1 mW
Posts: 11
Joined: Jan 10 2019 7:15am

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

Post by sascha121985 » Apr 20 2020 1:56am

Hello and good morning.

i have a little problem and i have no idea why it is so.
At the first to the facts:

- I have a rear hub motor with 1000W.
- Pas Throttle and BrakeSwitch
- KT 36/48 SVPRD-HRD01

With the standard Kunteng KT Stock Controller, i can ride my bike without any problems. Not with the full power because of the 10A rated controler but that is OK for me. The controller is only warm but not hot after a longer ride.

When i now switch to the custom controller with the open source firmware, everything is ok, too. It turns very smooth. All functions are great, but the controller gets very hot after a round about 5 km long ride, with 25 or 45 % (Assistant Level 1-3)
I have check the sequence hall sensors. They are OK.

Have one of you an idea, what i can change in my settings or what is wrong?

Best regards and thank you in advanced.
And stay healthy in this special time.
Sascha
Attachments
2020-04-20 08_41_59-Foto - Google Fotos.jpg
2020-04-20 08_41_59-Foto - Google Fotos.jpg (284.23 KiB) Viewed 1007 times
2020-04-20 08_43_59-Foto - Google Fotos.jpg
2020-04-20 08_43_59-Foto - Google Fotos.jpg (327.27 KiB) Viewed 1007 times
Last edited by sascha121985 on Apr 21 2020 1:47am, edited 1 time in total.

geofft   1 kW

1 kW
Posts: 375
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 » Apr 20 2020 6:21am

sascha121985 wrote:
Apr 20 2020 1:56am
When i now switch to the custom controller with the open source firmware, everything is ok, too. It turns very smooth. All functions are great, but the controller gets very hot after a round about 5 km long ride, with 25 or 45 % (Assistant Level 1-3)
I have check the sequence hall sensors. They are OK.

Have one of you an idea, what i can change in my settings or what is wrong?
It was noticed earlier in the development of the firmware that the OS fw produces more heat in the controller than the stock fw. Casainho did experiment with some changes in the fw (mosfet 'dead time' etc) but couldn't seem to make any improvement, so it was decided to just live with it.

I find it only causes any real problem when I run with the controller enclosed in a saddlebag. In the open air the controller hardly gets warm.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 6-fet, LCD3, 48v 12s lipo.

sascha121985   1 mW

1 mW
Posts: 11
Joined: Jan 10 2019 7:15am

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

Post by sascha121985 » Apr 20 2020 8:16am

Thanks for your answer.
But it gets so hot, that is swith off automaticly. So it is not possible to use it.
I can try to reduce the current from 100 to 80?

Best regards
Sascha

SlowCo   1 MW

1 MW
Posts: 1641
Joined: Jan 05 2015 5:43pm
Location: The Netherlands

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

Post by SlowCo » Apr 20 2020 10:23am

sascha121985 wrote:
Apr 20 2020 1:56am

- I have a rear hub motor with 1000W.
Then why are you using a 500W controller? And are you using regenerative braking with that 1kW hub?
Just get a 1500W controller if your battery and BMS can handle it.

Slipy   10 mW

10 mW
Posts: 24
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 » Apr 20 2020 5:05pm

Do you think it's easier to go totally homebrew for this as you described, or to buy the adapter and modify it to handle high voltages?
I think easier to do a homemade version, because you and someone other don't know what inside in bmsbattery module, you don't know scheme and dont know what you must to modify, on homemade version you must only choose dc dc converter from your voltage to 5v and solder six wires +- input dcdc converter voltage, +- from converter to Bluetooth module and rx tx

P. S. I hope you understand what i wrote, because I'm ukrainian and write this without a translator :)

thunderbolt   1 µW

1 µW
Posts: 3
Joined: Apr 20 2020 6:26pm

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

Post by thunderbolt » Apr 20 2020 7:33pm

Hello I'm new to the community here, I looked into Casainho and Stance work on the opensource firmware for KT controllers here
https://github.com/stancecoke/BMSBatter ... s_firmware
I do have KT controller/like which uses STM8S207 44 pin QFP. The entire firmware is built for STM105C 48 pins QFP, wondering what are the changes in the repo I may have to do to burn the EEPROM?
Any help is highly appreciated

Sorry this may be already answered somewhere

Thanks,
thunderbolt

sascha121985   1 mW

1 mW
Posts: 11
Joined: Jan 10 2019 7:15am

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

Post by sascha121985 » Apr 21 2020 1:39am

SlowCo wrote:
Apr 20 2020 10:23am
sascha121985 wrote:
Apr 20 2020 1:56am

- I have a rear hub motor with 1000W.
Then why are you using a 500W controller? And are you using regenerative braking with that 1kW hub?
Just get a 1500W controller if your battery and BMS can handle it.
I know that the controller is to small for my motor. but i got this motor for free and don't need the full power.
That is the reason of the small controller.

Do you mean that the regenerative braking is the reason of the high temperatur.
But i'm also use that feature with the stock controller.

best regards
Sascha

User avatar
stancecoke   100 kW

100 kW
Posts: 1381
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 » Apr 21 2020 1:48am

sascha121985 wrote:
Apr 20 2020 8:16am
But it gets so hot, that is swith off automaticly.
There is no "automatic switch off" in the controller. What ist getting hot? The big resistor or the FETs with the complete housing?

Have you adjusted the motor specific angle properly?

regards
stancecoke

sascha121985   1 mW

1 mW
Posts: 11
Joined: Jan 10 2019 7:15am

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

Post by sascha121985 » Apr 21 2020 6:09am

stancecoke wrote:
Apr 21 2020 1:48am
sascha121985 wrote:
Apr 20 2020 8:16am
But it gets so hot, that is swith off automaticly.
There is no "automatic switch off" in the controller. What ist getting hot? The big resistor or the FETs with the complete housing?

Have you adjusted the motor specific angle properly?

regards
stancecoke
It goes out. And after 5 minutes i can restart it again.
Not sure why, but it happend like this.

I must test what get hot. At the last ride the housing was closed, so i had no possibility to chek where the heat came from.

About the motor specific angle. I changed it several times over the bluethoothapp and checked when the engine starts best.
Or is there another way to determine that?

best regards
Sascha

User avatar
stancecoke   100 kW

100 kW
Posts: 1381
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 » Apr 21 2020 9:00am

sascha121985 wrote:
Apr 21 2020 6:09am
It goes out. And after 5 minutes i can restart it again.
This seems to be a problem with the 5V supply. Make sure, that you don't have other devices on the 5V supply than PAS, Brake and Throttle. For additional devices use a separate step down converter.
sascha121985 wrote:
Apr 21 2020 6:09am
Or is there another way to determine that?
find the angle with the lowest current draw at idle run.

regards
stancecoke

sascha121985   1 mW

1 mW
Posts: 11
Joined: Jan 10 2019 7:15am

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

Post by sascha121985 » Apr 22 2020 1:05am

stancecoke wrote:
Apr 21 2020 9:00am
sascha121985 wrote:
Apr 21 2020 6:09am
It goes out. And after 5 minutes i can restart it again.
This seems to be a problem with the 5V supply. Make sure, that you don't have other devices on the 5V supply than PAS, Brake and Throttle. For additional devices use a separate step down converter.
sascha121985 wrote:
Apr 21 2020 6:09am
Or is there another way to determine that?
find the angle with the lowest current draw at idle run.

regards
stancecoke
Good morning,

i have test it yesterday with opened controller.
After a short ride of 1km the big restistor gets warm. Round about 50°C The Mosfets were cool.Round about 28°C.
So I think the problem at a longer rides came from the resistor.
What is it for?

I have only pas, throttle, brake and the KT LCD3 direkt at the controller.
But i have the same conncetions at the stock one. The bt device has a separate stepdown.
But i would like to use the display normlay. bt only for debugging.

Should i install a stepdown also for the display? But the display does not use 5V or i'm wrong?

Best regards
Sascha

EDIT: OK the resitor is to drop the voltage down. But what schoul i do know? I check later the value of it. I use a 48V Batterie.
Do the white blue and grey cables play any role at all? ( speed limit, regen ,...)

EDIT 2: The colors are red grey or black and brown. (200 - 280 ohm) When i measured it inside the control a can see 210ohm.
I have the same resistors in both Controllers (stock and custom)

geofft   1 kW

1 kW
Posts: 375
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 » Apr 22 2020 5:34am

i have test it yesterday with opened controller.
After a short ride of 1km the big restistor gets warm. Round about 50°C The Mosfets were cool.Round about 28°C.
So I think the problem at a longer rides came from the resistor.
What is it for?
The subject of the series resistor and the associated LM317 has been much discussed on this thread previously.
Suggest you do a search on this thread for 'LM317', you'll find lots of info that should help you... :wink:
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 6-fet, LCD3, 48v 12s lipo.

sascha121985   1 mW

1 mW
Posts: 11
Joined: Jan 10 2019 7:15am

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

Post by sascha121985 » Apr 22 2020 7:31am

geofft wrote:
Apr 22 2020 5:34am
i have test it yesterday with opened controller.
After a short ride of 1km the big restistor gets warm. Round about 50°C The Mosfets were cool.Round about 28°C.
So I think the problem at a longer rides came from the resistor.
What is it for?
The subject of the series resistor and the associated LM317 has been much discussed on this thread previously.
Suggest you do a search on this thread for 'LM317', you'll find lots of info that should help you... :wink:
OK thanks a lot.
I have read the relevant threads and found out that the best was is to change the LM317 and the resistore with a V7815W.
But it is not so easy to order in germany.
What can i also use? Every dc dc converter with an Output of 15V?

john61ct   100 GW

100 GW
Posts: 7262
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

Post by john61ct » Apr 24 2020 2:19pm

Sorry not reading this whole thread.

Is there a good wiki summary of the important stuff?

What is the biggest phase-amp hardware to which this software applies?

Is true FOC available? variable regen? field weakening?

Tepa76   1 µW

1 µW
Posts: 2
Joined: Dec 11 2019 10:19am

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

Post by Tepa76 » Apr 25 2020 4:14pm

Hi all in forum!
Big respect and thank you for sharing this valuable work with open source fw!!
I had use this opportunity during winter time and update my bike from 36v square to 48v simplified FOC and now after first test drive… just to say wow everything seems to work near perfect.
So quiet and smooth operation and nice jump for max speed 8)

Shortly about background:
After riding season in Finland late autumn 19.. when I maintenance/inspect my hub motor I found there was already machined groves to hall sensors.. I've started to research how to go for sine wave control, I found these cheap Kunteng sine type controllers might suit for my needs, and if there is a some reason i can go even open source, witch isn’t my main target at beginning!

When i installing hall sensors I found that they was in 60deg orientation instead of 120deg and after playing with original-fw settings I found that stock couldn't wont work properly and quite quickly I jump to for OSEC.

Here is little summary what changes i had to make to get all this to work at this point. [Branch Master]

60deg commutation I’ve adapted by invert c-phase signal -> changing following line in motor.c

Code: Select all

        //hall_sensors = (GPIO_ReadInputData(HALL_SENSORS__PORT) & (HALL_SENSORS_MASK));
	hall_sensors = ((GPIO_ReadInputData(HALL_SENSORS__PORT) & (HALL_SENSORS_MASK)) ^4);
	
Same time when motor was open I added a separate hall sensor and magnet for embedded "in hub" speed signal and also a LM35 temperature sensor for winding.
Image

Following changes and additions i have made to get LCD6 (stock fw) to work with these changes.

ACAcommons.c

Code: Select all

void updateX4(void) {
ui16_x4_value = ui16_adc_read_x4_value(); 
	//TEPA76 ADD
	//LM35 has scale 0-150C/0-1500mV
	ui8_motor_temperature =  (ui16_x4_value * 500) >> 10;  //LM35 degrees  C ... type changed to uint propably don't needed..
}
display.c file with comments

Code: Select all

/*
Generic display init and update functions
Written by jenkie and Thomas Jarosch
Functions for the Nokia graphical screen mainly by m--k
King-Meter library and support written by Michael Fabry

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#include <stdio.h>
#include "stm8s.h"
#include "display.h"
#include "main.h"
#include "config.h"
#include "stm8s_itc.h"
#include "uart.h"
#include "adc.h"
#include "brake.h"
#include "ACAeeprom.h"
#include "interrupts.h"
#include "ACAcontrollerState.h"

#ifdef DISPLAY_TYPE_KT_LCD3

display_view_type display_view;
display_mode_type display_mode; //currently display mode
float current_display;
uint8_t battery_percent_fromcapacity = 11; //hier nur als Konstante um Batterie normal zu senden....


uint8_t ui8_tx_buffer[12];
uint8_t ui8_j;
uint8_t ui8_crc;
uint16_t ui16_wheel_period_ms = 4500;
uint16_t ui16_battery_bars_calc = 0;
uint8_t ui8_battery_soc = 12;
uint8_t ui16_error;
uint8_t ui8_rx_buffer[13];
uint8_t ui8_rx_buffer_counter = 0;
uint8_t ui8_byte_received;
uint8_t ui8_moving_indication = 0;
uint8_t ui8_UARTCounter = 0;
uint8_t ui8_controlByte10 = 0;		//TEPA76 added Byte10 ...cadence
uint8_t ui8_PAS_period_ms = 0;		//TEPA76 added Byte11 ...cadence

volatile struc_lcd_configuration_variables lcd_configuration_variables;

void display_init(){
	// noop just here to have a common interface
}

//#define DIAGNOSTICS || #define DISPLAY_TYPE_KT_LCD3 || #define BLUOSEC
void send_message() {

	// prepare moving indication info
	ui8_moving_indication = 0;
	if (brake_is_set()) {ui8_moving_indication |= (1 << 5);}			//brake is on

	//if (throttle_is_set ()) { ui8_moving_indication |= (1 << 1); }
	if(ui16_momentary_throttle > 1){ui8_moving_indication |= (1 << 1);} 		//TEPA76 added Set bit1 when momentary Throttle has values
	else if (ui8_adc_read_throttle() > 5){ui8_moving_indication |= (1 << 0);}	//TEPA76 added Set bit0 when Throttle sensor is connected but leave clear if momentary have value

	//if (ebike_app_cruise_control_is_set ()) { ui8_moving_indication |= (1 << 3); }


	//TEPA76 added Cadence display in LCD6
	ui8_controlByte10 |= (1 << 7);		//set bit7 Byte10 by default... unknown function
	if (PAS_is_active) {
	    ui8_moving_indication |= (1 << 4);	//bit4 for enable cadence calculation and pedaling symbol in LCD6
	    ui8_controlByte10 &= ~(1 << 7);	//clear bit7 Byte10 when pedaling... unknown function
	}



        //TEPA76 added for cadence function in LCD6
	ui8_PAS_period_ms =  ((uint32_t) ui16_time_ticks_between_pas_interrupt << 6) / 1000;	//LCD6 protocol takes periods in ms. Send raw value since LCD6 buffering for avg value


	if (((ui16_aca_flags & EXTERNAL_SPEED_SENSOR) == EXTERNAL_SPEED_SENSOR)) {
		if (ui16_time_ticks_between_speed_interrupt > 65000) {
			ui16_wheel_period_ms = 4500;
		} else {
			ui16_wheel_period_ms = (uint16_t) ((float) ui16_time_ticks_between_speed_interrupt / ((float) ui16_pwm_cycles_second / 1000.0)); //must be /1000 devided in /125/8 for better resolution
		}
	}else{
		if (ui32_erps_filtered == 0) {
			ui16_wheel_period_ms = 4500;
		} else {
			ui16_wheel_period_ms = (uint16_t) (1000.0 * (float) ui8_gear_ratio / (float) ui32_erps_filtered);
		}
	}

	// calc battery pack state of charge (SOC)
	ui16_battery_bars_calc = ui8_adc_read_battery_voltage() - ui8_s_battery_voltage_min;
	ui16_battery_bars_calc<<=8;
	ui16_battery_bars_calc /=(ui8_s_battery_voltage_max-ui8_s_battery_voltage_min);
	
	if (ui16_battery_bars_calc > 200) {
		ui8_battery_soc = 16;
	}// 4 bars | full
	else if (ui16_battery_bars_calc > 150) {
		ui8_battery_soc = 12;
	}// 3 bars
	else if (ui16_battery_bars_calc > 100) {
		ui8_battery_soc = 8;
	}// 2 bars
	else if (ui16_battery_bars_calc > 50) {
		ui8_battery_soc = 4;
	}// 1 bar
	else {
		ui8_battery_soc = 3;
	} // empty

	ui8_tx_buffer [0] = 65;
	// B1: battery level
	ui8_tx_buffer [1] = ui8_battery_soc;
	// B2: 24V controller
	ui8_tx_buffer [2] = ui8_battery_voltage_nominal;
	// B3: speed, wheel rotation period, ms; period(ms)=B3*256+B4;
	ui8_tx_buffer [3] = (ui16_wheel_period_ms >> 8) & 0xff;
	ui8_tx_buffer [4] = ui16_wheel_period_ms & 0xff;

	//Send confirming signal for activating offroad mode
	if (ui8_offroad_state == 4) { //quitting signal for offroad mode enabled. Shows about 80 km/h for three seconds

		ui8_tx_buffer [3] = (100 >> 8) & 0xff; //100ms are about 80 km/h @ 28" 2200mm wheel circumference
		ui8_tx_buffer [4] = 100 & 0xff;
	}

	// B5: error info display
	ui8_tx_buffer [5] = ui16_error;

	// B6: CRC: xor B1,B2,B3,B4,B5,B7,B8,B9,B10,B11
	// 0 value so no effect on xor operation for now
	ui8_tx_buffer [6] = 0;

	// B7: moving mode indication, bit
	// bit throttle 	:0	-> clear when throttle
	// bit throttle 	:1	-> set when throttle
	// bit pas		:4	-> set when pedaling
	// PAS_is_active
	ui8_tx_buffer [7] = ui8_moving_indication;


	// B8: 4x controller current
	// Vbat = 30V:
	// - B8 = 255, LCD shows 1912 watts
	// - B8 = 250, LCD shows 1875 watts
	// - B8 = 100, LCD shows 750 watts
	// each unit of B8 = 0.25A
        ui8_tx_buffer [8] = (uint8_t) ((((ui16_BatteryCurrent - ui16_current_cal_b + 1) << 2)*10) / ui8_current_cal_a);

	// B9: motor temperature
	//if temperature >= 120 C sign in LCD screen is flashing. e.g 0xDA T=-23C, 0x34 T=67C
	ui8_tx_buffer [9] = ui8_motor_temperature - 15; //according to documentation at endless sphere
	
	
	
        // B10 and B11: Cadence
	ui8_tx_buffer [10] = ui8_controlByte10;			//bit4 enable for cadence calculation and pedaling symbol in LCD6, bit7 is invert of bit4
	ui8_tx_buffer [11] = ui8_PAS_period_ms;			//PAS pulse period ms


	// calculate CRC xor
	ui8_crc = 0;
	for (ui8_j = 1; ui8_j <= 11; ui8_j++) {
		ui8_crc ^= ui8_tx_buffer[ui8_j];
	}

	ui8_tx_buffer [6] = ui8_crc;

	// send the package over UART
	for (ui8_j = 0; ui8_j <= 11; ui8_j++) {
		uart_put_buffered(ui8_tx_buffer [ui8_j]);
	}
}

/********************************************************************************************/
// Process received package from the LCD
//

void digestLcdValues(void) {

	ui8_assistlevel_global = lcd_configuration_variables.ui8_assist_level + 80; // always add max regen 

	// added by DerBastler Light On/Off
	light_stat = (light_stat&~128) | lcd_configuration_variables.ui8_light_On; // only update 7th bit, 1st bit is current status
	
	walk_stat = lcd_configuration_variables.ui8_WalkModus_On;	//TEPA76 added

	if (lcd_configuration_variables.ui8_max_speed != ui8_speedlimit_kph) {
		ui8_speedlimit_kph = lcd_configuration_variables.ui8_max_speed;
		eeprom_write(OFFSET_MAX_SPEED_DEFAULT, lcd_configuration_variables.ui8_max_speed);
	}
}

// see if we have a received package to be processed
//uint8_t ui8_count = 0;
void display_update() {

	// fill local buffer from uart ringbuffer
	uart_fill_rx_packet_buffer(ui8_rx_buffer, 13, &ui8_UARTCounter);
	
	// Check for reception of complete message
	if ((ui8_UARTCounter > 12) || (ui8_rx_buffer[ui8_UARTCounter - 1] == 0x0E)) {
		ui8_UARTCounter = 0;

		// validation of the package data
		ui8_crc = 0;
		for (ui8_j = 0; ui8_j <= 12; ui8_j++) {
			
			if (ui8_j == 5) continue; // don't xor B5 
			ui8_crc ^= ui8_rx_buffer[ui8_j];
		}

		// 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
		{
			// added by DerBastler Light On/Off 
			lcd_configuration_variables.ui8_light_On = ui8_rx_buffer [1] & 128;
			// added by DerBastler Walk On/Off 
			//lcd_configuration_variables.ui8_WalkModus_On = ui8_rx_buffer [1] & 64;
			lcd_configuration_variables.ui8_WalkModus_On = (ui8_rx_buffer [1] & 6)==6;	//TEPA76 modded for LCD6

			lcd_configuration_variables.ui8_assist_level = ui8_rx_buffer [1] & 7;
			lcd_configuration_variables.ui8_max_speed = 10 + ((ui8_rx_buffer [2] & 248) >> 3) | (ui8_rx_buffer [4] & 32);
			lcd_configuration_variables.ui8_wheel_size = ((ui8_rx_buffer [4] & 192) >> 6) | ((ui8_rx_buffer [2] & 7) << 2);

			lcd_configuration_variables.ui8_p1 = ui8_rx_buffer[3];
			lcd_configuration_variables.ui8_p2 = ui8_rx_buffer[4] & 0x07;
			lcd_configuration_variables.ui8_p3 = ui8_rx_buffer[4] & 0x08;
			lcd_configuration_variables.ui8_p4 = ui8_rx_buffer[4] & 0x10;
			lcd_configuration_variables.ui8_p5 = ui8_rx_buffer[0];

			lcd_configuration_variables.ui8_c1 = (ui8_rx_buffer[6] & 0x38) >> 3;
			lcd_configuration_variables.ui8_c2 = (ui8_rx_buffer[6] & 0x37);
			lcd_configuration_variables.ui8_c4 = (ui8_rx_buffer[8] & 0xE0) >> 5;
			lcd_configuration_variables.ui8_c5 = (ui8_rx_buffer[7] & 0x0F);
			lcd_configuration_variables.ui8_c12 = (ui8_rx_buffer[9] & 0x0F);
			lcd_configuration_variables.ui8_c13 = (ui8_rx_buffer[10] & 0x1C) >> 2;
			lcd_configuration_variables.ui8_c14 = (ui8_rx_buffer[7] & 0x60) >> 5;

			digestLcdValues();
			send_message();
			/*
			if(ui8_count > 19){
			  send_message();
			  ui8_count =0;
			}
			ui8_count ++;
			*/
		}
	}
}

#endif
Here's a some early stage shot when battery current was limited to 13A.. first with throttle to accelerate at full speed (without load) then gradually braking to go for current limiting point.
Image

Over all very impressive test drive behind. I had only a small torque pumping in couple of first pedaling s, witch i believe to get fixed by pid tuning.

Image

Next phase i have plan to add some functionality to walk assist and cruise functions. I will to ask what is the suggested place to give or manipulate some fixed torque request by user while pressing a buttons?

Also in some point during dev the lcd6 out temp started to showing constant -22 C°
Did some one known which way it measures a temp? inside button enclosure there was a component printed "TEM".. perhaps that was a some short of thermistor? at least i have infinite resistance over it!

Best regards,
Tepa76

User avatar
stancecoke   100 kW

100 kW
Posts: 1381
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 » Apr 26 2020 4:47am

Tepa76 wrote:
Apr 25 2020 4:14pm
Here is little summary what changes i had to make to get all this to work at this point
nice to get some fresh wind into the project!

The setpoint for the battery current is defined in the acasetpoint.c

If you want to add push assist or auto cruise, you have to define it there.

regards
stancecoke

TheQuiettt   1 µW

1 µW
Posts: 2
Joined: Apr 26 2020 7:41am

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

Post by TheQuiettt » Apr 26 2020 10:00am

Hello everyone, I am looking for software for the KT60SVPRCK-JLS02 (60V 45A) controller. Will this software work with this controller?

obcd   100 W

100 W
Posts: 159
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

Post by obcd » Apr 26 2020 10:12am

Two things you could check:
1. What microcontroller is the controller using?
2. Does it measure the phase current.

If it has a different microcontroller, this software can't be used.
If it's not measuring phase current, it won't work either.

Sometimes there is room for a phase measurement chip on the board, but the chip isn't mounted.

TheQuiettt   1 µW

1 µW
Posts: 2
Joined: Apr 26 2020 7:41am

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

Post by TheQuiettt » Apr 26 2020 10:28am

The microprocessor in the controller is STM8S105C6T6.
It has a phase current sensor.
Will this 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 » Apr 27 2020 1:30pm

Hello , forum

I'm new here. Trying to get work OpenSource controller.
I have this one from ebay :
Controller1.PNG
Controller1.PNG (87.73 KiB) Viewed 775 times
Controller2.PNG
Controller2.PNG (473.6 KiB) Viewed 775 times
I flashed it succsefuly . Installed Bluosec at phone , connection is ok.
But motor does not start , no impulses at output. Throotle is ok , it can be monitored by Bluosec.
Tryed to measure by scope. Results : Here are PWM at High side , but no any impulses at low side .
I checked directly on cpu PINs , all three phases at high side has PWM , but on low side - no.
May some conditions are missing ? Checked brake , its "0"
What can be wrong ?

Br , Linas

User avatar
stancecoke   100 kW

100 kW
Posts: 1381
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 » Apr 28 2020 4:33am

shellton wrote:
Apr 27 2020 1:30pm
I have this one from ebay
Can you Check If it uses the same schematic as known?

regards
stancecoke

Post Reply