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

Electric Motors and Controllers
casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 21, 2017 5:44 pm

stancecoke wrote:
Nov 21, 2017 2:45 pm
edit: the controller is OK, it's the J-LCD display, that causes the short circuit :(
Good that we are going to the next level: Regen :-) -- I need to learn it, let's learn toghether!!
Today I gave my BMSBattery Q11 direct drive motor to my mechanic, so he can try to put the spokes. When I have it ready, I will start testing it and the regen.

I hope you can repair the LCD. The board seems much more simple than the motor controller board :-) -- I would say a capacitor or voltage regulator that are in short, due to very high voltage that were generated on regen.

So, I think your LCD did fried with high voltage. The LCD3/LCD5 can handle from 24V up to 48V, maybe J-LCD also handles that.

I would say that your lab power supply didn't absorve any back current and so the voltage raised a lot, and your LCD did fried. What can we do?
1. maybe doing the tests using a battery
2. on the PWM cycle code (this will be the fastest possible) look at battery voltage and quick disable the motor phases if we get on an overvoltage
What do you think?
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 22, 2017 6:32 pm

Today I finished the implementation for the BMSBattery torque sensor and it works very well.
Well, I don't like much one small part of the algorithm that I will change tomorrow, test and close this implementation.

The torque signal is just like throttle signal and works well. The cadence/PAS signal I had to implement as I didn't implemented yet PAS control. In the end, I let it kind of modular to it should now be easy to implement PAS control.
I also put some #defines, I want this to be ready be used on the Java tool done by Stancecoke.

Here is the cadence (purple line) and seems I like to be at about 70 RPM:
Image

And here the code for maps cadence to motor speed and torque signal to motor current and works like to original firmware, at least for the throttle control as I never tested original firmware for the torque sensor:
Image

And a realtime of me pedaling, showing the final values after the mapping and ready to input to the motor current controller and motor speed controller:
Image
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 23, 2017 9:21 am

I am really happy to say that I think the firmware is now at about 70% of completeness.
I am being riding with my EBike, with a Q85 motor 328 RPM, 24V battery, S06S controller, LCD3 and torque sensor. I also tested with other hardware combinations before, like: Q100 motor, 48V battery, S12S controller, LCD5 and throttle.

Some things missing:
- developing and testing for direct drive motor with regen (I will develop and test with the BMSBattery motor Q11 48V 1KW rear drive motor + S12S controller)
- possible improvement on FOC efficiency
- documentation of user cases, like how to connect a hardware pack, configure and install the firmware for: 24V battery pack + Q85 motor + S06S controller + LCD5 + torque sensor
- implementing other minor things like PAS, external speed sensor, etc.

~~~~~~~~~~~~~~~~~~~~~
Today I just finished the torque sensor control and I did a ride and tested with the following hardware combination:
- 24V battery
- Q85 motor 328 RPM
- S06S controller
- LCD3
- torque sensor

The torque sensor controls the motor this way:
1. if LCD P3 = 1, the pedal torque * (assist level / 2) will define the motor current/torque
2. if LCD P3 = 0, the humam power on the crank * (assist level / 2) will define the motor current/torque

In 2., as human power depends on the pedal cadence value and it is zero at startup, there is no motor assistance at startup, unlike on 1. With the time we can change this behavior if we like.

I am trying to make code modular so it will be easy to enable/disable options of the control modes, inside the ebike_app_controller (). This way, will be possible to select which control mode the user wants, the max pedal cadence, etc, using the Java tool.

Here is the ebike_app_controller ();
Image

And will call torque_sensor_control_mode ():
Image

And today I took from my bicycle mechanic, the direct drive BMSBattery Q11 motor on the 26'' wheel. On the picture, the other small motor is a BMSBattery geared motor Q85 that will but placed on that 16'' wheel for the ebike of my son, that has already installed a torque sensor:
Image
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 23, 2017 8:07 pm

Some notes about the S06ST (torque sensor version):
- The S06ST (torque sensor version) seems to be similar to S06S but has a connector specific for the BMSBattery torque sensor.
- This version has no PAS connector but has throttle connector and it works as expected - you can connect a throttle and run your motor only with the throttle if you prefer.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 301
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 24, 2017 3:02 am

casainho wrote:
Nov 23, 2017 8:07 pm
- The S06ST (torque sensor version) seems to be similar to S06S but has a connector specific for the BMSBattery torque sensor.
Have you buyed a S06ST? Almost 3 years ago, I took a picture where the torquesensor specific wires are contacted to the circuit board:

Image
casainho wrote:
Nov 23, 2017 9:21 am
I am really happy to say that I think the firmware is now at about 70% of completeness.
Great to see this progress! So I hope that I can close my fork soon! :-)

My USB/UART converter died with the J-LCD.
I had a short look at the circuit board of the display, I had to break the housing, as it is welded or bonded and can't be disassembled in a non-destructive way :-(
Perhaps it's only a burned diode that causes the short circuit, I have not tried to repair it yet.

Regards
stancecoke

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 6:07 am

stancecoke wrote:
Nov 24, 2017 3:02 am
Have you buyed a S06ST? Almost 3 years ago, I took a picture where the torquesensor specific wires are contacted to the circuit board:
Yes, and I ma trying to maintain with the original firmware. As soon I need to open and flash the firmware on it, I will look at this specifics and try to document.

Do you know if there are any specifics commands on the LCD for the torque sensor?
Do you remember how the original firmware did behave? Does it start the motor without cadence/pedaling?
stancecoke wrote:
Nov 24, 2017 3:02 am
My USB/UART converter died with the J-LCD.
Perhaps it's only a burned diode that causes the short circuit, I have not tried to repair it yet.
Found some good information about regen but I was expecting to found even better on web, anyway, I think we need to learn and document.
Regeneration - Using a Power Supply

In some stationary application a power supply may be used instead of a battery; in this case regenerative braking may become dangerous.

A battery is a four-quadrant device, capable of issuing (discharge) or receiving (recharge) current maintaining its voltage costant.

A power supply in general is designed as a one-quadrant generator, designed for issuing current at constant voltage, but not for receiving it.

If a power supply has to be used, then the best choice is a conventional power supply with large filtering output electrolytic capacitors; a regenerating motor will charge the capacitors and as long as the voltage does not exceed their maximum rating, the power supply will operate in two quadrants. A switching power supply in general is not suitable. Consult the Roboteq literature on this subject.
https://www.roboteq.com/index.php/appli ... generation
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 6:29 am

Hmmm, I was trying to see if S06ST could regen/brake my Q11 motor and seems S06S don't support regen. On BMSBattery site, I only found one S12S listed as having regen/brake "EABS"........
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 6:37 am

casainho wrote:
Nov 24, 2017 6:29 am
Hmmm, I was trying to see if S06ST could regen/brake my Q11 motor and seems S06S don't support regen. On BMSBattery site, I only found one S12S listed as having regen/brake "EABS"........
Regen does work on S06S!!! -- I had to enable with C13 parameter on LCD. With C13 = 0 (regen disabled), when I brake, my lab power supply voltage keeps equal but after I tested with C13 = 3, motor at low speed, lab power supply at 24V and I did hit the breaks -- my lab power supply went to 50V when braking/regen!!

Now I will need to connect my battery and test the regen/brake, I never used this before...
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 301
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 24, 2017 6:51 am

casainho wrote:
Nov 24, 2017 6:07 am
Do you know if there are any specifics commands on the LCD for the torque sensor?
No, there are no specific parameters. And I found, the regen is not working with the S06ST over the brake lever also. But i found, that it does regen, if you reduce throttle/human power slowly (like the "one-pedal-feeling" at my i3 :-)). But with an ebike I didn't like this behavior... If you close the throttle rapidly, no regen happens.
casainho wrote:
Nov 24, 2017 6:07 am
Do you remember how the original firmware did behave? Does it start the motor without cadence/pedaling?
I don't remember that detail, I've not used the setup with the S06ST for a long time, as the decribed regen behavior was not satisfying for me...

regards
stancecoke

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 8:24 am

stancecoke wrote:
Nov 24, 2017 6:51 am
casainho wrote:
Nov 24, 2017 6:07 am
Do you know if there are any specifics commands on the LCD for the torque sensor?
No, there are no specific parameters. And I found, the regen is not working with the S06ST over the brake lever also. But i found, that it does regen, if you reduce throttle/human power slowly (like the "one-pedal-feeling" at my i3 :-)). But with an ebike I didn't like this behavior... If you close the throttle rapidly, no regen happens.
Very very strange. I have throttle and torque sensor connect as also usual brakes. I am doing my tests for now with the wheel on the air.
If I run using throttle, breaking will regen.
If I run using torque sensor, breaking will not regen.

C3 = 0:
If I run using torque sensor, the motor will quickly go to the max speed and stay there, even If i stop pedaling. Also if I brake, the motor coast but after releasing the break, will quickly go to the max speed again.
With throttle, works as expected.

C3 = 1:
If I run using torque sensor, nothing happens.
Throttle works as expected.

This BMSBattery S/Kunteng controllers have so many options that we can get lost... and we are not talking yet about options on version with Bluetooth and the mobile app...
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 9:46 am

No happy with my experience with S06ST, running the original firmware, torque sensor and a direct drive motor.

Took me some time to understand that the vibrations I was felling on the EBike were from regen. And I got regen after pedaling a bit to go to max speed and after stop pedaling. I didn't like the vibrations, I wounder if is possible to do regen without that vibrations. Also I didn't feel regen as a smooth down ramp...
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

honya96
10 mW
10 mW
Posts: 33
Joined: Mar 05, 2015 9:38 am

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by honya96 » Nov 24, 2017 5:02 pm

With my 18fet when I go WOT to like 50kph and then release the throttle almost but not completly, it does quite strong sine wave regen down to like 10kph, which it should not do. Strenght also depends on p3 parameter and assist level.

It means that with current based throttle eliminating the braking, then you can wire variable sine regen without vibration. Great for powerfull hub bikes.

With this implemented it will start to be interesting for me.

Can you limit or higher over stock the phase amperage with your software?

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 5:50 pm

I did some quick tests (with a battery connected this time and no lab power supply) to see if regen does work when I release the torque, which should by the way I implemented the motor control - on the geared motor, regen simple don't happen because of the motor clutch.

The regen current is configured at initialization of the firmware with the following code:

Code: Select all

#define ADC_MOTOR_REGEN_CURRENT_MAX 2 	// 1 amp regen current; 1 --> 0.5A

motor_set_regen_current_max (ADC_MOTOR_REGEN_CURRENT_MAX);
Maybe it is not easy to understand on the video, but there is a big difference when I used a regen current of 1 amp or 10 amps. I will put more time to do real time logs, etc.

1 amp regen current:


10 amps regen current (I guess it never achieved 10 amps because the top speed was low the mass of the wheel is low):
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 24, 2017 6:02 pm

honya96 wrote:
Nov 24, 2017 5:02 pm
With my 18fet when I go WOT to like 50kph and then release the throttle almost but not completly, it does quite strong sine wave regen down to like 10kph, which it should not do. Strenght also depends on p3 parameter and assist level.

It means that with current based throttle eliminating the braking, then you can wire variable sine regen without vibration. Great for powerfull hub bikes.

With this implemented it will start to be interesting for me.

Can you limit or higher over stock the phase amperage with your software?
With current firmware, regen seems working but needs more developing and testing -- see my last message.

We have full control of the currents. Right now we control the motor total current and we use the phase current only to implement the "very low resolution FOC".
So yes, we can use less current than original firmware or even higher values and the limit is the hardware :-)

This is the code for C5 Controller Maximum Current Adjustment Mode, and as you can see, we go further than the original firmware by using the values 0, 1 and 2 while on original firmware they are Undefined:

Code: Select all

void set_motor_controller_max_current (uint8_t ui8_controller_max_current)
{
  float f_controller_max_current;

  switch (ui8_controller_max_current)
  {
    case 0:
    f_controller_max_current = 0.1;
    break;

    case 1:
    f_controller_max_current = 0.25;
    break;

    case 2:
    f_controller_max_current = 0.33;
    break;

    case 3:
    f_controller_max_current = 0.5;
    break;

    case 4:
    f_controller_max_current = 0.667;
    break;

    case 5:
    f_controller_max_current = 0.752;
    break;

    case 6:
    f_controller_max_current = 0.8;
    break;

    case 7:
    f_controller_max_current = 0.833;
    break;

    case 8:
    f_controller_max_current = 0.87;
    break;

    case 9:
    f_controller_max_current = 0.91;
    break;

    case 10:
    f_controller_max_current = 1.0;
    break;

    default:
    f_controller_max_current = 1.0;
    break;
  }

  ui16_motor_controller_max_current_10b = (uint16_t) (((float) ADC_MOTOR_CURRENT_MAX_10B) * f_controller_max_current);
}
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 301
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 25, 2017 4:13 am

casainho wrote:
Nov 24, 2017 5:50 pm
I did some quick tests (with a battery connected this time and no lab power supply) to see if regen does work when I release the torque
Very good! But I would prefer to meter the regen by an extra analog voltage on an extra ADC pin. And then mount a linear hall sensor in the brake lever, or use a thumb throttle for braking. Is there a free ADC pin available on the circuit board? Perhaps the solder pad that is used for the torque signal on the S06ST?

I got my BionX running now, I just had to increase the value of PWM_CYCLES_COUNTER_MAX in the code of the torque-simulation fork, as the erps of a direct drive are much lower of course. I was not happy with the code of the recent master branch, as I couldn't get the external interrupts running for PAS and SPEED detection.

The J-LCD is working again, also. It was just one burned diode, it was easy to replace it. :-)
So I can try the idea for regen, that I described above, now,

Regards
stancecoke

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 25, 2017 7:16 am

stancecoke wrote:
Nov 25, 2017 4:13 am
Very good! But I would prefer to meter the regen by an extra analog voltage on an extra ADC pin. And then mount a linear hall sensor in the brake lever, or use a thumb throttle for braking. Is there a free ADC pin available on the circuit board? Perhaps the solder pad that is used for the torque signal on the S06ST?
I understand. Maybe we should adapt S06ST connections, because it has analog inputs for throttle, and torque sensor + digital inputs for PAS of torque sensor + digital brakes. But we are not talking yet of bluetooth version... would be great if we could adapt one version to have it all :-)
stancecoke wrote:
Nov 25, 2017 4:13 am
I got my BionX running now, I just had to increase the value of PWM_CYCLES_COUNTER_MAX in the code of the torque-simulation fork, as the erps of a direct drive are much lower of course. I was not happy with the code of the recent master branch, as I couldn't get the external interrupts running for PAS and SPEED detection.
External wheel speed sensor is not implemented yet, it is on the issue list for TODO. I have some BMSBattery external speed sensors with me but that had not being a priority for me. Also if using direct drive motor, external speed sensor is useless.

For PAS, it is also not implemented but it is implemented the version for the torque sensor. Are you using PAS? Because I am not and I don't plan to use PAS so we could skip that until someone really need PAS (which I think no one will but they would prefer to go instead with more advanced technology like torque sensor and regen braking).

How I did implement the torque sensor PAS?

I tried to use a timer to count the ticks of timing between pulses. Then I found that I had to use more resources to detect and limit when user stops pedaling, I would need to use the PWM cycle. So I decide to instead implement all the logic on the PWM cycle, were we now have some good free time and I tink we are near to finish the firmware and will not need to increase the usage of the PWM cycle code -- maybe just a few more calcs for regen.
I did the code to best way to always give results between safe limit values, other way having a wrong cadence value at some time could be dangerous like starting the motor without user knowledge.

Here the implementation:
Image
stancecoke wrote:
Nov 25, 2017 4:13 am
The J-LCD is working again, also. It was just one burned diode, it was easy to replace it. :-)
So I can try the idea for regen, that I described above, now,
Good that you are back :-)
For regen, please be really careful. Seems that regen controlling current is working, please select a value that is safe for your battery pack.
ALSO, I didn't implement yet that vbat readings. You should check battery voltage every PWM cycle and disable the PWM signal (coasting motor) if the vbat is higher than you max battery pack voltage. <---- this should had protect you before!!
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 25, 2017 7:26 am

I did some regen logs on that situations I recorded before with that 2 videos:

With

Code: Select all

#define ADC_MOTOR_REGEN_CURRENT_MAX 2 	// 1 amp regen current; 1 --> 0.5A
and considering that at 0 amps the ADC value = 79, the negative valleys are the regen current, and this one went from the 79 down to 77, so the 2 ADC units = 1 amp of regen current:
Image

With

Code: Select all

#define ADC_MOTOR_REGEN_CURRENT_MAX 20 	// 10 amps regen current; 1 --> 0.5A
and considering that at 0 amps the ADC value = 79, the negative valleys are the regen current, and this one went from the 79 down to 73, so the 6 ADC units = 3 amps of regen current (here it never achieved 10 amps because the top speed was low as also the mass of the wheel is low):
Image

So we can see that on first situation, the negative valley is flat and so the regen current controller did his work, keeping limiting to the 1 amp regen current.

On the second situation, the negative valley is a peak and with max value under the 10 amps the regen current controller were configured to limit, so there was no limitation from the regen current controller and what we see is the natural decay of the regen current.

casainho wrote:
Nov 24, 2017 5:50 pm
I did some quick tests (with a battery connected this time and no lab power supply) to see if regen does work when I release the torque, which should by the way I implemented the motor control - on the geared motor, regen simple don't happen because of the motor clutch.

The regen current is configured at initialization of the firmware with the following code:

Code: Select all

#define ADC_MOTOR_REGEN_CURRENT_MAX 2 	// 1 amp regen current; 1 --> 0.5A

motor_set_regen_current_max (ADC_MOTOR_REGEN_CURRENT_MAX);
Maybe it is not easy to understand on the video, but there is a big difference when I used a regen current of 1 amp or 10 amps. I will put more time to do real time logs, etc.

1 amp regen current:


10 amps regen current (I guess it never achieved 10 amps because the top speed was low the mass of the wheel is low):
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 301
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 25, 2017 8:05 am

casainho wrote:
Nov 25, 2017 7:16 am
Because I am not and I don't plan to use PAS so we could skip that until someone really need PAS
I think 99% of "Pedelecs" in Germany use PAS, as the law says, you have to turn the cranks to have motor assistance. So this is of very high importance!
In my eyes it is much smarter to do the PAS and SPEED detection with an interrupt, instead of looking at the state of the I/O pin every fast loop run. But that is a matter of taste. :wink:

The green wire from the torque-signal goes to the pad that's marked with "X4" on the circuit board (board revision KTE-6S3-B). The pad is connected via a RC-filter to pin 15, AIN7.

Torque Wire X4.JPG
Torque Wire X4.JPG (87.5 KiB) Viewed 164 times
regards
stancecoke

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 25, 2017 9:45 am

Since PAS is so important, I will implement it and try to see if there is a free timer to be used for PAS, as PAS is more complex to detect the direction of pedal rotation, compared to the PAS of torque sensor.

About braking, that is great you did found that information.
Do you advice a brake linear ebrake? BMSBattey don't sell such thing.

With the torque sensor, since it works just like throttle, I can right now test the ebrake... when I reduce the torque on the pedal it will brake, with the current/torque I do define as regen current value.
I need to think more on what feals natural when pedaling... but the thing this is not natural as bicycles don't work this way, the only thing near are fixed gear bicycles or the ones with coast brakes.
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
stancecoke
1 kW
1 kW
Posts: 301
Joined: Aug 02, 2017 2:56 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by stancecoke » Nov 25, 2017 11:38 am

casainho wrote:
Nov 25, 2017 9:45 am
Do you advice a brake linear ebrake? BMSBattey don't sell such thing.
We had a longer discussion about that. The "phaserunner" supports this kind of regen obviously.
There are several suggestion for tinkering...

Image

One information I took from this forum ;-)

Image

regards
stancecoke

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 25, 2017 5:02 pm

stancecoke wrote:
Nov 25, 2017 11:38 am
We had a longer discussion about that.
Thanks.
I can't remove from my head the fixed gear experience, were I can decelerate with pedals, just like I accelerate -- seems very natural to me. I wish I could find a way to have a near experience with ebike since it breaks. I think I will try the same algorithm as original firmware of S06ST but I hope the regen on our firmware don't make all that vibrations... I wounder why regen may imply such vibrations...
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
Alan B
100 GW
100 GW
Posts: 7025
Joined: Sep 11, 2010 7:43 am
Location: San Francisco Bay Area, USA
Contact:

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by Alan B » Nov 25, 2017 5:49 pm

There are different ways to do regen.

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 25, 2017 7:07 pm

Alan B wrote:
Nov 25, 2017 5:49 pm
There are different ways to do regen.
Thanks. Can you point some links with information??

We are using a different PWM scheme/technique than the original firmware. The one we use is the same used on electric unicycles and they brake very well and smooth - I hope we can get the same brake "quality".
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

User avatar
Alan B
100 GW
100 GW
Posts: 7025
Joined: Sep 11, 2010 7:43 am
Location: San Francisco Bay Area, USA
Contact:

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by Alan B » Nov 25, 2017 7:14 pm

I haven't found any good articles on regen details.

One technique is to pulse all three lower (or upper) FETs with in phase PWM, shorting the motor to build current, then opening to allow flyback to charge battery. This is the simplest technique. The rate of switching will determine how smooth it is.

Another is to drive the PWM'd switch's other half with inverse PWM. This way the throttle generates acceleration when above the back EMF and deceleration when you throttle back and drop below back EMF voltage out of the controller.

casainho
10 kW
10 kW
Posts: 954
Joined: Feb 14, 2011 2:43 pm

Re: OpenSource firmware BMSBattery S/Kunteng KT controllers STM8

Post by casainho » Nov 25, 2017 7:26 pm

Ok, I think the algorithm to brake using the pedals must work the same way coast brakes work: rider can stop pedaling to rest and only when he rotates backwards the pedals, regen brake will happen.
With a 12 magnet PAS, as soon we detect no torque signal = 0 and 1 magnet rotating backwards, we could activate regen brake level 1, if 2 magnets backwards, regen brake level 2 and so on. When rider do torque or rotates forward, we can stop regen.

But the BMSBattery torque sensor can't tell us when we rotate backwards :-(
Stancecoke, as you probably saw, there is a 4 pin header on the board, probably to program that microcontroller. Were you able to see which microcontroller is?

For prototyping, I think I can put inside an PAS sensor inside the torque sensor, and I hope it can detect the originals 12 magnets. Maybe using some glue and open an hole to pass to outside the PAS cable:

Image
Developer of OpenSource firmware for EBike BMSBattery S/Kunteng KT motor controllers: https://opensourceebikefirmware.bitbucket.io/

Post Reply