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

Electric Motors and Controllers
geofft
100 W
100 W
Posts: 145
Joined: Nov 09, 2012 9:41 am
Location: Berkshire UK

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

Post by geofft » Apr 17, 2018 4:52 am

casainho wrote:
Apr 17, 2018 4:33 am
geofft wrote:
Apr 17, 2018 4:23 am
I'm struggling to make any sense of the .tar.xz files in that SDCC 3.7.0 download link, getting nowhere trying to unpack them with peazip. I think I'll have to wait for a simpler Windows installer version to become available before I can go any further with this.
To extract, use 7Zip for Windows that is OpenSource: https://www.7-zip.org/download.html

After, copy that 3 folders "lib", "local" and "share" to inside C:/SDCC, as per instructions of Stancecoke.
Thanks - no problem extracting them with 7Zip, think I'll throw Peazip away....
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 20amp, LCD3, 48v 12s lipo.

User avatar
stancecoke
10 kW
10 kW
Posts: 553
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 17, 2018 5:37 am

Winrar works for extracting the files from the archive also, as suggested in the instructions. I'll add the links to the tutorial.

regards
stancecoke

geofft
100 W
100 W
Posts: 145
Joined: Nov 09, 2012 9:41 am
Location: Berkshire UK

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

Post by geofft » Apr 17, 2018 10:20 am

stancecoke wrote:
Apr 15, 2018 6:05 am
I've just uploaded a new branch with improved direction detection on PAS and made Regen like coast brakes availabe in normal PAS/Throttle mode.
Finally got this installed and working today, some early observations:-

1) The modified PAS detection works well once PAS ratio is set. On my installation the range over which PAS operated without malfunction was 1.7 - 2.1, so the default of 1.7 was a little low. Set it at the obvious centre point of 1.9, at this figure it works reliably with no false triggering. So, for me, this is an improvement on the previous code and I found achieving the best setting for PAS ratio is not difficult.

2) Was initially confused by the brake indicator showing at times (lcd3) without the brakes being operated. Guessed this was probably to indicate regen/coast brake in operation(?) but it's a little unnecessary and distracting for gear motors, maybe this function can be switched off in config.h. when not required...?

Probably unrelated to the new pas code, it seems the wattmeter holds zero well now but has lost it's previous accuracy and is now indicating around 60% of its 'expected' value.

Didn't notice any occurrences of this problem:-
Just noticed one small 'glitch' though, often when under full power (800w on my setup, usually using throttle but I think has also happened under pas only) the LCD3 wattmeter reading will suddenly decay down to zero, although the motor is still at full drive. If at this point you release throttle/stop pedalling the motor 'hangs in' at full power for a further 2-3 secs before stopping. Not a big deal but just thought I'd mention it, it can catch you out if it happens at a bad moment.
..not sure if the recent changes could have affected this, maybe I need to do a longer test ride to be sure of this.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 20amp, LCD3, 48v 12s lipo.

User avatar
stancecoke
10 kW
10 kW
Posts: 553
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 17, 2018 2:33 pm

@geofft: Thank you for testing and the feedback!
casainho wrote:
Apr 16, 2018 4:11 pm
regen vibrates the motor and I know FOC is not working while regen. All this needs work. I don't have much time... It will take time.
I've logged the phase current while riding and while regeneration with FOC disabled (correction angle always 127). The log shows, that the phase current is 120° late at regen. In my fork I normally read phase current at 180°, now I suggest to do the reading of the phase current at 60° when battery current is negative. I've implemented it in the latest commit, but I have not tried it on the road, as it's already dark outside... :shock:

I think you had a similar idea, as you had the parameter

Code: Select all

#define FOC_READ_ID_CURRENT_ANGLE_ADJUST_INVERT 242
in your code at an earlier commit, but I can't find that in the recent master branch any more?!

regards
stancecoke
phase current riding - regenerating.PNG
phase current riding - regenerating.PNG (12.87 KiB) Viewed 194 times

casainho
100 kW
100 kW
Posts: 1454
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 17, 2018 2:42 pm

I received my TSDZ2 motor today and I also officially started the project: Flexible OpenSource firmware for TongSheng TSDZ2 mid drive motor

Please join the thread here: https://endless-sphere.com/forums/viewt ... 30&t=93818
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1454
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 18, 2018 7:39 am

Ok, TSDZ2 is out off topic but I would like to say that the firmware development started the best way possible!!! :-) and thanks to all the knowledge earned on this project for Kunteng motor controllers.
casainho wrote:
Apr 18, 2018 7:34 am
VICTORY!!

The connection for firmware programming and debug are available on the connector for the speed sensor.

Seems that the original firmware is not read protected. I was able to read the option bytes, firmware and finally connect with OpenOCD for a debug session.

Please read my full notes here: https://opensourceebikefirmware.bitbuck ... enOCD.html
Image

Image
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

geofft
100 W
100 W
Posts: 145
Joined: Nov 09, 2012 9:41 am
Location: Berkshire UK

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

Post by geofft » Apr 18, 2018 8:15 am

casainho wrote:
Apr 18, 2018 7:39 am
Ok, TSDZ2 is out off topic but I would like to say that the firmware development started the best way possible!!! :-) and thanks to all the knowledge earned on this project for Kunteng motor controllers.
casainho wrote:
Apr 18, 2018 7:34 am
VICTORY!!

The connection for firmware programming and debug are available on the connector for the speed sensor.

Seems that the original firmware is not read protected. I was able to read the option bytes, firmware and finally connect with OpenOCD for a debug session.
Well done, that's a great start. I guess people will be much more inclined to try the 'new' firmware if they know they can restore the original fw if required.
Have subscribed to the thread, will be watching progress with interest..
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 20amp, LCD3, 48v 12s lipo.

mjentos
1 µW
1 µW
Posts: 2
Joined: Apr 18, 2018 12:43 pm

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

Post by mjentos » Apr 18, 2018 1:04 pm

Hi,
I got controller 60V KT 18 MOSFETS, and motor Nine Continent RH205 kassette. I can`t to configure it to run motor smoothly, i got effect like on the video https://www.youtube.com/watch?v=exmxFgL ... tu.be&t=13 . Motor has 46 magnets, I set P1 on 46 and still works wrong. Do you think with the new firmware I will be able to make it run well?

User avatar
stancecoke
10 kW
10 kW
Posts: 553
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 18, 2018 1:11 pm

stancecoke wrote:
Apr 17, 2018 2:33 pm
I've implemented it in the latest commit, but I have not tried it on the road,
I've tested it on the road now, but I was not successful. It seems, that the zero crossing of the phase current is not influenced by the correction angle at all... :(

regards
stancecoke

casainho
100 kW
100 kW
Posts: 1454
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 18, 2018 2:05 pm

stancecoke wrote:
Apr 18, 2018 1:11 pm
stancecoke wrote:
Apr 17, 2018 2:33 pm
I've implemented it in the latest commit, but I have not tried it on the road,
I've tested it on the road now, but I was not successful. It seems, that the zero crossing of the phase current is not influenced by the correction angle at all... :(
Thanks for logging and testing. Really nice to see that is really different on both situations.
Also see that 2 lines may not be comparable since the current phase displacemente depends on motor speed and current, and I think you can't assure they were registered on that same conditions.

One thing: I remember to play with magnets and if we think we have 2 magnets, were 1 we control his position (by controlling the pahse current), we need to put at a specific distance to have max attraction force (90 degrees per FOC).
At motoring mode, we want let's say to put current at 90 degres. At regen mode, we want to push to the other side, so, at -90 degrees. Maybe at regen mode we need to put current at -90 degrees, or the same as 270 degrees.
And also, since the current is flowing to battery, on the inverse direction, shouldn't the phase current be inverted 180 degrees also??
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

honya96
100 W
100 W
Posts: 255
Joined: Mar 05, 2015 9:38 am
Location: Czech Republic

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

Post by honya96 » Apr 18, 2018 2:35 pm

mjentos wrote:
Apr 18, 2018 1:04 pm
Hi,
I got controller 60V KT 18 MOSFETS, and motor Nine Continent RH205 kassette. I can`t to configure it to run motor smoothly, i got effect like on the video https://www.youtube.com/watch?v=exmxFgL ... tu.be&t=13 . Motor has 46 magnets, I set P1 on 46 and still works wrong. Do you think with the new firmware I will be able to make it run well?
Try changing C2 and reset display everytime.

User avatar
stancecoke
10 kW
10 kW
Posts: 553
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 18, 2018 2:41 pm

After thinking a little: The current controller pulls the dutycycle to zero, if high regen current is wanted. In this case the correction angle can't have any effect, as the PWM puts no sinewave to phase lines.
Can we achieve higher regen current, if we set a higher dutycyle and a "misstuned" correction angle?!
With dutycycle = 0 I get about 1.5A regen current at about 20km/h with my BionX...

regards
stancecoke

honya96
100 W
100 W
Posts: 255
Joined: Mar 05, 2015 9:38 am
Location: Czech Republic

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

Post by honya96 » Apr 18, 2018 2:43 pm

stancecoke wrote:
Apr 18, 2018 1:11 pm
...but I was not successful.
Interesting is that with stock fw you can regen by decreasing throttle possition and the transition between braking and accelerating is not noticeable at all.

mjentos
1 µW
1 µW
Posts: 2
Joined: Apr 18, 2018 12:43 pm

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

Post by mjentos » Apr 18, 2018 3:22 pm

honya96 wrote:
Apr 18, 2018 2:35 pm
mjentos wrote:
Apr 18, 2018 1:04 pm
Hi,
I got controller 60V KT 18 MOSFETS, and motor Nine Continent RH205 kassette. I can`t to configure it to run motor smoothly, i got effect like on the video https://www.youtube.com/watch?v=exmxFgL ... tu.be&t=13 . Motor has 46 magnets, I set P1 on 46 and still works wrong. Do you think with the new firmware I will be able to make it run well?
Try changing C2 and reset display everytime.
I tried 0-7, no improvement

casainho
100 kW
100 kW
Posts: 1454
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 18, 2018 10:18 pm

stancecoke wrote:
Apr 18, 2018 2:41 pm
After thinking a little: The current controller pulls the dutycycle to zero, if high regen current is wanted. In this case the correction angle can't have any effect, as the PWM puts no sinewave to phase lines.
Can we achieve higher regen current, if we set a higher dutycyle and a "misstuned" correction angle?!
With dutycycle = 0 I get about 1.5A regen current at about 20km/h with my BionX...
No, the current controller tries to decrease the duty_cycle. Let's say motor is rotating at 100 erps and that gives a 12v BEMF. If duty-cycle value equals to a 12v from battery, no current flows. If you decrease duty-cycle a bit, now the voltage from battery will be lower than the BEMF voltage from motor and current will start to be regen.

So, on motor regen duty-cycle is not always zero but will be a value in a way that regen current is not more the value we define/control, so, there will be sinewave phase voltages while regen. Maybe the current phase will simple invert in direction and so shoild have 180 degrees...
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

casainho
100 kW
100 kW
Posts: 1454
Joined: Feb 14, 2011 2:43 pm

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

Post by casainho » Apr 19, 2018 2:38 am

stancecoke wrote:
Apr 18, 2018 2:41 pm
Can we achieve higher regen current, if we set a higher dutycyle and a "misstuned" correction angle?!
You mean changing the angle to get regen?? Idon't think so. On FOC, for regen and invert rotation, we change Iq current from positive to negative. Let's say motor is running with a reference Iq = 10A, to start regen we should put Iq ref = -10A.

If we imagine 2 parallel rails, with 2 magnets on each rail at a very low distance each one, one north pole and other south, they will attract them selfs and stay inline (0 degrees). Now if we move one, the other will follow and if the other has some contrary force to movement direction, like a pull finger, the max torque will be at 90 degrees an not inline 0 degrees. If we push the first magnet to right to move the second one, max torque will be at 90 degrees and after being moving, to brake, max torque will be at -90 degrees (now on the left side).
Developer of the Flexible OpenSource firmware for EBike motor controllers:
- Kunteng/BMSBattery VLR FOC motor controller: https://opensourceebikefirmware.bitbucket.io/
- TongSheng TSDZ2 mid drive motor controller: https://opensourceebikefirmware.bitbuck ... ment_tsdz2

User avatar
stancecoke
10 kW
10 kW
Posts: 553
Joined: Aug 02, 2017 2:56 pm

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

Post by stancecoke » Apr 19, 2018 2:48 am

casainho wrote:
Apr 18, 2018 10:18 pm
So, on motor regen duty-cycle is not always zero but will be a value in a way that regen current is not more the value we define/control,
I don't know if it's a matter of the BionX. As I wrote, the max regen current I get at 20 km/h is about 1.5Amps only. If I ask for e.g. 5A regen current, the current controller drives the duty cycle to zero. If I ask for e.g. 0.5 A, of course the dutycycle will be higher than zero...

regards
stancecoke

honya96
100 W
100 W
Posts: 255
Joined: Mar 05, 2015 9:38 am
Location: Czech Republic

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

Post by honya96 » Apr 19, 2018 3:04 pm

mjentos wrote:
Apr 18, 2018 3:22 pm
I tried 0-7, no improvement
Then leave it at 0 and test all 36 phase-hall combinations (google for it).

Post Reply