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

Something good I achieved: our firmware on LCD3 + our firmware on TSDZ2 motor controller, where we can defined max power on LCD:

casainho said:
Done!! Although there is a bit of oscillation on the wheel and power that I wans't expecting, anyway, very good for the first iteration.

The throttle at my left hand was always at max position. My lab power supply was setup for 45V and it can't give much more than 5 amps, so max power could not be more than 225W, that is why I didn't tested with a higher value.

So, on LCD I was setting the target max power (when we see the value blinking and I increase/decrease in steps of 50) and the throttle was at full/max position, although as we can see, the firmware on the motor controller controls the motor current and hence the motor power in a way the power don't pass (to much) the defined max value:

[youtube]F4RdW0Mr2YA[/youtube]
 
stancecoke said:
Hm, that's not my prefered solution, as you have to stop, swtich off, switch on try to morse, fail, switch off, switch on, try again..... It is quite difficult to find the right rythm
Why not 5 really fast clicks on the lever, even while running, (you cant accidentaly hit the lever 5 times so fast) then when active show 99 and when not show 25 or whats set..

This is much faster way and you will not fail to activate.
 
honya96 said:
Why not 5 really fast clicks on the lever,

Good idea! Very easy to program. But you will loose the possibility to define you own individual morse-code...
Is anyone seriously interested in using it in this way?

regards
stancecoke
 
stancecoke said:
honya96 said:
Why not 5 really fast clicks on the lever,
Good idea! Very easy to program. But you will loose the possibility to define you own individual morse-code...
Is anyone seriously interested in using it in this way?
I also prefer that way, because I think must be something hard to change the state and not happen by mistake.
I also like the idea of showing the 99km/h for some seconds when offroad mode is activated and maybe 25km/h when it is deactivated.

Also, there is a state machine on the firmware to detect when ebike is stopped (wheel is stopped) and I think is a good idea to putor call there this piece, so the offroad state can be changed only with ebike stopped.

Do you want to implement that Stancecoke? If so, please try using the switch case as is better to understand than a big number of ifs.
 
honya96 said:
Why not 5 really fast clicks on the lever, even while running, (you cant accidentaly hit the lever 5 times so fast) then when active show 99 and when not show 25 or whats set..

This is much faster way and you will not fail to activate.

This seems a good method, and at this time will probably be good enough for our purposes.

I think however, when the authorities get serious about checking ebikes they will soon get wise to possible 'cheat' systems. A simple system like this may be a little too easy to uncover, so stancecoke's method of a selectable code may be a better long term solution....?
 
casainho said:
Do you want to implement that Stancecoke? If so, please try using the switch case as is better to understand than a big number of ifs.

In this case, with no individual durations of the morse code, there is no need for a switch case, it's just counting up one variable in one if-structure...
But as geofft wrote: Is that way of activating the offroad-mode too easy?!

regards
stancecoke
 
stancecoke said:
casainho said:
Do you want to implement that Stancecoke? If so, please try using the switch case as is better to understand than a big number of ifs.

In this case, with no individual durations of the morse code, there is no need for a switch case, it's just counting up one variable in one if-structure...
But as geofft wrote: Is that way of activating the offroad-mode too easy?!
I see the implementation as being the same as previous but now with 5 steps and the time between them much more short. And if so, will still be customizeable, so we can get the best of both worlds.
 
Hm, but then we can keep the three steps, that's diffcult enough to hit....
Or we take more steps, but increase the tolerance, it's half a second recently.

regards
stancecoke
 
stancecoke said:
Hm, but then we can keep the three steps, that's diffcult enough to hit....
Or we take more steps, but increase the tolerance, it's half a second recently.
3 steps are few to me, as when I am waiting stopped on a cross section of the road, I always have my hand at brakes and sometimes I hesitate to start so I hit brakes a few time in sequence, but not very fast sequence - I really like the idea of being fast and long sequence.
 
On the street I often hit the brake lever 3 times quickly when I see cars in front stopping hard. That's because I use brake lights and want to signal to cars behind. 5 times is a far better sequence for switching mode.
 
stancecoke said:
So, we can make the duration of 5 steps and the tolerance user-settable.

regards
stancecoke

Seems fine to me, I can comfortably make 5 operations in about 2 seconds, so user selectable 1.5 - 3.0 seconds should do the trick..
 
I've pushed the 5-step-version to a new branch now.
https://github.com/OpenSource-EBike-firmware/BMSBattery_S_controllers_firmware/tree/feature/offroad_mode_5_step

I left the initial values for the step-durations at one second. The tolerance is now settable in the main.h. It is set to 0.8s now.

You can start the code at any time. To make sure, to begin from the start, pull the lever for a few seconds first.

I'll try it in hardware tomorrow.

regards
stancecoke
 
I've tested it on the workbench now. It works :)
I've added print commands to each step temporaribly to show the progress at the screen.
If the speed limit is really disabled on a real ride is not tested yet...

[youtube]Qlsn_ZlR8sk[/youtube]

regards
stancecoke
 
stancecoke said:
I've tested it on the workbench now. It works :)
Good!! And maybe you can try finish the feature, by adding the feedback to user. Maybe showing a specific velocity is hard becaise it depends on wheel size, etc. Much more simple is to use signal using the brake symbol on LCD - an idea is to make it flash, and it wound be to use a counter variable, maybe even expanding the switch structure to add this.
 
stancecoke said:
We should use the value that's defined by the user on the LCD. I think in US the legal limit is 20mph (32km/h).

In California there are 3 classes of electric bicyle plus motorized bicyles and mopeds. The electric bike rules that are interesting are classes 1&2 vs class 3. Classes 1&2 are limited to 20 mph. Class 3 permits assist up to 28mph provided the rider is pedaling and the assist is pedal activated.
 
-dg said:
stancecoke said:
We should use the value that's defined by the user on the LCD. I think in US the legal limit is 20mph (32km/h).

In California there are 3 classes of electric bicyle plus motorized bicyles and mopeds. The electric bike rules that are interesting are classes 1&2 vs class 3. Classes 1&2 are limited to 20 mph. Class 3 permits assist up to 28mph provided the rider is pedaling and the assist is pedal activated.
Well, maybe we are doing a kind of redundancy because user already can define max speed on LCD and is relatively fast for user to do it.

Even the motor power can be changed on LCD.
 
casainho said:
And maybe you can try finish the feature, by adding the feedback to user.

I've added a confirmation signal now. The display shows something about 80 km/h for three seconds, if the morse code was correct. The shown velocity differs due to the chosen wheel circumference, but I think that doesn't matter.

I can't test this in hardware, as I have no LCD3, perhaps someone else can try!
And we have to comment out the print commands :wink:

regards
stancecoke
 
stancecoke said:
casainho said:
And maybe you can try finish the feature, by adding the feedback to user.

I've added a confirmation signal now. The display shows something about 80 km/h for three seconds, if the morse code was correct. The shown velocity differs due to the chosen wheel circumference, but I think that doesn't matter.

I can't test this in hardware, as I have no LCD3, perhaps someone else can try!
And we have to comment out the print commands :wink:

regards
stancecoke

Just tried this in the garage (not on road) but can't get any display indication of offroad mode being triggered.
Sorry to be dumb but I'm not quite sure what I should be inputting via the brake lever to trigger this - could you just clarify the precise sequence needed, 5 quick operations doesn't seem to work for me.... :(
 
You have to "morse" in the same way as in the video, one second for each step. You can change the duration for each step in the main.h
The value is in 0.1s steps, "10" means one second.

Code:
#define OFFROAD_TIME_1 10	//duration of first pull of break lever
#define OFFROAD_TIME_2 10	//duration of first release
#define OFFROAD_TIME_3 10	//duration of second pull
#define OFFROAD_TIME_4 10	//duration of second release
#define OFFROAD_TIME_5 10	//duration of third pull

regards
stancecoke
 
for the improvement of the commutation implementation it is useful to have a look at the code of the VESC perhaps. I had a short look at it, but I think it would take some days to understand the firmware structure.

- Sensored and sensorless FOC wich auto-detection of all motor parameters is implemented since FW 2.3.
- When the current limits are hit, a soft back-off strategy is used while the motor keeps running. If the current becomes way too high, the motor is switched off completely.
- The RPM limit also has a soft back-off strategy.
- Commutation works perfectly even when the speed of the motor changes rapidly. This is due to the fact that the magnetic flux is integrated after the zero crossing instead of adding a delay based on the previous speed.
- When the motor is rotating while the controller is off, the commutations and the direction are tracked. The duty-cycle to get the same speed is also calculated. This is to get a smooth start when the motor is already spinning.

Of course there are some differences in the hardware, especially the phase current sensors, but the "auto-detection of all motor parameters" sounds very interesting...

regards
stancecoke
 
installed the firmware on the new controller. without load - speed 47km/h with a load of 5km/h. the wheel continues to spin after releasing the throttle. Is it possible to adjust the lower value of throttle?
 
I thought the problem with the released throttle was solved?! Please upload your config.h again!

regards
stancecoke
 
stancecoke said:
I thought the problem with the released throttle was solved?! Please upload your config.h again!

regards
stancecoke

Thanks for the help!
Sometimes the wheel starts to rotate itself without pressing the throttle.
what to choose? pwm directly or current / speed?
 

Attachments

  • config.h
    1.4 KB · Views: 106
  • settings.PNG
    settings.PNG
    18.5 KB · Views: 2,283
hey guys wondering if some one can help me out i got a kt 18 fet i got with 4110 fets and 100v caps moded to it also built up the traces does any one know how to make the power on circut support 100v i can replace the voltage reg with a dc to dc converter but is that only thing i need to change thanks
 
Back
Top