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

stancecoke said:
Demion said:
when you hold DOWN button to enter cruise mode.
The "long press button down" is a "6" in the three least signifikant bits of byte 2.
Thanks again and sorry if not on topic.
I connected controller to arduino succesfully and all settings and data working well.
But when I set assist level to 6 (during full throttle) it instantly switches to slow walk mode instead of going into cruise mode, as stated in manual. (When the vehicle is traveling above 7Km/H, hold DOWN button for 3 seconds to set the cruise function.)

Anyone actually tested cruise mode? Can someone please dump packet from LCD3 (with button down and cruise on) if possible, just to be sure, thanks.
Maybe some other bits need to be set, or maybe problem is my controller is ZWSRMT. I dont have LCD3 to test myself.

Update: When P3 = 0 or C4=4 (control throttle by assist level) instantly slow walk mode, P3 = 1 or C4=0 no effect (no cruise, slow walk mode after throttle release).
Cruise with blue + black cable shorted and hold throttle for 8-10 seconds working fine.

I tried another approach - connecting throttle signal wire to arduino analog pin. I get values 0.8v - 4v according to throttle values. When I connect arduino digital PWM pin to controller throttle signal pin and try analogWrite motor just twitches and does not run. Any ideas what I might be doing wrong? Thanks in advance.

Update2: It acutally worked with RC Low Pass Filtering. PWM PIN - 10k resistor - 22uf capacitor - controller (common ground).
I probably need much less capacitor value like 100nf. I only had 22uf available for now.

Now I can control throttle and break (connect red pin to arduino digital / analog to read sensor, blue (black) to ground) and make cruise. I will post code on github soon if anyone interested. By the way I am sending all data from controller to wifi access point ajax web page with esp8266 from there you can also change controller settings.
 
-dg said:
stancecoke said:
Oh, sorry for the confusion. I just tried it with my recent fork. It doesn't compile with debug info. I tried with casainhos TSDZ2 code,that worked. So no difference between windows and linux behavior.

But I think Casainho gave the important hint already:
casainho said:
There is an important issue: we can't use static variables with initial values, liker 5 for instance, other way compilation fails. Because of this I am using a lot of global variables and this makes the code hard to read/understand.
I'm not sure about the statics thing being the cause, but it's certainly worth testing. I'll check that out.

Ok, I can fully reproduce the compile segfault with just the attached simple program. Build it with:

Code:
sdcc -mstm8 --std-sdcc11 --out-fmt-elf --debug  main.c

I have added this to the SDCC bug report.

As Casainho surmised, statics with initializers are the problem. However, this is only if they are declared inside a function. We can use statics without initializers anywhere. And we can use statics with initializers at the file level. This at least avoids making everything global.

Bad:
Code:
main() {
    static int s = 1;    // fails: initialized static in function
    ...
}
OK:
Code:
main() {
    static int s;        // ok: static in function with separate initializer
    s = 1;               // just as good anyway since main() is called only once
    ...
}

static int f = 42;       // ok: file level initialized static
foo() {
    if (--f < 0)
        ...
}
 
Please does anyone know what kind of temperature sensor is used inside of lcd3? I removed and measured it, wanted to use externaly for battery temp. It was around 27k but I can't get anything with that value to work. Then I lost them and now I got 2 displays showing -34°C..
 
honya96 said:
Please does anyone know what kind of temperature sensor is used inside of lcd3? I removed and measured it, wanted to use externaly for battery temp. It was around 27k but I can't get anything with that value to work. Then I lost them and now I got 2 displays showing -34°C..
There is sone information on the schematic,, I thibk on TSDZ2 dec page you find thatpdfschematic.
 
-dg said:
We can use statics without initializers anywhere. And we can use statics with initializers at the file level. This at least avoids making everything global.

Thank you for that explanation! I followed your advice in my fork, now it compiles without errors with the debug option enabled :)

regards
stancecoke
 
Hello peeps !

I'm currently building up an e-bike, I bought a conversion kit from amazon, which is supposed to deliver 1500w (rear hub motor), controlled by a kt36-48svp controller, with a lcd3. My battery is made of 13 samsung 30q in series, and 4 in parallel (13s4p, 12ah). But that controller draws too many amps from my battery (the controller is rated for 45 amps max, and 54.6v x 45 amps = almost 2.5kw !!) and result in a cut after 3-4 seconds of keeping the throttle wide open. Voltage is sagging like crazy ! So I wanna take that number down by flashing the controller's chip (a stm8s105c6t6), 25-30 amps seems more reasonnable.
I followed the tutorial ( https://opensourceebikefirmware.bitbucket.io/windows_instructions/index1.html ) and bought a st link v2 dongle, and I'm stuck at a part, where I got to change a string to unlock the read protection, to 00 00 02 00 00 00 00 00, but when I try to edit that line, I realize there's one more pack of 00, not just 8. Do you happen to know if it changes anything ? I just add 00 at the end of the string and I'm good ? Someone here already tried to unlock that particular chip (stm8s105c6t6) ? I chose stm8s105x6 in the "configure" tab, it seemed like the right choice.


Any help would be really great, as I'm quite stuck on that, I don't want to brick my dear controller. I'm close to getting that ride really perfectly tuned !

Thanks in advance folks !
 
Lem0n said:
Any help would be really great, as I'm quite stuck on that, I don't want to brick my dear controller. I'm close to getting that ride really perfectly tuned !

Go ahead and read chapters 2-4 of the tutorial also, you will learn, that you just have to press the "write option bytes" button of the Java tool to do the job :wink:

regards
stancecoke
 
Thanks for your answer. So to unlock the chip, I just use the java tool ? I dont overwrite that string (00 00 02 00 00 00 00 00) manually over the 00 00 00 00 00 00 00 00 00 already existing ? It's that extra 00 that's bothering me :(
 
Lem0n said:
Thanks for your answer. So to unlock the chip, I just use the java tool ? I dont overwrite that string (00 00 02 00 00 00 00 00) manually over the 00 00 00 00 00 00 00 00 00 already existing ? It's that extra 00 that's bothering me :(

Do you know that you can limit the current on lcd3 with stock fw? Or bypass your bms for discharge only..
 
I'm a bit weak on math, so understanding the actual motor control algorithm has been challenging. I've seen lots of discussion of the Clarke and Park transformations without absorbing much.

This video explained this in a way I can sort of understand. The animations here along with the matrices really made it clear what they are. I took a linear algebra class a couple years ago to help me understand more of the machine learning algorithms. I was amazed to see that matrix multiplication is at the heart of most machine learning and things like google page rank etc. So I was delighted to see that that motor control also based on the matrix product operation.

https://www.youtube.com/watch?v=vdeVVTltr1M

Sorry for the bad production values and spotty sound, the content really
worked for me.
 
honya96 said:
Lem0n said:
Thanks for your answer. So to unlock the chip, I just use the java tool ? I dont overwrite that string (00 00 02 00 00 00 00 00) manually over the 00 00 00 00 00 00 00 00 00 already existing ? It's that extra 00 that's bothering me :(

Do you know that you can limit the current on lcd3 with stock fw? Or bypass your bms for discharge only..

Sadly, with the "Cx" (I forgot which number) it's only possible to take down 5 amps, as theres 10 settings, -1, -1.5, -2, -2.5 ... to -5. And -5 wasn't enough, as I wanted to go from 45 to 25-30.
 
Do anyone knows how to display km/h on the lcd3 once the kt controller is flashed ? The lcd is displaying some stuff like temperature, my old km records, but watts and km/h are stuck to 0. If someone knows that'd be greatly appreciated :)
 
There seems to be something wrong/different with your LCD3. Perhaps it uses a different XOR for the checksum.
You can try different numbers in this part of the display.c:

Code:
   if (((ui8_crc ^ 10) == ui8_rx_buffer [7])     || // some versions of CRC LCD5 (??)
    ((ui8_crc ^ 5) == ui8_rx_buffer [7])     || // CRC LCD3 (tested with KT36/48SVPR, from PSWpower)
    ((ui8_crc ^ 9) == ui8_rx_buffer [7])     || // CRC LCD5
((ui8_crc ^ 2) == ui8_rx_buffer [7])) // CRC LCD3

2,5,9 and 10 are already checked in the recent code.

You can try to reset the display via parameter C10 or try other protocol settings via parameter C11

regards
stancecoke
 
geofft said:
I've added the tutorial now 8)
https://opensourceebikefirmware.bitbuck ... ndex6.html

I hope it is detailed enough, as it's just a "quick and dirty" document.

Nice work, BT HC-05 module ordered.

Have now received the HC-05 BT module and wired it as shown and it pairs with (android) tablet ok.
'Diagnostics' is selected in configurator, Blueterm is loaded and it connects to the HC-05 without any problem.
Controller is powering up and responds normally to pas and throttle.

Just can't seem to get any data to appear on the blueterm screen. I haven't changed any settings in the Diagnostics section of main.c but I guess I should see data with the default settings...?

Any suggestions gratefully received.. :?
 
stancecoke said:
geofft said:
Any suggestions gratefully received.. :?

Try to swap rx and tx!

Thanks, now working just fine.... :)

I can see that this pumps out a LOT of data very fast, how do you target the area where you had any particular problem..?
 
Normally I log a complete testride and do the analysis in Excel afterwards. The result is something like this 8)

index.php


or a more recent and more confusing example: :?
Example Log.PNG

regards
stancecoke
 
stancecoke said:
Normally I log a complete testride and do the analysis in Excel afterwards.

I see, using Excel as a datalog viewer. I wondered how you were producing those wonderful graphs.

I look forward to using my new gadget for real sometime.. :wink:
 
geofft said:
I look forward to using my new gadget for real sometime.. :wink:

you can print out ui16_current_cal_b in column 1 instead of dutycycle for example and compare it with the recent current in column three, to see why the motor pushed at standstill...

regards
stancecoke
 
Hi
I got KT48SVPRM-XFCF06 (board KTE-9S5-J5). It has 9 transistors K150E09NE. Processor STM8S105C6T6. Current sensor acs711 (QFN).
Is it compatible with this OpenSource firmware?
kt48svprm.jpg

What are the extra 3 transistors doing?
 
I think no one tested this..

Look at how the gates are parallel, I think it's like 2 paralel for high side and single for low side, so 6+3..

Where you bought this? I like that "design"
 
It is the controller which is built in a battery case (https://www.li-force.ru/shop/view/tube-controller-48v-20a) (http://www.szktdz.com/en/news_show.php?article_id=423).

I have rung out transistors 2 (Drain):
 
stancecoke said:
geofft said:
I look forward to using my new gadget for real sometime.. :wink:

you can print out ui16_current_cal_b in column 1 instead of dutycycle for example and compare it with the recent current in column three, to see why the motor pushed at standstill...

regards
stancecoke

I confess I don't completely understand how to set up these output parameters. I'm presuming this is achieved by modifying the printf commands in the diagnostics area of main.c, but I'm not totally sure about this. Maybe some further info on this in your tutorial (when you have time :wink: ) would help me here...
 
I've added some more descriptions in the tutorial, I think the syntax of the printf command should be self explaining with the example.
https://opensourceebikefirmware.bitbucket.io/windows_instructions/index6.html

regards
stancecoke
 
stancecoke said:
I've added some more descriptions in the tutorial, I think the syntax of the printf command should be self explaining with the example.
https://opensourceebikefirmware.bitbucket.io/windows_instructions/index6.html

regards
stancecoke

Thanks for that, I'm ok with this now.

The parameter descriptions are a great help, they're not always obvious from their naming in the code.
 
Back
Top