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

Electric Motors and Controllers
User avatar
stancecoke   10 kW

10 kW
Posts: 896
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Feb 25 2018 7:14am

honya96 wrote:
Feb 25 2018 6:21am
but you tested it right?
only on the workbench yet. We have -10°C here in Munich at the moment, brrrr. Far to cold to do a test ride :-)
Burning mosfets may happen with a blocked wheel, :| as there is no active limitation of the phase current in my branch!

regards
stancecoke

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 25 2018 10:42am

stancecoke wrote:
Feb 25 2018 7:14am
honya96 wrote:
Feb 25 2018 6:21am
but you tested it right?
only on the workbench yet. We have -10°C here in Munich at the moment, brrrr. Far to cold to do a test ride :-)
Burning mosfets may happen with a blocked wheel, :| as there is no active limitation of the phase current in my branch!

regards
stancecoke
Same temps here..

In my case its caused by too big/fast motor for 6fet,
60v mosfets, and happend at standstill everytime so I hope that current limiting will prevent that and enable us to use "any" motor. :) I upgraded one 6fet to stp80nf70 (stock) and one to csd19536kcs (for 72v at 3kw+!) mosfets so that should not be a problem anymore. :D

Gaston   1 µW

1 µW
Posts: 4
Joined: Feb 26 2018 7:59am
Location: POLAND

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

Post by Gaston » Feb 26 2018 8:32am

I just joined endless-sphere for this interesting project.
I'm building my first ebike and would use your firmware, I indeed love the idea of Regen commanded like roller brake (pedalling backward), it's such a great feature ! My bike will have FWD Mxus 500W motor & 48V (12S) battery.

BMSbattery do not sale de S06 in this voltage and the S12 is just horribly too big IMO.
What you think of pswpower.com? They have a compact 10A/20A.max controller "P-KT36/48SVPRD-20A", just 96x61x35mm.

If you confirm it might work, I will be happy to join you testing this promising project !

geofft   1 kW

1 kW
Posts: 318
Joined: Nov 09 2012 9:41am
Location: Berkshire UK

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

Post by geofft » Feb 26 2018 9:13am

BMSbattery do not sale de S06 in this voltage and the S12 is just horribly too big IMO.
What you think of pswpower.com? They have a compact 10A/20A.max controller "P-KT36/48SVPRD-20A", just 96x61x35mm.

If you confirm it might work, I will be happy to join you testing this promising project !
I'm using the PSWpower controllers you mention and can confirm they work just fine with this firmware project. The pcb layout is slightly different from the BMS S06S versions but the connection points for the STlink are fairly obvious when you look at the pcb.

The only issue I had with these was the LM317 voltage regs running very hot when operated at 12s. I fit them with heatsinks which helps, may also try a slightly higher resistance series resistor sometime to drop the input voltage (to the LM317) a little more.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR 20amp, LCD3, 48v 12s lipo.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 9:21am

Gaston wrote:
Feb 26 2018 8:32am
BMSbattery do not sale de S06 in this voltage and the S12 is just horribly too big IMO.
What you think of pswpower.com? They have a compact 10A/20A.max controller "P-KT36/48SVPRD-20A", just 96x61x35mm.
48v controller is best for this battery voltage. That 6fet from pswpower works for me. Maybe they sell it cheaper on Aliexpress if only one unit order and you have more protection if it comes faulty.

http://s.aliexpress.com/3EZjIFrU?fromSns=Copy

I Confirm Geofft's recomendation of higher resisitance, if you will use 24/36v version. 48v version is running ok for me even at 14s battery (its hot, but works)

Gaston   1 µW

1 µW
Posts: 4
Joined: Feb 26 2018 7:59am
Location: POLAND

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

Post by Gaston » Feb 26 2018 12:29pm

Great, count me on board !
I just ordered the other parts, so I unfortunately don't expect to have a running bike before April :(

The thing is on Ali are just available the 350W Controller (17A), but on their website are both the 350W P-KT36/48SVPRD-17A and the 500W P-KT36/48SVPRD-20A.
Not sure it's a big difference, but as the motor is 500W, will order the 20A one (in fact at same price, who would by 17A one??).
Or if you believe safe to have a spare one I should order 2?

I understood also need this ST-LINK/V2.

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2018 12:41pm

Gaston wrote:
Feb 26 2018 12:29pm
Or if you believe safe to have a spare one I should order 2?

I understood also need this ST-LINK/V2.
Yes, order spare controllers and parts.
Follow the instructions here and see the material you need: https://opensourceebikefirmware.bitbuck ... MWARE.html
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2018 12:44pm

Gaston wrote:
Feb 26 2018 8:32am
I just joined endless-sphere for this interesting project.
I'm building my first ebike and would use your firmware, I indeed love the idea of Regen commanded like roller brake (pedalling backward), it's such a great feature ! My bike will have FWD Mxus 500W motor & 48V (12S) battery.
Thanks for the feedback!!

I think I am the only one planning to use regen when pedalling backwards. I am not using currently my direct drive motor ebike but I plan to do it soon and I will update the code for that feature and testing better :-)
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2018 1:01pm

I increased max battery current and went to ride and discharge the battery, to see if the reducing duty_cycle for such that battery voltage never gets lower than ADC_BATTERY_VOLTAGE_MIN -- implemented by the following piece of firmware code:

Code: Select all

  if (UI8_ADC_BATTERY_VOLTAGE < ((uint8_t) ADC_BATTERY_VOLTAGE_MIN)) // battery voltage under min voltage, reduce duty_cycle
  {
    if (ui8_duty_cycle > 0)
    {
      ui8_duty_cycle--;
    }
  }
And works very well!!!!!!! And it is a great sensation to feel the motor support reducing when the battery gets near the ADC_BATTERY_VOLTAGE_MIN. The motor support reduces gradually, as I expected.

And I also found I bug, I think. My battery pack has 7 cells and I did configure ADC_BATTERY_VOLTAGE_MIN to be: 7 * 3.10 volts = 21.7 volts. But the LCD always did show to me as min voltage 21.0 volts..... here is the piece of firmware that defines that values:

Code: Select all

#define BATTERY_LI_ION_CELLS_NUMBER 7
#define LI_ION_CELL_VOLTS_MIN 	3.10
#define ADC_BATTERY_VOLTAGE_MIN ((BATTERY_LI_ION_CELLS_NUMBER * LI_ION_CELL_VOLTS_MIN) / ADC_BATTERY_VOLTAGE_PER_ADC_STEP)
So, I guess the firmware is just considering 3 volts per cell and not 3.1 volts: 3 * 7 = 21 VERSUS 3.1 * 7 = 21.7

Me pedalling back to home, motor wasn't helping at that time :-)

Image
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 1:12pm

@Casainho - Great that it works and you like it!! :) have you tested the phase current limiting? I mean how different setting affects power at low to high speed..

Please take a look at the piece of log I sent few posts back. I hope its not my fault and waste of your time.

Btw now since the undervoltage works that well it should be settable in app, everyone will want different value. I'll go to 2.7v per cell

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 1:19pm

Gaston wrote:
Feb 26 2018 12:29pm
Not sure it's a big difference, but as the motor is 500W, will order the 20A one (in fact at same price, who would by 17A one??).
Or if you believe safe to have a spare one I should order 2?

I understood also need this ST-LINK/V2.
You can ask seller on Ali to send you 20A but anyway its better to have more units so you can buy at pswpower. 17A vs 20A probably doesnt matter for us. Only mosfet type matters. I am safely pulling 25A from one stock 15A unit.... and planing to run modded 6fet at 50-60A :twisted:

STlink I bought cheapest on ali and works :wink:

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2018 1:20pm

honya96 wrote:
Feb 26 2018 1:12pm
@Casainho - Great that it works and you like it!! :) have you tested the phase current limiting? I mean how different setting affects power at low to high speed..

Please take a look at the piece of log I sent few posts back. I hope its not my fault and waste of your time.

Btw now since the undervoltage works that well it should be settable in app, everyone will want different value. I'll go to 2.7v per cell
Yes, and did confuse me, as I didn't know the limiting was from motor or battery current. In the end, I put a big value for motor and I feel that is battery current that limits. I am using 12.5 amps of battery current. More than that and is more like a motor cycle (almost no need to make force on the pedals) when LCD assist power level is the max of 5.

Which log? Please post a link.

I have no time for the Java tool, better to go with config.h and main.h up to when I update the Java tool.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 1:24pm

casainho wrote:
Feb 26 2018 1:20pm
Which log? Please post a link.

I have no time for the Java tool, better to go with config.h and main.h up to when I update the Java tool.
>>> Loading file main.ihx in PROGRAM MEMORY image in computer
(API) ERROR : No such file or directory

I havent tried older versions of your fw now but flashing stancecoke's works

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2018 1:27pm

You need to use as reference config-example.h. Forget the java tool for now.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 1:31pm

casainho wrote:
Feb 26 2018 1:27pm
You need to use as reference config-example.h. Forget the java tool for now.
Ok, thanks. Will try. :wink:

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 2:23pm

@Casainho - version from 30.1.2018 works as before (still lots of bugs known) on my table with gearmotor

But after the changes, sometimes no reaction to throtttle, if it starts it starts too fast so it almost falls from stand. Sometimes runs without throttle, sometimes blocks motor so hard so If I move it with my hand it pulls over 3A measured at one phase. It shows 700-950w at standby..... and more and more.

But somehow I still managed to feel it limiting power when low voltage so it looks like that works ok.

I'll wait with more testing until you try with direct motor, but I guess it will be good if someone else test on table too if he gets the same behavior.

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 26 2018 6:04pm

honya96 wrote:
Feb 26 2018 2:23pm
@Casainho - version from 30.1.2018 works as before (still lots of bugs known) on my table with gearmotor

But after the changes, sometimes no reaction to throtttle, if it starts it starts too fast so it almost falls from stand. Sometimes runs without throttle, sometimes blocks motor so hard so If I move it with my hand it pulls over 3A measured at one phase. It shows 700-950w at standby..... and more and more.

But somehow I still managed to feel it limiting power when low voltage so it looks like that works ok.

I'll wait with more testing until you try with direct motor, but I guess it will be good if someone else test on table too if he gets the same behavior.
On 2 Feb I started to add the PI controller.

You can try run without PI controller, just almost plain throttle -- you need to define EBIKE_THROTTLE_TYPE_THROTTLE_PAS_PWM_DUTY_CYCLE for that -- here is the piece of firmware that will apply:

Code: Select all

void ebike_throttle_type_throttle_pas (void)
{
#if defined (EBIKE_THROTTLE_TYPE_THROTTLE_PAS_PWM_DUTY_CYCLE)
  uint8_t ui8_temp;
  float f_temp;

  f_temp = (float) (((float) ui8_throttle_value_filtered) * f_get_assist_level ());
  ui8_temp = (uint8_t) (map ((uint32_t) f_temp,
  			 (uint32_t) 0,
  			 (uint32_t) 255,
  			 (uint32_t) 0,
  			 (uint32_t) 255));
  motor_set_pwm_duty_cycle_target (ui8_temp);
  #endif
If you decided to define EBIKE_THROTTLE_TYPE_THROTTLE_PAS_CURRENT_SPEED, please test with P3 = 1, were PI controller will only control battery current and not wheel speed.

I think the issue of starting to fast, and probably after stop and then start again, is a PI controller oscillation. I did setup my KP and KI for my 24V S06S. The same ADC step for reading battery current, must be higher to your S12S, as it has bigger shunt so will have higher current. Also a step of duty_cycle on your 48V battery, also represent more output than on my 24v battery. So, in resume, please adjust KP and KI for battery current of PI controller.

Forget for now about shown LCD power value.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 26 2018 8:15pm

casainho wrote:
Feb 26 2018 6:04pm
I think the issue of starting to fast, and probably after stop and then start again, is a PI controller oscillation. I did setup my KP and KI for my 24V S06S. The same ADC step for reading battery current, must be higher to your S12S, as it has bigger shunt so will have higher current. Also a step of duty_cycle on your 48V battery, also represent more output than on my 24v battery. So, in resume, please adjust KP and KI for battery current of PI controller.

Forget for now about shown LCD power value.
I am testing on 6fet first. At 36V

So now I was able to make it work kind of well without touching KP KI just by setting PWM rampup to 15, phase current 60 (lower than 20 oscilates)... etc. I dont know for sure what helped the most.

But still sometimes after releasing throttle and getting to low rpm it kind of kicked before stopping completly. No idea why.

Otherwise what still bothers me is the motor trying to pull power after releasing throttle - phases energized , current should be near zero, but when I block the motor fast it pulls 5A+ from battery.

now I understand more that its hard to avoid but I guess you will take a look at that more once you get to the direct drive?

You can think about or try how much slower the reaction will be if energizing the phases only while it gets input from throttle (as stock fw) and apply power then.

If it doesnt affect the reaction time too much it may be better?

I know we need backEMF but we can get it quite fast right?

User avatar
stancecoke   10 kW

10 kW
Posts: 896
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Feb 27 2018 4:05am

honya96 wrote:
Feb 26 2018 8:15pm
Otherwise what still bothers me is the motor trying to pull power after releasing throttle - phases energized , current should be near zero, but when I block the motor fast it pulls 5A+ from battery.
I think we should increase the slow loop frequency to at least 50Hz to improve that behaviour. If you let the phases float, you have to syncronize the PI-Controller to the wheel speed, if you enable the outputs again (when using a direct drive).

regards
stancecoke

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 27 2018 5:38am

stancecoke wrote:
Feb 27 2018 4:05am
If you let the phases float, you have to syncronize the PI-Controller to the wheel speed, if you enable the outputs again (when using a direct drive).
Float you mean energized or not? Can't we just watch the hall sensors output? Or see some feedback from phases even when they are completely off?

I'd prefer feeling completly no drag from motor (as when controller is off)

@Casainho - as I mentioned before, your fw blocks the wheel if you turn off the lcd while wheel rotates, stancecoke's does not. This can be a problem in case of lcd failure

User avatar
stancecoke   10 kW

10 kW
Posts: 896
Joined: Aug 02 2017 2:56pm

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

Post by stancecoke » Feb 27 2018 7:05am

honya96 wrote:
Feb 27 2018 5:38am
Float you mean energized or not?
Floating means, that the mosfets are not conducting, so you have the same behaviour, as the contoller is switched off. (of course the body diodes still rectify the Back EMF phase currents to the battery line)
Perhaps the wording is not exact, as normally you call a terminal floating, if it's not connected to a certain electrical potential.
honya96 wrote:
Feb 27 2018 5:38am
Can't we just watch the hall sensors output?
I'd prefer feeling completly no drag from motor (as when controller is off)
We have to find the right duty cycle to have zero battery/phase current when reactivating the PWM, this will take a certain time where you will feel braking or acceleration. So I think, it's better to have a fast current control (making the current going to zero very fast when releasing the throttle) in this way the PI controller is always up to date.
honya96 wrote:
Feb 27 2018 5:38am
@Casainho - as I mentioned before, your fw blocks the wheel if you turn off the lcd while wheel rotates, stancecoke's does not. This can be a problem in case of lcd failure
That's the only situation, when my code sets the phases floating: Undervoltage detection.

Code: Select all

 else if(ui8_BatteryVoltage<BATTERY_VOLTAGE_MIN_VALUE){

      TIM1_CtrlPWMOutputs(DISABLE);
      uint_PWM_Enable=0; // highest priority: Stop motor for undervoltage protection
      ui32_setpoint=0;
      printf("Low voltage! %d\n",ui8_BatteryVoltage);
    }
regards
stancecoke
Last edited by stancecoke on Feb 27 2018 9:44am, edited 1 time in total.

honya96   1 kW

1 kW
Posts: 328
Joined: Mar 05 2015 9:38am
Location: Czech Republic

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

Post by honya96 » Feb 27 2018 9:14am

Now with 18fet controller - brake icon shows, throttle icon shows at startup, and if I add throttle it shows error message #6 - controller or motor has short circuit abnormality.

Can it be that I have 3 shunts in paralel? I am setting amps ~ 3 times lower than I would normally.

I also replaced original voltage regulator and resistor by dc-dc converter. (Worked with stock fw I think)

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 27 2018 9:28am

honya96 wrote:
Feb 27 2018 9:14am
Now with 18fet controller - brake icon shows, throttle icon shows at startup, and if I add throttle it shows error message #6 - controller or motor has short circuit abnormality.

Can it be that I have 3 shunts in paralel? I am setting amps ~ 3 times lower than I would normally.

I also replaced original voltage regulator and resistor by dc-dc converter. (Worked with stock fw I think)
That error message apears on LCD because you are applying throtttle but wheel is not moving / motor don't start up.

You can try comment the lines of duty_cyle++ and duty_cycle-- on PWM cycle code, that protects for under/over current and use the define option that setups direct throttle value to duty_cycle -- that way it should work or something on the hardware is missing.
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 27 2018 9:18pm

I was testing (for now, only with wheel on the air) the firmware on my Q11 direct drive motor (rear wheel), 48V battery and S12S. I didn't changed anything about the PI controller.

First issue I had was that I exchanged the wires of throttle for PAS and vice-versa.

Then, the issue I found was that once I applied throttle and the motor was near the max duty_cycle, it would never stop. I solved by setup this values for regen current values (value of 0 or 1 would make motor never stop):

Code: Select all

    motor_set_regen_current_max (2);
    ebike_app_battery_set_regen_current_max (2);
But maybe the issue would not happen when riding in real life, I am not sure. Anyway, it now seems to work as I expect.

With the wheel on the air, even if there is no throttle but I push the motor with the pedals, the duty_cyle target is zero (no throttle) but the duty_cycle (real duty_cycle applied to motor) increases in a way for the motor to not offer resistance to the force I apply to push the motor (because regen current is equal to a min value). I am curious to see what happens when I go down hill...

I could pedal up to max motor speed and then duty_cycle hits the max value, I then feel the motor blocking my force on the pedals and I see regen current flowing to battery on that situation, just as expected.

The code is on master branch and I wish I can ride tomorrow for testing....
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

casainho   100 MW

100 MW
Posts: 2662
Joined: Feb 14 2011 2:43pm

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

Post by casainho » Feb 28 2018 12:02am

I did some testing rides with the Q11 direct drive motor (rear wheel), 48V battery, S12S and torque sensor. I like the result!! For now, the only thing I miss from geared motor is the no vibrations -- this direct drive motor vibrates and I fell it, much better if they didn't exist like on geared motor.

I hope to test and ride my ebike more and after, add the code for the feature "Regen ebrake like coast brakes" that is in parallel branch and not on master branch.

Improvements:
- Because there was the issue of float operations on battery voltages, the motor was starting when I powered on the controller :-( -- I implemented the feature: Added protection for battery over voltage when firmware starts, to avoid unexpected motor starting
- Corrected float operations on battery voltage macros
- Found that my S12S has a different battery voltage ADC step: #define ADC_BATTERY_VOLTAGE_PER_ADC_STEP 0.262
S06S that I tested has a step of 0.272
- Improved current sent to LCD, so power seems to be correct (the LCD did show about 600W of motor at startup, with battery voltage of 57V and battery current limited to 12.5A --> 57*12.5 = 585W).
Developer of the Flexible OpenSource firmware for EBike motor controllers (TSDZ2 and KT) and LCDs (KT-LCD3 and Bafang 850C color LCD).

If you like my work, you can consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

Post Reply