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

Ok, for those who want to try it here is the master branch with the porting of all the modifications of the torque x4 (except the operation on x4 which I have eliminated since it does not work on my control unit).
I could not do extensive tests butbut I have seen that the speedometer, the bars, the wattmeter are working.
I simply noticed that on github you can make the comparison between one version and another and then with a little patience and a little logic I ported all the pachs made by Stancecoke into x4 torque (editing with notepad ++ and simply try with Start compile.bat):
Throttle override, bug that causes the engine to shut down, changed to integer arithmetic and shift to the right, Bugfix in the calculation of the current target. I did not touch the walk assist because it seemed to me it was already in the master. I could not try the bike on the road, unfortunately bad luck sees us well, as soon as I got on the bike (mtb) the old rear shock absorber burst and I found myself with the wheel touching the frame :-(
So give it a try, unfortunately I won't be able to do it for the next 3-4 days :-(
But at least on the stand everything works.
If it works maybe someone who knows how to put it on github, don't ask me, I can't do it :-(

View attachment BMSBattery_S_controllers_firmware-Master_all_bug_fix_as_x4troque.zip
 
First, thank you for your efforts! :thumb:

andrea_104kg said:
If it works maybe someone who knows how to put it on github, don't ask me, I can't do it

I've pushed it to a new branch:
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/tree/Andrea

Sadly, your file format uses another LF/CR obviously, so github thinks, every line has changed :-(
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/compare/Master...Andrea?diff=split

To be honest, I don't understand why you ported the changes?! What is the improvement in your branch now?!

regards
stancecoke
 
Simply on my pswpower control unit, the x4 torque version does not work. The master version goes but the engine turns off every 10 minutes or has power drops, lcd03 does not mark neither km nor watt ... in short, very very incomplete ... Maybe it should be tested well, as I said I only tried for a short time .. .
I didn't know about the carriage returns problem :-(
 
Actually, I didn't understand why the master version doesn't show me km and watts etc. I am not a programmer but the differences in the code are not so substantial ... it is practically the same, the fact is that on the master they do not work ...
 
andrea_104kg said:
the fact is that on the master they do not work
Strange, I've never heard any complaints about the Kunteng display not working on the Master Branch (besides a wrong XOR). Only system freezing due to the excessive use of floats, especially with torque sensor, as there is some more math in the algorithm. Maybe no one tried your combination with a Kunteng LCD and a torquesensor yet.

If someone can confirm, that your chages are working properly on the road, I can push the Andrea branch to the master.

regards
stancecoke
 
OutsMarted said:
This would mean you can also restart the controller while you are pedaling at speed without exceeding current limits.

I would still like to know if I can restart the controller safely when not standing still, will this result in a very high regen current on boot?
 
OutsMarted said:
can restart the controller safely when not standing still
this is not recommented. @Xnyle has added the experimental feature "PWM off @coast", but I don't know if it works. You would need the right KV for that feature, I guess Xnyle has hardcoded KV for his own specific motor.

regards
stancecoke
 
stancecoke said:
OutsMarted said:
can restart the controller safely when not standing still
this is not recommented. @Xnyle has added the experimental feature "PWM off @coast", but I don't know if it works. You would need the right KV for that feature, I guess Xnyle has hardcoded KV for his own specific motor.

regards
stancecoke

Yes I will see if I can use that function to make it work. For now I see that the pwm to the mosfets is disabled on startup and is enabled on first call of the aca_setpoint function, if there is enough battery voltage. I would still need to figure out if there is already a value for erps true to reality on first call of the function, so the correct dutycycle is initialised according to the "kv" value.
This value is indeed hardcoded and there is also a connection to the app I see.
I have solved my current sensor problems by the way. And I would also like to ask how can I push something to the github project? In the branch history I see that people have done it and I wonder how, since it fails when I try to push anything? I am using Visual Studio.
I have made a lot of changes to the project for my individual setup, but I could also morph it into an LCD8 branch or put some changes onto the master, since I also solved some issues/made some lighter code applicable to that branch.
 
OutsMarted said:
And I would also like to ask how can I push something to the github project?

Just fork the repo to your own account, then upload your changes to your fork and make a pull request to my repo.

regards
stancecoke
 
stancecoke said:
OutsMarted said:
And I would also like to ask how can I push something to the github project?

Just fork the repo to your own account, then upload your changes to your fork and make a pull request to my repo.

regards
stancecoke

As you probably saw, it worked. I will make another pull request when I tested all my changes for now I have implemented the simple cruise feature for my lcd8 in my fork, which I already tested.
In my personal offline setup I have made more bitshifting changes, but I cannot really implement them to the master here, because then functionality will be lost that I am not using.
Have yet to test my field weakening implementation and walk assist speed limit and then I will try to do the safe restarting of the controller when riding.
 
ok ... test performs, I'm happy as a child with a dream toy [: D]
Even if it is not a bike according to the "American" standards but slightly higher than the modest European standards, (800w peak, less than my brose of my former turbo levo) the result is, at least for me, exciting . Fantastic progression, you don't really notice that you have a hub, exceptional power regulation with the pedals, silent as only a hub can do and as it accelerates you don't feel that lateral "pull" on the chain as in the central. You can start and accelerate with the pedals with any gear, beautiful :)
Everything works for now, no sudden shutdowns or power drops, working speedometer, working battery bars, at least for now no bugs detected ... beautiful!
Thanks to everyone who helped me, I've been on the verge of giving up many times, but it was worth it ... :)
Of course, if problems arise, I'll be here to point them out, but I've built a lot of bikes and now I understand when something goes well after a few km and this is fine :)
It remains with the limits of the hub, it is not suitable for serious off-road vehicles, but for that I have another enduro with tsdz2 ( and modified firmware :) ) but now on normal routes it seems really miserable .... :)
bicitorque.jpg
 
andrea_104kg said:
test performs, I'm happy as a child with a dream toy

Great news!!! So I can push your branch to the master!

Is anyone interested in inheriting this project from me? I haven't had a Kunteng controller for a long time and am not really interested in maintaining this project. I could simply push it back to @casainhos open e-bike organization, but there would be no owner who feels responsible for it...

regards
stancecoke
 
stancecoke said:
andrea_104kg said:
test performs, I'm happy as a child with a dream toy

Great news!!! So I can push your branch to the master!

Is anyone interested in inheriting this project from me? I haven't had a Kunteng controller for a long time and am not really interested in maintaining this project. I could simply push it back to @casainhos open e-bike organization, but there would be no owner who feels responsible for it...

regards
stancecoke

We would miss you and your dedication Stancecoke! Is there no way to keep you interested in the KT controller? Maybe some sponsorship with an 18 fet controller :wink: :wink: ? It may be a simple controller, but it is also very tuneable and nearly indestructable. Currently running my 18 fet 72v controller at 120 battery amps and 200 phase amps (mxus 3k 4T; front wheel lift limits the max useable phase amps...), and still haven't blown any mosfets (some 8500 watts!). In my other bike (noname 50mm 3T) it runs at 250 phase amps without sweat.

The thing I would still very much like to implement btw is speed dependent field weakening. I think this might be something like (line 267 of motor.c):
ui8_assumed_motor_position = ui8_interpolation_start_position + ui8_interpolation_angle + ui8_s_motor_angle + ANGLE CORRECTION;

where the angle correction would be ERPS dependent in an 'if statement'. Still not sure how to exactly do this, maybe Andrea has implemented field weakening already?
 
Iambuilderman said:
The thing I would still very much like to implement btw is speed dependent field weakening.
If you follow the discussion on the last pull request of @OutsMarted you will see, that he has done steps in this direction already :)
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/pull/23

regards
stancecoke
 
Does anyone know if it is possible to dump the stock firmware so that if I do not like the open source one, I can go back to stock?
 
akbarramzan said:
Does anyone know if it is possible to dump the stock firmware so that if I do not like the open source one, I can go back to stock?
I do not think there is an easy way of doing this. I can say that I like the firmware now. But I noticed a few things after upgrading, so here are my findings:
My controller was originally a square wave controller, the top speed was higher, but with field weakening it is the same again.
There is a little bit of a braking effect when no power is wanted, this can be fixed, but in the end I do not really mind it.
Big plusses are that I have a legal 250W 25 kmh mode now, can regen with my throttle when braking. And the assist level are customisable and constant power for me over the whole battery life. Acceleration has also increased for me, because I could set higher amps and the motor is not vibrating my bike anymore. Also the walk assist mode is limited to around 5kmh now and not so powerful that it lurges you forward, not that I use it a lot, but it is nice.
 
I am also trying out to find the correct resistor to solder out. But i don't seem to find it correctly.

my board seems to look like andreas board, but i do not have the 103 resistor there (red circle). instead on the backside of my board there is a resistor soldered on. Would it be enough to just solder that resistor out?

22-01-19 12-18-37 3500.jpg
22-01-19 12-20-05 3502.jpg
 
It looks like mine. I really don't know what the additional resistance is for. After much testing I gave up using the x4 port and brought the bug fixes from x4 to the "Andrea" branch. It works perfectly using the throttle port. If you don't need to use the accelerator and torsometer together, just use that branch.
 
moondash said:
I am also trying out to find the correct resistor to solder out. But i don't seem to find it correctly.

my board seems to look like andreas board, but i do not have the 103 resistor there (red circle). instead on the backside of my board there is a resistor soldered on. Would it be enough to just solder that resistor out?

The pcb's I have use a different layout to yours (and Andrea's) so I can't comment on which resistor to remove. However, tracing out the X4 circuit on my boards it looks like this:-

X4 layout.jpg

This X4 circuit works just fine with the o/s firmware 'Torque from X4' branch. You'll see it has two options for the pullup/down resistor, for our purposes it needs to be connected to the 0v line. It's best not to guess with this, try to trace out the circuit you have and modify it to copy or be similar to that shown in the diagram above.

It would be good to get this properly worked out as it is obviously causing some headaches... :wink:
 
Quick question... :)

I am trying to test the 72v controller (56-90VDC) flashed with the open firmware with a 48v battery, but nothing happens.

Still, in the parameter configurator, I put 0 and 255 for low and high voltage cutoffs, so I should not be bothered by any LVC...

Is there a hard LVC inside the controller that needs to be modified in order to use lower than 56V battery voltage ?

Thanks !!
 
bruc.jpegUnfortunately my experience with a torque meter hub motor ended with the motor burn out. It was to be expected as small hub motors are not suitable for climbs and I am heavy :)
I went back to the original design, a self-built mid motor with a hub converted to a mid motor.
The motor is a q100h modified by me to turn the axis. It works but the torque meter is much nicer with the hub motor. In particular, the q100h suffers from a certain delay in stopping when you stop pedaling. Power gradually decreases, some force remains for about 2 seconds after you stop pushing on the pedals. The strength gradually decreases until it disappears, but 2 seconds is too long and it is annoying. What can it depend on? I tried to lower throttle min a bit, but the problem doesn't go away. Furthermore, keeping the foot still on the pedal and with a modest pressure, the engine tends to start even without the pedal being rotated, only due to the effect of the weight on the pedal. This should not happen, the pas should prevent the start without the rotation of the pedals. Or am I wrong?
I am also thinking of buying a bafang bpm 201 rpm, more suitable for climbs, I much preferred the torsometer on a hub motor. Has anyone tried the firmware on that engine?
 
Pas timeout can be adjusted shorter and try to enable pwm off @ coast. Then the motor stops much faster!

The motor just starting when you put preassure on the pedals is not ideal, but maybe it also helps to lower timeout value. The torque sensor sends many pulses/revolution, which makes it a bit sensitive to small movements.

Consider getting the q128h motor it is really strong and quite light.
 
motmid.jpgI did another short test, unfortunately not in-depth due to lack of time, but there are some problems. I reduced the pas timeout to half and enabled pwm off. There is no longer the problem of the delay but the motor jerks, it starts for a second at 800w (subjecting the gears to a very considerable stress, since I am stationary and the bike jumps forward) after a second the assistance decreases to less than 100w. Uphill it is not possible to accelerate more than 350w, the more you press on the pedals, the more the power decreases. Even when pedaling quietly, the engine power fluctuates, it seems that it cuts the assistance completely and then starts again.
Tomorrow I will try again but I think it is due to the central motor, when the second chain starts to pull obviously the pressure on the pedals decreases and he cuts the assistance.
For the q128h, I already had that engine, great but I managed to burn it in just 3 days :-( and it was also oil cooled but it didn't help :-( (only 800w of power)
I also burned 2 bpm code 13 but it lasted a year :)
The only one I couldn't burn is a cod17 bpm rewound by me.
 
andrea_104kg said:
motmid.jpgI did another short test, unfortunately not in-depth due to lack of time, but there are some problems. I reduced the pas timeout to half and enabled pwm off. There is no longer the problem of the delay but the motor jerks, it starts for a second at 800w (subjecting the gears to a very considerable stress, since I am stationary and the bike jumps forward) after a second the assistance decreases to less than 100w. Uphill it is not possible to accelerate more than 350w, the more you press on the pedals, the more the power decreases. Even when pedaling quietly, the engine power fluctuates, it seems that it cuts the assistance completely and then starts again.
Tomorrow I will try again but I think it is due to the central motor, when the second chain starts to pull obviously the pressure on the pedals decreases and he cuts the assistance.
For the q128h, I already had that engine, great but I managed to burn it in just 3 days :-( and it was also oil cooled but it didn't help :-( (only 800w of power)
I also burned 2 bpm code 13 but it lasted a year :)
The only one I couldn't burn is a cod17 bpm rewound by me.

Then you should try to increase the pas timeout incrementally untill it runs out, I think.
If that doesnt do it then you could also try to lower the P value. It might make it more stable.
 
Back
Top