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

Vbruun said:
The value goes Up to 1024 with 1024 representing 5v (or 3v?, Cant remember) and 0 representing 0v.

Just change min to correspond to slightly above resting voltage and max to 1024. That shoul work.

I'm using values of 310/700, these relate to 1.5v and 3.5v on the tqsr input. Although my tqsr could theoretically go to 4.0v I found in reality I could not achieve above 3.5v.
 
andrea_104kg said:
Vbruun said:
Did you ever repair the trace you cut?
i do not remember what... :(

I thought you had cut a trace. But I misunderstood what you previously wrote. Try to log the x4 value. Imo the easiest way to do it is via the bluOSEC app.
 
I tried, nothing, always starts at the maximum.
I tried to reload the master branch too, nothing works, even if I connect an accelerator or if I connect the white torque wire to the accelerator signal ... I don't know what to try anymore, I declare myself incompetent in making this firmare work .. :( :(
 
Geofft i tried with pulldown resistor, but this down the torque sensor to 0,2v :-(

Ok, looking back on the thread a couple of pages I realise that Stancecoke has already talked about an X4 pulldown resistor.

You mentioned then that when you fitted the pulldown resistor the motor stopped continuously driving under pas - is this actually correct?

If so, and it pulls the tqsr output down to 0.2v as you state, then the pulldown resistor is too low a value as already advised. You need to increase its value so it allows the tqsr output to reach 1.5v at rest, but don't go to any higher resistor value than this. You may find a value around 10k works, but you need to experiment.

Well done for sticking with this by the way, it's a frustrating issue and many people would have given up by now.... :)

EDIT: I've just measured the resistance X4 to ground on an old controller pcb and it's showing 99k. I'm guessing this is looking across the pulldown resistor, so you might need to go quite high with this value.
 
andrea_104kg said:
I declare myself incompetent in making this firmare work ..
If the motor accelerates if the voltage on x4 is definetly zero, there can be the known issue with the current cal b offset, see the FAQs. But the power should be near zero than. The wheel can be stopped very easily by hand then.

If there is significant power on the wheel, there must be something greater 500 on the ADC reading of x4 (uint16_t ui16_X4_min_range = 500;)
At this point it is useful to use the diagnostics mode and look at the values of ui16_sum_torque and uint32_current_target.

They are printed by default in diagnostics mode:
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/blob/a370abc9e0f2c1ab7552eafefeacfe8db04c547d/main.c#L194

regards
stancecoke
 
I tried again to put the pull down resistor, but now it has no effect :-( obviously after removing the pull up resistor on the circuit something has changed ...
But at this point, always thinking according to logic, some of you have the same ECU that has been working for a few years, isn't it that someone has been messing with the code in recent times? Can you have a zip of the x4 branch you use with pswpower's kt36 / 48 svpr so i can test if it works?
 
stancecoke said:
andrea_104kg said:
I declare myself incompetent in making this firmare work ..
If the motor accelerates if the voltage on x4 is definetly zero, there can be the known issue with the current cal b offset, see the FAQs. But the power should be near zero than. The wheel can be stopped very easily by hand then.

If there is significant power on the wheel, there must be something greater 500 on the ADC reading of x4 (uint16_t ui16_X4_min_range = 500;)
At this point it is useful to use the diagnostics mode and look at the values of ui16_sum_torque and uint32_current_target.

They are printed by default in diagnostics mode:
https://github.com/stancecoke/BMSBattery_S_controllers_firmware/blob/a370abc9e0f2c1ab7552eafefeacfe8db04c547d/main.c#L194

regards
stancecoke

i read the faqs but i find nothing about current cal b... :(
 
Can you have a zip of the x4 branch you use with pswpower's kt36 / 48 svpr so i can test if it works?

I've attached a 7zip copy of my current 'Torque from X4' firmware. This works faultlessly with my torquesensor/6fet setup.
I'll be very surprised if it helps with your problem though, but worth a try I guess....
 

Attachments

  • BMSBattery_SC Torque_from_X4.7z
    3.4 MB · Views: 16
Thanks!
I tried immediatly buy nothing... :-( It works with throttle but It start at max with pas :-(
I misured volts betveen -12v on step down out and the KT controller aluminum box and there Is 48V battery voltage ... is it normal?
My step down has the aluminum shell and is resting over the controller
 
andrea_104kg said:
i read the faqs but i find nothing about current cal b...

Ah, you are right. So it's somewhere here in the thread... But if the wheel starts with much power if you are pedaling, it's irrelevant anyway.
So try to log the data in diagnostics mode!

regards
stancecoke
 
I misured volts betveen -12v on step down out and the KT controller aluminium box and there Is 48V battery voltage ... is it normal?

You shouldn't be measuring any voltage on the controller casing. The pcb busbars that run alongside the fet's run very close to the slots in the alu case, make sure they're not touching here. Also check the fet insulators where they're bolted to the case, maybe one of these has failed.

I've got no more ideas regarding your main problem other than something strange is happening to the voltage on X4, or you have a hardware issue. I think best you accept Stancecoke's help and advice about logging values in Diagnostics mode and let him apply his developer knowledge to the problem... :wink:
 
I'll think about it, but I think I have exhausted my skills, I don't have a usb-serial adapter, even if I have old PCs with the real serial ...
tonight I will disassemble the whole control unit in search of any short circuits that bring the mass to the controller box .. but I can not do more. Exceeds my modest abilities, implies a knowledge of the language "c" (I am old and I stopped at the gw basic and the superbasic of the sinclair ql, more than 30 years ago ...)
I will remain curious as to why the engine starts, why it works with the throttle (at least without pedaling), and also why nothing works with the master branch (really strange, if it were a hardware problem it shouldn't work with every version) plus a another dozen doubts, 2 torque sensors perfectly functional, but unusable, a step down, as well as obviously an unusable control unit ... but I'm not complaining I knew it was a difficult thing, even if I thought a little more "user friendly": - ) :)
 
last curiosity, i open the controller and seems ok, but if i put the tester between a negative, es, throttle black wire, and positive on aluminium of the controller i can read over 40v.... but if the back of the mosfet is in short with the aluminum shouldn't the control unit burn? I don't understand where the tension is coming from...
 
andrea_104kg said:
last curiosity, i open the controller and seems ok, but if i put the tester between a negative, es, throttle black wire, and positive on aluminium of the controller i can read over 40v.... but if the back of the mosfet is in short with the aluminum shouldn't the control unit burn? I don't understand where the tension is coming from...

The case of the controller is normally isolated from the internal circuits and is not grounded, so if just one mosfet is touching the case it won't burn because there is no circuit for any current to flow. If two mosfets (or any other track or component) were touching the result would probably not be good, and the magic smoke may be released... :(

It's probably worth tracking this short down - it's difficult to see how this could have any bearing on your main issue but electrons can be unpredictable little buggers at times, you never know.
 
Happy 2022!!! You won't believe it but, before disassembling everything I tried to reload the master branch. As I said, with this branch nothing worked and I wanted to understand why ... even turning the pedals, while with the x4 version started at maximum without control, the master did nothing.... Then I remeasured the voltage at the output of the torque sensor that at no load is 1.5v and I noticed that connected to the throttle, falls to 1.2v (but strangely the voltage is fluctuating a bit). Then I thought to lower the values of throttle min and throttle max.... and magically.... IT WORKS!!!
I've only done 200 meters at night but the torque meter can be clearly felt.... :)
Unfortunately, the master version does not show me the watts on lcd3, in the few meters done the engine seems very underpowered, but one problem at a time.... :)
In addition to the problem of watts, (too bad they were very convenient) I noticed that the engine starts after more than half a pedal stroke, is there any way to adjust?
Of course I only tried it for a few hundred meters, many other problems could come up but for now after days of disappointment I'm really happy! :)
Thanks to everyone who helped me, I hope all my questions can be of help to new users :) (I will not stop asking them.. :) )
 
andrea_104kg said:
Happy 2022!!! You won't believe it but, before disassembling everything I tried to reload the master branch. As I said, with this branch nothing worked and I wanted to understand why ... even turning the pedals, while with the x4 version started at maximum without control, the master did nothing.... Then I remeasured the voltage at the output of the torque sensor that at no load is 1.5v and I noticed that connected to the throttle, falls to 1.2v (but strangely the voltage is fluctuating a bit). Then I thought to lower the values of throttle min and throttle max.... and magically.... IT WORKS!!!
I've only done 200 meters at night but the torque meter can be clearly felt.... :)

Glad to hear you are making some progress.. :D

However, I think you still have some issues with your installation, the controller should not be pulling the torquesensor output voltage down. The fluctuating voltage here is not good also. Some suggestions of mine, maybe others have more..

Do you have a solid ground (-ve) connected between the tqsr output plug and the controller ground? Any problem with this connection will cause you many headaches...

Is the output of your dc-dc tqsr supply solid when connected and operating? It should be holding up at 12v and not fluctuating. What input voltage does your tqsr work with?

If both these things are good it could point to a faulty tqsr, but I think this is less likely.
 
Thank you so much again! I don't know if there will be any problems, today I could only try it for 3km and it goes very well. But I can't give a real comparison with other torsometers because this one is mounted on a hub while the others I tried were on mid motor. The pedaling is very "soft" and very pleasant, but I don't know if it depends on the torque meter or the hub motor.
Unfortunately without a wattmeter I feel "blind", I will have to install a real one.
I don't understand your statement "Do you have a solid ground (-ve) connected between the tqsr output plug and the controller ground? Any problem with this connection will cause you many headaches..."
i send a picture (ugly, i know) of my connections.
The step down is a real rock, it outputs 12,20v very stable :)

IMG_20220101_224300.jpg
I do not know if i need to connect -12v on the step down output and a black cable on pas and throttle connector
 
I do not know if i need to connect -12v on the step down output and a black cable on pas and throttle connector

With your 'Step down' converter, are the -ve of the battery input and the -12v output connected? If they're not your tqsr output signals are not related to the controller ground and will be 'floating'.

I suggest you make the connection you describe to make certain the grounds (-ve's) are all solidly connected. When you have done this recheck the tqsr signal voltage (white wire) at rest and see if you are getting the full 1.5v when connected to the controller.
 
.
.
.
To be completely clear, you need to add these connections to the black connectors of the controller plugs.

Inkedandrea diag_LI.jpg

When you have done this you should see the full 1.5v (pedals at rest) on the torquesensor signal when connected to the controller.

Are you still using the 'Master' branch? If so, you will probably now need to re-adjust the throttle min/max settings, try 80/180 as a start.
 
I have made a couple of test rides with this firmware now. First of all the switch from square to sine wave at low speed is much more silent compared to the stock controller.
I think the square wave controller disabled pwm on braking and maybe on coasting too, because you could feel the power cutting away immediately. I was wondering if this could be implemented here too. This would mean you can also restart the controller while you are pedaling at speed without exceeding current limits.
I think this would be possible by setting the dutycycle to a mapping of erps according to the kv value of the motor. Would this work?
I would also like to share that the current sensor only increases in value for me when drawing above something like 4A, is this normal? I yet have to determine ui16_current_cal_a, but I should calculate this from high power levels then. For now I am running conservative amp limits.
 
jm1090 said:
I don't have throttle lag once I am running. Maybe only a little at startup.. ?

For PAS input to disable cruise, I need to take a look at the code and see if it's easy to do, but I don't have PAS to test it, you would need to be beta tester :D
Sorry for late reply. Yup, I have a couple of 12 magnet setups, where it can be tested. Thanks for the initiative!
The lag can be "fixed" by using higher integral, but I'm not sure at which point it'll start oscillating. So far the only method of detection seems to be through setPoint and Vbat, which doesn't seem super reliable.
The lag is there usually on lower current settings, on 5A max it took solid 1.3 seconds for the throttle to do anything. :?

Also in regards to your earlier question, the CPU overload is detectable when you connect BluOSEC app when the motor is spinning. There is a 2-3 second window, where the user inputs (throttle, brake, PAS) are not responsive. As for other circumstances, I haven't noticed any, but it seems quite possible given what the STM8 already does in real time.
 
Ok, I fixed all the wires a bit, and I managed to do a few km.
The torque sensor is now fixed at 1.5v.
If I put throttle_min at 1,5v I get a "pure torque sensor", it starts only when you press the pedals and even on the flat you have to press otherwise the motor is at zero watts. But it is very tiring for me.
I prefer to leave throttle_min on 1.3v. In this way as soon as I turn the pedals the motor starts with little power, (I think 30-50w maximum, I can estimate it from the battery drop which is only 0.4v) as on a normal pas, but unlike a pas yes you can accelerate by pressing harder on the pedals. It's a combination that I really like. It also avoids the annoying sway typical of torsometers during pedaling, because the motor never goes to zero, it never stops completely. Very beautifull.
Problems and bugs:
- turns off about every 15 minutes. All. Even the display.
The first time it happened I thought I broke everything. Instead, just turn it back on and go for another 15 minutes. Sounds like the sleep timer, possible?
- battery bars sometimes remain empty, a white rectangle. I do not know why. It is a problem that occurs randomly, sometimes it goes, sometimes it doesn't, but even without the battery bars everything works perfectly.
- the external speed sensor does not work. Yet on the bike where I took it off it works ... :-(
Is the automatic shutdown linked to the sensor failure?
- in the lcd3 there is a field that measures the watts of the motor. It doesn't work, it stays blank, but sometimes the number 12 appears and rarely the number 13. What does it mean?
- I don't know how many watts the control unit delivers. They seem few to me. The uphill motor pulls little, the drop of the old battery is only 2v, usually if it reaches about 900w the voltage should drop more.
The problem of switching off is the most serious, for the rest you can live with it peacefully. Is this a known problem?
 
Congratulations with finally making it work! Good job and great persistence!

The problem with switching off is known and fixed in the torque from x4 branch. The food thing is that will likely work now that you have wired things Up correctly, but og course there is No guarantee.

You need to somehow measure the power the controller draws. Remember that you set the current in the firmware, so you need to calibrate it to get good results. My personal experience is that this firmware pulls similar/ a little Harder than stock on the same current settings.
 
Back
Top