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

cnrd said:
Is it documented anywhere how these are mapped? If not, can someone point me to where they are set in the code?

The C and P parameters are mapped to the struct lcd_configuration_variables in the display.c, but they are not used for any action in the recent firmware,

Code:
			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;

So feel free to add any function to the parameters, if you want. :wink:

regards
stancecoke
 
Thanks!

EDIT: Another question, is there any way to figure out which GPIO is where on the PCB? As I'm would love to know where the light pin is on my PCB:

Code:
#define LIGHT__PIN                  GPIO_PIN_4
#define LIGHT__PORT                 GPIOC
 
Just look for the datasheet of the microcontroller. It should give you a clue which pins are port C.

Next, look in the code what GPIO_PIN_4 is defined as. It gives you a clue which bit of port C is used for the lights.

On some schematics I found PC4 and PC7 go directly to a header. Those 2 are good candidates.
 
cnrd said:
As I'm would love to know where the light pin is on my PCB:
The connector for the light module is marked with "DDB" on some PCBs:

https://endless-sphere.com/forums/viewtopic.php?f=2&t=79763#p1177510

https://endless-sphere.com/forums/viewtopic.php?f=30&t=100898

regards
stancecoke
 
How would you connect the programmer if you are making changes to the firmware?
There are 2 things unclear.
1. The usb programming stick 5V is connected to the controller 5V. I assume this powers the microcontroller with the pc usb 5V so that the controller can be programmed without the need to power it. Or is that 5V used used to power part of the ST-2 programmer?
2. In case it's used to power the microcontroller, can I just power the controller with 36V, or is there a risk that it might drive some of it's outputs during programming and kill some fets doing this? If the st-2 programmer is driving the reset, I assume this shouldn't be much of a problem.

I understand that this situation is also possible if the firmware freezes due to a bug, so the supply should be current limited during initial testing to avoid magic smoke.

So basically I think a setup with a 36V current limited lab power supply and leaving the programmer 5V line disconnected should work?

If I use an unknown motor, I seem to have 2 unknown important parameters being 'correction angle' and 'motor spec angle'.
Can I slowly change those and observe the phase current for their optimal settings? Does the motor needs to be loaded for this?
Is it somewhere described how you should obtain these parameters?
 
obcd said:
I assume this powers the microcontroller with the pc usb 5V so that the controller can be programmed without the need to power it.

Yes, correct.

obcd said:
In case it's used to power the microcontroller, can I just power the controller with 36V

I've done this a few times by accident, fortunately without smoke as result 8), but you should avoid that.

obcd said:
I seem to have 2 unknown important parameters being 'correction angle' and 'motor spec angle'.

You should not change the correction angle, keep it at 127. It's only for finetuning for people who really know what they do.
The motor specific angle can be adjusted slightly. Run the motor idling and check the battery current. Change the angle in steps of 5 and find the value, where you get minimum current at idle run.

See the wiki also!

regards
stancecoke
 
As I needed a controller in a hurry, I bought the KT36ZWSRMT-XW01DL 36V 11A one.

As expected from the serial number, the phase current measuring chip is not present on the board.

On the S06S, that chip is marked as ACS711. There are 3 different types of that chip for different currents.
As the output voltage differs, depending upon the one you use, I was wondering how the firmware knew which was used?
Or do all controllers use the 25A version?

While I might be able to figure that out studying the firmware sources, there also is a small additional pcb in the controller.
It has the marking KTE-QHE131028 written on the pcb and has a 8S003F3P6 sti microcontroller on one side of the board and an lm339 on the other side. It's connected to pins PD2, PD3 and PD4 of the main microcontroller and has 3 wires that seem to come from the 3 output driver stages. It also has a 5V and GND wire connection. The 3 wires that come from the output stages have the traditional yellow green and blue colors, and the 3 wires going to the microcontroller also have those colors.

I read that this controller has some sort of torque sensor simulation and assume the little pcb is related to that functionallity.
So, my question, can I use the osf firmware on this controller if I install the phase current measuring chip on the green phase wire? Can I simply ignore that small sub pcb in the controller?

Once I reflash the microcontroller with the osf, there is no way back. I would hate to destroy a brand new controller doing that and hope someone else might have come across one of these and knows if they can be used.

There is also a second even smaller pcb, but that's just the light switch circuit.

Thanks in advance for reading this till here and possible answers if you have a clue.
 
obcd said:
As the output voltage differs, depending upon the one you use, I was wondering how the firmware knew which was used?
The differece is only in gain, not in offset. We are only looking at the zero-crossing of the phase current, so the gain doesn't matter.


obcd said:
assume the little pcb is related to that functionallity
no, this additional pcb is for sensorless mode in six-step-commutation. It emulates the Hall-sensor signals.
See casainhos photos.

obcd said:
So, my question, can I use the osf firmware on this controller if I install the phase current measuring chip on the green phase wire? Can I simply ignore that small sub pcb in the controller?

you have to remove the small sub pcb and solder in the hallsensor-wires instead (if they are not existing in parallel already)
If you attach the ACS711, you can use the OSEC with full functionality.

Have fun with the handicraft! :wink:

regards
stancecoke
 
Again, thanks for the answers.

There is already a connector for the hall sensors as well.

The small pcb connects to some io lines on the main microcontroller that are not connected according to the S06S schematics,
PD2 PD3 and PD4.

The controller indeed can work on brushless motors as well. As I want to use it for a pump motor, I doubt it's an option as I don't want to run the pomp motor manually before it starts.

All I need is a start/stop switch and a fixed speed setting using a potentiometer on the throttle input.

It's a 3 phase 36V 5A motor with hall sensors, so I assume the controller should be able to make it rotate. (No idea what else to use.)

regards, stay safe.
 
obcd said:
All I need is a start/stop switch and a fixed speed setting using a potentiometer on the throttle input.

So just do it, you don't need the open source firmware for that purpose.
Just a switch between the red and the blue wire of the display connector and the poti on the throttle input. Connect the battery and the phase wires. That should work with the stock firmware in sensorless mode. If the motor runs in the wrong direction, just swap two phase wires.

The only advantage of the custom firmware would be less noise from motor, due to the sinosodial commutation.

regards
stancecoke
 
Doesn't sensorless need minimal rotation at startup to figure out the rotor position?
Can it start running from a standstill without issues?
 
Yes, the controller starts in open loop, when the speed is high enough it will switch to closed loop. No problem with a pump, where the load is low at low speed...

regards
stancecoke
 
That pomp design is based upon a rubber tube that is pushed flat at 2 positions that move with the rotating motor.
The product that will be pumped is desinfection hand gel, so it's not as liquid as water. Basically, the motor pushes the gel trough the tube.
The motor has a gear box that reduces the axe speed from approx 280 rev. / min to 10 rev. / min.
So to me, it seems more like the motor load won't change much when the motor is coming up to speed.
On a cetrifugal pump, the situation would be different.
Due to the nature of the product they want to create a barrier between the rotating parts and the parts with the liquid.

Maybe I can use the original firmware and connect the hall sensors, or will that just work with the type of motors the controllers are designed 4 as the hall positions relative to the rotor position could be different?

Sorry for all those questions. I just don't want to mess things up, specially since it's a bit of an unusual setup.

It's the watson marlow 630 series:
http://www.watson-marlow.com/gb-en/

regards.
 
Has anyone observed issues with using a throttle on the x4 input? I have a resting voltage of 5v, which seems to be causing the issue as it reads at 4.3v when connected. I have the KT36ZWSRTB-SJT02LB

Does anyone know why it's pulled to +5v? It's the same on three identical units i have and prevents me from using my otherwise functioning, torque sensor and throttle simultaneously.

Any known workarounds would be really appreciated. (Thanks to Geoff for helping me isolate my problem)

I've used a regular Wuxing thumb throttle and a slimline throttle from Grin:

https://www.ebikes.ca/shop/electric-bicycle-parts/throttles/t-htwist-slim.html

https://www.amazon.co.uk/Thumb-Throttle-Control-Pedelec-Electric/dp/B00ZRPRJBG
 
davideserin said:
I have a resting voltage of 5v, which seems to be causing the issue as it reads at 4.3v when connected.
There seem to be different PCB assemblies. Some have a pullup resistor at X4, some doesn't. See this post:
https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&p=1426450&hilit=temperature+sensor#p1426450

So you can try two solutions: Identify the pullup resistor on the pcb and remove it or add an e.g. 1k pull down resistor between X4 and GND. First solution should be preferred :wink:

obcd said:
Maybe I can use the original firmware and connect the hall sensors, or will that just work with the type of motors the controllers are designed 4 as the hall positions relative to the rotor position could be different?
Just try! But you have to find the right Phase- Hallsensor combination,
https://www.pedelecforum.de/wiki/lib/exe/fetch.php?cache=&w=605&h=700&tok=537d5d&media=tipps:motorphasen-_und_hallsensoren_anschlussreihenfolge_herausfinden.png

regards
stancecoke
 
Hi, I try develop my own lcd using arduino but I have problem with uart.
So I use the usb uart conventer and H TERM to check transmison but the controller dont send any data.
Do you know whats wrong?
Thanks for any help .
 
Lesny said:
the controller dont send any data.
The controller only sends data when it receives a valid message from the display. It "answers" to the query of the display.

Only in diagnostics-mode, it sends data continously.

regards
stancecoke
 
stancecoke said:
Lesny said:
the controller dont send any data.
The controller only sends data when it receives a valid message from the display. It "answers" to the query of the display.

Only in diagnostics-mode, it sends data continously.

regards
stancecoke

Thanks for tip.
 
So I send to controller this data byte by byte 0012546011006464015014 but controller dont receive any data (I use bluetoth terminal). What I make wrong?

This is my code:

byte txBuffer[13];
byte assistlvl=0;
uint8_t crc = 0x02;
void setup() {
Serial.begin(9600);
txBuffer[0] = 0; //B0 od 0-40 konfiguracja odczytu napięcia
txBuffer[1] = assistlvl; //B1 poziom wspomagania od 0-6; 6 tryb walking
txBuffer[2] = 0b01111101; //B2
txBuffer[3] = 46; //B3 parametr P1 ilość magnesów x przełożenie (w przypadku kt open source wartość jest olewana ale coś trzeba wpisać)
txBuffer[4] = 0b00000000; //B4
txBuffer[5] = 0; //B5
txBuffer[6] = 0b00000000; //B6
txBuffer[7] = 0b01000000; //B7
txBuffer[8] = 0b01000000; //B8
txBuffer[9] = 0b00000000; //B9
txBuffer[10] = 0b00000001; //B10
txBuffer[11] = 0x32; //B11
txBuffer[12] = 0x0E; //B12
}

void loop() {
int i=0;

for (i = 0; i < 13; ++i){
crc ^= txBuffer;
}
txBuffer[5] = crc;
for (i=0;i<13;i++){
Serial.print(txBuffer);
}

}
 
stancecoke said:
There seem to be different PCB assemblies. Some have a pullup resistor at X4, some doesn't. See this post:
https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&p=1426450&hilit=temperature+sensor#p1426450

So you can try two solutions: Identify the pullup resistor on the pcb and remove it or add an e.g. 1k pull down resistor between X4 and GND. First solution should be preferred :wink:

regards
stancecoke

This worked for me, thanks so much. I simply soldered a 1k resistor at the back of the plug between signal and ground.

I have x4Throttle branch working now with both throttle on x4 and Sempu torque signal on the throttle input.

I noticed a few possible bugs that i'll report once i'm more familiar with the setup and can recreate and confirm the issues clearly.

Thanks,
David.
 
Lesny said:
What I make wrong?

First idea: You have to reset crc in each loop run, or calculate the checksum outside the loop. XOR2 is the last step normally, I don't know if it's a difference.
add a delay of 500ms in the loop.

https://endless-sphere.com/forums/viewtopic.php?t=73471


davideserin said:
This worked for me,
:thumb:

davideserin said:
I noticed a few possible bugs that i'll report once i'm more familiar with the setup and can recreate and confirm the issues clearly.
I'm looking forward to your feedback!

regards
stancecoke
 
Hi stancecoke,

The communications works fine but I have another question if I use OpenSource firmware which parameters from kt lcd3 is used by the controller ?
 
Lesny said:
which parameters from kt lcd3 is used by the controller ?
Only light and assistlevel, see this post:
https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&start=3875#p1538316

Feel free to add any function to the parameters :wink:

regards
stancecoke
 
stancecoke said:
Lesny said:
which parameters from kt lcd3 is used by the controller ?
Only light and assistlevel, see this post:
https://endless-sphere.com/forums/viewtopic.php?f=30&t=87870&start=3875#p1538316

Feel free to add any function to the parameters :wink:

regards
stancecoke

hmm
it is possible to change the configuration so that the controller uses the speed setting sent by uart like ori firmware ?
 
Back
Top