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

Electric Motors and Controllers
honya96   1 kW

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

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

Post by honya96 » May 08 2018 10:08am

1N4001 wrote:
May 08 2018 6:17am
Another use case would be for owners of torque-limited systems. Keep the start current/torque the same (which is entirely doable), but "boost" it at high RPM, to raise the top speed. The point is to squeeze more power out of the motor under conditions when there is still untapped potential.
I said allready that youre wrong, maybe someone will come up to teach you how it works but its a waste of time for me.

geofft   1 kW

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

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

Post by geofft » May 09 2018 3:04am

casainho wrote:
May 07 2018 1:29pm
this value of 174 (244 degrees; 170 would be 239 degrees) was found experimentaly
// seems to be about 180 + 60 degrees; were I expected to be 180 degrees
#define MOTOR_ROTOR_ANGLE_FOC (174 + MOTOR_ROTOR_OFFSET_ANGLE)[/code]
Please adjust the "174" value to something between 110 and max of 255 (including the sum of MOTOR_ROTOR_OFFSET_ANGLE).

Note that 20 equals to 30 degrees, 31 to 45 degrees, 42 to 60 degrees. I would say maybe the final value will be some of that round numbers (+ or -): 30, 45, 60 or 90 degrees.
I've been having a play with the FOC angle as you suggested here, used the training stand with a fixed load/speed and measured battery current, also assessed motor running. The user adjustment for this in config.h (MOTOR_ROTOR_OFFSET_ANGLE) was left at '0'.

I have found the '174' setting is, for me , at the extreme upper end of the working range, in fact when set to 180 the motor malfunctions and will not run. For me the 'sweet spot' seems to be around 120-140, at this setting the motor operates really smoothly with good torque. I think 130 actually equates to 180deg, your 'expected' figure?

It seems odd that our two motors (Q85 vs Q128H) have such different requirements for the FOC angle, differences outside the normal range of any manufacturing tolerances you would think. It would be interesting to get some input from other testers, has anybody else experimented with this?

After a 4-5km test ride the motor was virtually cold but I still had a pretty hot controller (around 72C at the mosfets), so it looks like some improvements still need to be made here. I'll fiddle further with the FOC setting during the week but I have a feeling the cause of this excessive (compared with stock) controller temperature won't be found here.

I'm not sure how good my logic is here, but with a good working FOC I'm thinking that the angle that gives best efficiency should be quite clearly defined, but that seems not to be the case. In fact settings for the angular adjustment of 100-160 (140-225deg?) all seemed to give similar results on the test stand. (I have only as yet tried '130' (180deg) on the road). This makes me wonder if the FOC is really operating as you guys intended, maybe we need to do some more tests here. Anyway, I will test more when I can find time during the week, let me know if you want anything else tried.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   10 kW

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

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

Post by stancecoke » May 09 2018 2:20pm

I just modifed a BionX igh3 Motor for use with our firmware (my fork at the moment). I use it in the testbench for regen trials, after I ruined the gearwheels of my Sanyo Dynamotor.
FOC works fine with the Bionx. Even at regen with the algorithm I descibed before.

regards
stancecoke

Image

casainho   100 MW

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

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

Post by casainho » May 09 2018 3:25pm

geofft wrote:
May 09 2018 3:04am
casainho wrote:
May 07 2018 1:29pm
this value of 174 (244 degrees; 170 would be 239 degrees) was found experimentaly
// seems to be about 180 + 60 degrees; were I expected to be 180 degrees
#define MOTOR_ROTOR_ANGLE_FOC (174 + MOTOR_ROTOR_OFFSET_ANGLE)[/code]
Please adjust the "174" value to something between 110 and max of 255 (including the sum of MOTOR_ROTOR_OFFSET_ANGLE).

Note that 20 equals to 30 degrees, 31 to 45 degrees, 42 to 60 degrees. I would say maybe the final value will be some of that round numbers (+ or -): 30, 45, 60 or 90 degrees.
I've been having a play with the FOC angle as you suggested here, used the training stand with a fixed load/speed and measured battery current, also assessed motor running. The user adjustment for this in config.h (MOTOR_ROTOR_OFFSET_ANGLE) was left at '0'.

I have found the '174' setting is, for me , at the extreme upper end of the working range, in fact when set to 180 the motor malfunctions and will not run. For me the 'sweet spot' seems to be around 120-140, at this setting the motor operates really smoothly with good torque. I think 130 actually equates to 180deg, your 'expected' figure?

It seems odd that our two motors (Q85 vs Q128H) have such different requirements for the FOC angle, differences outside the normal range of any manufacturing tolerances you would think. It would be interesting to get some input from other testers, has anybody else experimented with this?

After a 4-5km test ride the motor was virtually cold but I still had a pretty hot controller (around 72C at the mosfets), so it looks like some improvements still need to be made here. I'll fiddle further with the FOC setting during the week but I have a feeling the cause of this excessive (compared with stock) controller temperature won't be found here.

I'm not sure how good my logic is here, but with a good working FOC I'm thinking that the angle that gives best efficiency should be quite clearly defined, but that seems not to be the case. In fact settings for the angular adjustment of 100-160 (140-225deg?) all seemed to give similar results on the test stand. (I have only as yet tried '130' (180deg) on the road). This makes me wonder if the FOC is really operating as you guys intended, maybe we need to do some more tests here. Anyway, I will test more when I can find time during the week, let me know if you want anything else tried.
Again, clear description of your tests and I think we can learn well from them.

1. Good to know that the 180 degrees I expected (130 in 8 bits) is what you think are ok.
"the motor operates really smoothly with good torque" maybe there are 2 different things here: when you mean with good torque is at startup when you block the wheel or when running?? because I think there are 2 different stages: torque at startup (when motor is blocked, like starting to run with a big load/(ebike + rider)). I would like hear your experience/feeling about the torque at startup using that 130 value.
When I get home, I will try that 130 on my Q85. I don't think our motors work differently....

2. About the temperature, nice that you saw your motor col but the controller hot (72ºC at mosfets). I think the controller will get hot due to high current... but if you think that should not be the reason... I see other 2 possibilities:
- 1. PWM scheme:

(1.)PWM scheme of Kunteng original firmware over 1 ERPS: https://opensourceebikefirmware.bitbuck ... eware.html
Image

(2.)PWM scheme of our firmware for Kunteng as also TSDZ2 original firmware over 1 ERPS: https://opensourceebikefirmware.bitbuck ... oller.html
Image

We can see that each phase is about 1/3 of the time disabled, there are no commutations nor current, so it may make a difference.
But I decided to implement the 2nd scheme because I already used that in past. And later I even tried to implement 1first scheme, in 2 different time but the motor did run louder, more louder than original firmware... so I could not make it working as original firmware PWM scheme. But, at least we know that other "good" motor controller use just the same PWM scheme as we do on our firmware.

- 2. Dead time: so, you have a different controller from me, I have S06S from BMSBattery and there may be difference between them. As you can see, I did measured a dead time near1us on my controller and firmware is using 1us. I think that if your controller dead time must be a little more like 1.5us, it should be very hot because it is like a kind of short circuit on mosfets!! See here my measures for dead time: https://opensourceebikefirmware.bitbuck ... gnals.html

This you can test right now, go to PWM.c file and change that 16 value:

Code: Select all

  // break, dead time and lock configuration
  TIM1_BDTRConfig(TIM1_OSSISTATE_ENABLE,
		  TIM1_LOCKLEVEL_OFF,
		  // hardware nees a dead time of 1us
		  16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16
		  TIM1_BREAK_DISABLE,
		  TIM1_BREAKPOLARITY_LOW,
		  TIM1_AUTOMATICOUTPUT_DISABLE);
As a comparison, TSDZ2 dead time I measured is 3.2us which seems to big!! Maybe the developers put that safe big value during development but didn't optimize for the final production firmware version....

TSDZ2 original firmware: Dead time of 3.2us, example of PWM channel 1 and PWM inverted channel 1:
Image

3. FOC: yes, I also think that angle should be very well defined. I just don't know if the motors wirings are standard - also I saw pictures of some motors that the small PCB with the hall sensors, has a placement adjustment...
FOC should give us the highest torque possible per each Amp. If you try to disable FOC, you should "feel the difference" at least in torque - comment all the following line to disable FOC (motor.c):

Code: Select all

      // minimum speed to do FOC
      if (ui16_motor_speed_erps > MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES)
      {
        // read here the phase B current: FOC Id current
        ui8_adc_id_current = UI8_ADC_MOTOR_PHASE_B_CURRENT;
        if (ui8_adc_id_current > ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MAX) { ui8_angle_correction++; }
        else if (ui8_adc_id_current < ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MIN)
        {
	  // decrease only when not regen!! other way ui8_angle_correction will always decrease... CAN WE IMPROVE THIS??
	  if (UI8_ADC_BATTERY_CURRENT > (ui8_adc_battery_current_offset + 2)) { ui8_angle_correction--; }
        }
      }
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, please 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: 2744
Joined: Feb 14 2011 2:43pm

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

Post by casainho » May 09 2018 3:34pm

Snickers wrote:
May 08 2018 9:58am
Do you make some release in order to identify firmware version afterward?
Do you plan to use the LCD3 as a piloting S06S for the FOC motor parameter in real time?
No, no firmware version management up to now. I think we still don't have a stable version, or I am bad at manage this things :-)

That's a good idea!! When we have our own LCD3 firmware working, we can add that specific commands and yes, adjusting in real time the FOC parameters (angle or such), would be great!!
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, please 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: 2744
Joined: Feb 14 2011 2:43pm

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

Post by casainho » May 09 2018 3:40pm

stancecoke wrote:
May 08 2018 8:56am
Concerning regen:
Here is a good explanation how our PWM is working as step-down converter in motor mode and as step-up converter in regen mode.
Here also is described to use the BEMF that belongs to a certain rpm for controlling the regen, like I proposed some posts before :-)....

https://www.roboteq.com/index.php/appli ... en-braking
I know that page because unfortunately there ins't almost no documentation about regen :-(

I din't understand your idea, I must say. Maybe also my focus is not regen now - but once the FOC recent code works and it is clear the angles, I want to jump to regen, because I think regen may simple have a different FOC angle...

Can you please explain your idea?? So do you do regen or you simple avoid regen??
I am avoiding doing FOC, I mean, decrease the angle when regen as I found I problem... I really want to improve this!!!

Code: Select all

	  // decrease only when not regen!! other way ui8_angle_correction will always decrease... CAN WE IMPROVE THIS??
	  if (UI8_ADC_BATTERY_CURRENT > (ui8_adc_battery_current_offset + 2)) { ui8_angle_correction--; }
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, please 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: 2744
Joined: Feb 14 2011 2:43pm

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

Post by casainho » May 10 2018 3:00am

casainho wrote:
May 09 2018 3:40pm
I din't understand your idea, I must say.
Ok I got your message: viewtopic.php?f=30&t=87870&start=2175#p1375727

I think I want to try and see on oscilloscope regen working, thanks for that information and I hope it will help me to understand. I wish I can find some way for it to work without the need of user tweaking.
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, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

geofft   1 kW

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

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

Post by geofft » May 10 2018 3:24am

casainho wrote:
May 09 2018 3:25pm

This you can test right now, go to PWM.c file and change that 16 value:

Code: Select all

  // break, dead time and lock configuration
  TIM1_BDTRConfig(TIM1_OSSISTATE_ENABLE,
		  TIM1_LOCKLEVEL_OFF,
		  // hardware nees a dead time of 1us
		  16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16
		  TIM1_BREAK_DISABLE,
		  TIM1_BREAKPOLARITY_LOW,
		  TIM1_AUTOMATICOUTPUT_DISABLE);
If you try to disable FOC, you should "feel the difference" at least in torque - comment all the following line to disable FOC (motor.c):

Code: Select all

      // minimum speed to do FOC
      if (ui16_motor_speed_erps > MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES)
      {
        // read here the phase B current: FOC Id current
        ui8_adc_id_current = UI8_ADC_MOTOR_PHASE_B_CURRENT;
        if (ui8_adc_id_current > ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MAX) { ui8_angle_correction++; }
        else if (ui8_adc_id_current < ADC_PHASE_B_CURRENT_ZERO_AMPS_FOC_MIN)
        {
	  // decrease only when not regen!! other way ui8_angle_correction will always decrease... CAN WE IMPROVE THIS??
	  if (UI8_ADC_BATTERY_CURRENT > (ui8_adc_battery_current_offset + 2)) { ui8_angle_correction--; }
        }
      }
Ok, will try these things, but may be the weekend before I can get to do this.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

User avatar
stancecoke   10 kW

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

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

Post by stancecoke » May 10 2018 4:42am

casainho wrote:
May 10 2018 3:00am
I think I want to try and see on oscilloscope regen working, thanks for that information and I hope it will help me to understand. I wish I can find some way for it to work without the need of user tweaking.
I've logged the Phase B current at the PAS events in motor mode and in regen mode. I use the zero crossing at 180° for doing the simplified FOC. I don't know if it's stable at higher amps, I can't test with higher power on the testbench, due to the limited power of my Lab power supply.
We could implement a self learning algorithm to find the correlation between duty cycle and erps at zero battery current. This would avoid the need of a user setting.

regards
stancecoke
Phase Current at Motor and Generator Mode.PNG
Phase Current at Motor and Generator Mode.PNG (12.88 KiB) Viewed 761 times

1N4001   10 W

10 W
Posts: 72
Joined: Nov 28 2017 7:55am

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

Post by 1N4001 » May 10 2018 6:47am

What's the current state of Bluetooth "displays"? I'm finally about to order from BMSBattery and I wonder if I should take the S06S-BL.


And if there are any problems with BT, you can just wire up a normal LCD instead of the BT adapter, right? edit: I just found in the docs that this isn't possible as the wiring is different.

casainho   100 MW

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

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

Post by casainho » May 10 2018 6:50am

1N4001 wrote:
May 10 2018 6:47am
What's the current state of Bluetooth "displays"? I'm finally about to order from BMSBattery and I wonder if I should take the S06S-BL. And if there are any problems with BT, you can just wire up a normal LCD instead of the BT adapter, right?
BT version has LCD connection + Bluetooth module. I am using one S06SBT with our firmware and works ok. Just there Bluetooth don't work.

Until someone want to develop the mobile app, we will not have it.....
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, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

1N4001   10 W

10 W
Posts: 72
Joined: Nov 28 2017 7:55am

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

Post by 1N4001 » May 10 2018 6:58am

casainho wrote:
May 10 2018 6:50am
BT version has LCD connection + Bluetooth module. I am using one S06SBT with our firmware and works ok. Just there Bluetooth don't work.
Interesting, so the S06S-BL can work with an LCD, exactly like the S06S, but has the BT adapter in addition?
Until someone want to develop the mobile app, we will not have it.....
I might know someone who could do it, but no guarantees...

casainho   100 MW

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

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

Post by casainho » May 10 2018 9:32am

1N4001 wrote:
May 10 2018 6:58am
casainho wrote:
May 10 2018 6:50am
BT version has LCD connection + Bluetooth module. I am using one S06SBT with our firmware and works ok. Just there Bluetooth don't work.
Interesting, so the S06S-BL can work with an LCD, exactly like the S06S, but has the BT adapter in addition?
Yes.
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, please 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: 2744
Joined: Feb 14 2011 2:43pm

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

Post by casainho » May 11 2018 4:36pm

geofft wrote:
May 09 2018 3:04am
I have found the '174' setting is, for me , at the extreme upper end of the working range, in fact when set to 180 the motor malfunctions and will not run. For me the 'sweet spot' seems to be around 120-140, at this setting the motor operates really smoothly with good torque. I think 130 actually equates to 180deg, your 'expected' figure?
I did some more tests and had the sameresults as you. Like 175 at upper limit and 115 and down limit, so the amplitude is like 60 which is like ~90 degrees. Also found that at near 127 I got a good result, being 127 the 180 degrees as I expected. So the "FOC angle" is at 127.

Also, I tested with FOC disabled, with motor current of 3.5 A and found almost no difference in the results: almost the same battery current and speed - I guess a difference may be seen at higher currents, maybe I will try again with 10A using my battery instead of the lab power supply.

Anyway, I want next test to see if we have the max torque possible at startup. After that, I think I will close this work on testing FOC.
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, please 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: 2744
Joined: Feb 14 2011 2:43pm

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

Post by casainho » May 11 2018 11:23pm

I had to put TSDZ2 motor working with SVM. I did a copy of our firmware for KT controllers to TSDZ2 and the motor didn't start at first. Then I did the procedure bellow and finally I had to change phase wires to get it running (in fact, I just changed on firmware the phases -- the color wires on the PCB is different: KT is yellow, green, blue and TSDZ2 is yellow, blue, green).

Andby the way, running using SVM and is much more silent than using block commutation/6 steps. See the comparison between the 2 videos showing motor running with block commutation VS SVM.

It is near silent as original firmware and also uses less current when running as seen on the video: 1.02A VS 1.25A. Next step is to try implement "FOC" using only math since we already know the motor R and L.

Block commutation:


SVM:

casainho wrote:
May 05 2018 2:00pm
geofft wrote:
May 04 2018 1:16pm
Just tried this, things don't seem quite right.

Initially had rough startup, changed MOTOR_ROTOR_ERPS_START_INTERPOLATION_DEGREES from 20 to 0. This smoothed out startup but motor would frequently startup in reverse. Set this back to 20.

Changed MOTOR_ROTOR_OFFSET_ANGLE from 0 to 20, this again smoothed out startup and ran smoothly, but was noticeably down on torque compared to previous fw version and controller was very hot after a short test ride.
Please try the following process. I wrote it to install firmware instructions and if they are ok to you, I will put online:

Hall sensor connections

With the motor phase wires disconnected (it is recommended to insulate with tape the phase wires) and the hall sensor wires connected to the motor controller, use a multimeter to measure the voltage of each hall sensor wires.

Rotate the wheel slowly by hand in the backward direction and the motor will rotate (if you are using a geared motor, it is the only direction which the motor will rotate).

For the hall sensors to be correctly connected, you must make sure the voltages sequence is the following (and repeats over and over) - if not, you will need to exchange the wires up to get the right sequence:

Position | Blue wire: hall sensor C | Green wire: hall sensor B | Yellow wire: hall sensor A
2 | 0 volts | 5 volts | 0 volts
6 | 5 volts | 5 volts | 0 volts
4 | 5 volts | 0 volts | 0 volts
5 | 5 volts | 0 volts | 5 volts
1 | 0 volts | 0 volts | 5 volts
3 | 0 volts | 5 volts | 5 volts

Phase wires connections

Yellow wire: motor phase A
Green wire: motor phase B
Blue wire: motor phase C

After having hall sensors with the right sequence and with the motor controller turned off, connect the motor controller green wire phase B (middle wire on controller board, being the yellow and blue on the extreme to run the sides) to the motor green wire. Now connect the other wires with the same colors and finally try to run the motor starting with a low throttle value and with a protected lab power supply or battery pack with a BMS. If the motor don't work, makes noise, ask to much current, etc, exchange the yellow and blue wires between them, keeping the green wire - try again to run the motor.
If the previous ways was not ok for running the motor, you can try other motor phases combinations.
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, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

geofft   1 kW

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

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

Post by geofft » May 12 2018 2:50am

casainho wrote:
May 11 2018 4:36pm
geofft wrote:
May 09 2018 3:04am
I have found the '174' setting is, for me , at the extreme upper end of the working range, in fact when set to 180 the motor malfunctions and will not run. For me the 'sweet spot' seems to be around 120-140, at this setting the motor operates really smoothly with good torque. I think 130 actually equates to 180deg, your 'expected' figure?
I did some more tests and had the sameresults as you. Like 175 at upper limit and 115 and down limit, so the amplitude is like 60 which is like ~90 degrees. Also found that at near 127 I got a good result, being 127 the 180 degrees as I expected. So the "FOC angle" is at 127.
127 will work fine for me. Around this figure I get good torque (with throttle) from both startup and when rolling. Startup is a little rough for me at the default setting for 'MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES' (config.h), reducing this setting to '0' smooths things out very nicely.
Also, I tested with FOC disabled, with motor current of 3.5 A and found almost no difference in the results: almost the same battery current and speed - I guess a difference may be seen at higher currents, maybe I will try again with 10A using my battery instead of the lab power supply.
FOC definitely makes a difference. I found (on training roller, wheel heavily loaded) with FOC disabled full throttle could only achieve 14mph, with FOC re-enabled this rose to 18.5mph with the motor sounding much more lively.

I'm still chasing this extra (over stock) mosfet temperature, it seems it has nothing to do with FOC angle. I hope to experiment with increasing mosfet 'dead time' setting later, will let you know the result. I think I also need to maybe re-check that stock and 'new' fw are pushing a roughly equal amount of max current through the motor so we're getting a fair comparison...
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

casainho   100 MW

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

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

Post by casainho » May 12 2018 3:37am

geofft wrote:
May 12 2018 2:50am
127 will work fine for me. Around this figure I get good torque (with throttle) from both startup and when rolling. Startup is a little rough for me at the default setting for 'MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES' (config.h), reducing this setting to '0' smooths things out very nicely.
So startup is not working as expected. I know that KT original firmware starts with block commutation and after jumps to FOC. I see just the same on TSDZ2. I remember to implement the same on our firmware but for some reason there was an dangerous issue with current controller... maybe I will revisit this think later.

geofft wrote:
May 12 2018 2:50am
Also, I tested with FOC disabled, with motor current of 3.5 A and found almost no difference in the results: almost the same battery current and speed - I guess a difference may be seen at higher currents, maybe I will try again with 10A using my battery instead of the lab power supply.
FOC definitely makes a difference. I found (on training roller, wheel heavily loaded) with FOC disabled full throttle could only achieve 14mph, with FOC re-enabled this rose to 18.5mph with the motor sounding much more lively.
Great that you did test that and this way I will move forward. An increase of 4.5mph/7.2km/h with motor heavily load is a BIG gain!!
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, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

geofft   1 kW

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

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

Post by geofft » May 12 2018 6:49am

Casainho wrote:
- 2. Dead time: so, you have a different controller from me, I have S06S from BMSBattery and there may be difference between them. As you can see, I did measured a dead time near1us on my controller and firmware is using 1us. I think that if your controller dead time must be a little more like 1.5us, it should be very hot because it is like a kind of short circuit on mosfets!! See here my measures for dead time: https://opensourceebikefirmware.bitbuck ... gnals.html

This you can test right now, go to PWM.c file and change that 16 value:
CODE: SELECT ALL

// break, dead time and lock configuration
TIM1_BDTRConfig(TIM1_OSSISTATE_ENABLE,
TIM1_LOCKLEVEL_OFF,
// hardware nees a dead time of 1us
16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16
TIM1_BREAK_DISABLE,
TIM1_BREAKPOLARITY_LOW,
TIM1_AUTOMATICOUTPUT_DISABLE);
As a comparison, TSDZ2 dead time I measured is 3.2us which seems to big!! Maybe the developers put that safe big value during development but didn't optimize for the final production firmware version....

TSDZ2 original firmware: Dead time of 3.2us, example of PWM channel 1 and PWM inverted channel 1:
I read from this that I need to increase the '16' number to increase the 'dead time' period applied by the firmware - I hope that's correct. I tried doubling this to 32 but couldn't detect any real change, a couple of test rides (stock vs 'new') showed that new fw was still running around 15-20C hotter than stock.

Not sure where we can go with this now, I suppose the difference is significant and can't really be ignored as it must be having some effect on efficiency. It's a pity we can't get more tester results on this, I'm always afraid these things could be something to do with my particular setup and I'm giving you guys bad info.

On the plus side everything else works really well now - almost time to fit my torque sensor and begin some fun and games with that... :shock:

Forgot to mention - the github download with the user wattmeter correction you posted a link to recently wouldn't flash for me, do you want a cmd dump for this?
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

lqbweb   100 mW

100 mW
Posts: 48
Joined: Nov 08 2014 10:57pm

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

Post by lqbweb » May 12 2018 7:01am

geofft wrote:
May 12 2018 6:49am
Casainho wrote:
- 2. Dead time: so, you have a different controller from me, I have S06S from BMSBattery and there may be difference between them. As you can see, I did measured a dead time near1us on my controller and firmware is using 1us. I think that if your controller dead time must be a little more like 1.5us, it should be very hot because it is like a kind of short circuit on mosfets!! See here my measures for dead time: https://opensourceebikefirmware.bitbuck ... gnals.html

This you can test right now, go to PWM.c file and change that 16 value:
CODE: SELECT ALL

// break, dead time and lock configuration
TIM1_BDTRConfig(TIM1_OSSISTATE_ENABLE,
TIM1_LOCKLEVEL_OFF,
// hardware nees a dead time of 1us
16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16
TIM1_BREAK_DISABLE,
TIM1_BREAKPOLARITY_LOW,
TIM1_AUTOMATICOUTPUT_DISABLE);
As a comparison, TSDZ2 dead time I measured is 3.2us which seems to big!! Maybe the developers put that safe big value during development but didn't optimize for the final production firmware version....

TSDZ2 original firmware: Dead time of 3.2us, example of PWM channel 1 and PWM inverted channel 1:
I read from this that I need to increase the '16' number to increase the 'dead time' period applied by the firmware - I hope that's correct. I tried doubling this to 32 but couldn't detect any real change, a couple of test rides (stock vs 'new') showed that new fw was still running around 15-20C hotter than stock.

Not sure where we can go with this now, I suppose the difference is significant and can't really be ignored as it must be having some effect on efficiency. It's a pity we can't get more tester results on this, I'm always afraid these things could be something to do with my particular setup and I'm giving you guys bad info.

On the plus side everything else works really well now - almost time to fit my torque sensor and begin some fun and games with that... :shock:

Forgot to mention - the github download with the user wattmeter correction you posted a link to recently wouldn't flash for me, do you want a cmd dump for this?
I guys do not have so much spare time :S sorry. I need a VM to compile your stuff, learn how to flash it etc. I will do, but dont expect it in less than 2 weeks-4weeks. Sorry :S

geofft   1 kW

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

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

Post by geofft » May 12 2018 7:15am

lqbweb wrote:
May 12 2018 7:01am

I guys do not have so much spare time :S sorry. I need a VM to compile your stuff, learn how to flash it etc. I will do, but dont expect it in less than 2 weeks-4weeks. Sorry :S
No problem, I completely understand this. I have the enormous advantage of being retired so can find more time for hobbies and interests like this.... :)
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

casainho   100 MW

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

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

Post by casainho » May 12 2018 7:24am

geofft wrote:
May 12 2018 6:49am
Casainho wrote:
- 2. Dead time: so, you have a different controller from me, I have S06S from BMSBattery and there may be difference between them. As you can see, I did measured a dead time near1us on my controller and firmware is using 1us. I think that if your controller dead time must be a little more like 1.5us, it should be very hot because it is like a kind of short circuit on mosfets!! See here my measures for dead time: https://opensourceebikefirmware.bitbuck ... gnals.html

This you can test right now, go to PWM.c file and change that 16 value:
CODE: SELECT ALL

// break, dead time and lock configuration
TIM1_BDTRConfig(TIM1_OSSISTATE_ENABLE,
TIM1_LOCKLEVEL_OFF,
// hardware nees a dead time of 1us
16, // DTG = 0; dead time in 62.5 ns steps; 1us/62.5ns = 16
TIM1_BREAK_DISABLE,
TIM1_BREAKPOLARITY_LOW,
TIM1_AUTOMATICOUTPUT_DISABLE);
As a comparison, TSDZ2 dead time I measured is 3.2us which seems to big!! Maybe the developers put that safe big value during development but didn't optimize for the final production firmware version....

TSDZ2 original firmware: Dead time of 3.2us, example of PWM channel 1 and PWM inverted channel 1:
I read from this that I need to increase the '16' number to increase the 'dead time' period applied by the firmware - I hope that's correct. I tried doubling this to 32 but couldn't detect any real change, a couple of test rides (stock vs 'new') showed that new fw was still running around 15-20C hotter than stock.

Not sure where we can go with this now, I suppose the difference is significant and can't really be ignored as it must be having some effect on efficiency. It's a pity we can't get more tester results on this, I'm always afraid these things could be something to do with my particular setup and I'm giving you guys bad info.

On the plus side everything else works really well now - almost time to fit my torque sensor and begin some fun and games with that... :shock:

Forgot to mention - the github download with the user wattmeter correction you posted a link to recently wouldn't flash for me, do you want a cmd dump for this?
So about the controller running hot, I don't know more, maybe that is because of that 1/3 more time being commuting the PWM signal... maybe someday I will revisit this or maybe some one will do.
I must say I almost never touch my motor controllers to verify this.

I just merged the code to master. It build ok for me. Please send the cmd dump.
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, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

geofft   1 kW

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

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

Post by geofft » May 12 2018 8:03am

casainho wrote:
May 12 2018 7:24am

So about the controller running hot, I don't know more, maybe that is because of that 1/3 more time being commuting the PWM signal... maybe someday I will revisit this or maybe some one will do.
I must say I almost never touch my motor controllers to verify this.
I've been using a 'worst case scenario' with this testing, i.e. controller inside saddlebag, lots of full throttle input, etc, so with normal usage this probably won't be an issue. So, as you say, let's move on.
I just merged the code to master. It build ok for me. Please send the cmd dump.
Just tried this from the master branch, now builds and flashes just fine... :)
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

casainho   100 MW

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

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

Post by casainho » May 12 2018 1:16pm

I just tested the motor torque with different startup angles. I used a pocket digital hook scale connected to the bicycle wheel to measure the torque and connected always on the same place on the wheel.

At 0 degrees got a good torque like 20kg. At 10 degrees got like 21kg and at 20 (30 degrees) I got 22kg. The issue I found was that using using 30 degrees, the motor did fail/shake to transition to angle interpolation, even with 15 degrees. So I went back to using 0 degrees.

I also played with using MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES to 0 and it works but I think with some less torque.

Also, I think an adjustment of MOTOR_ROTOR_OFFSET_ANGLE is important. For my Q85, it is 5. With 0, I got instead 17kg instead of the 20kg.

I committed the code to master branch with the option MOTOR_ROTOR_ANGLE_STARTUP on main.h, so Geoff or others can play and see of 0 value is a good one.

I think the current default values are good and there is no need now to adjust any angle value or any "magic" angle values on the firmware. The values just follow the description of FOC and motor model application notes.
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, please 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: 2744
Joined: Feb 14 2011 2:43pm

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

Post by casainho » May 12 2018 10:10pm

Finally got control of the LCD3 symbols!!

- This code waits for a press on the UP BUTTON to enable/disable all the LCD symbols.
- This code waits for a press on the DOWN BUTTON to increase the LCD backlight 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, please consider making a donation. I am being using the donations to buy needed resources for my developments. My paypal: casainho AT gmail.com.

geofft   1 kW

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

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

Post by geofft » May 13 2018 12:18pm

casainho wrote:
May 12 2018 1:16pm
I just tested the motor torque with different startup angles. I used a pocket digital hook scale connected to the bicycle wheel to measure the torque and connected always on the same place on the wheel.

At 0 degrees got a good torque like 20kg. At 10 degrees got like 21kg and at 20 (30 degrees) I got 22kg. The issue I found was that using using 30 degrees, the motor did fail/shake to transition to angle interpolation, even with 15 degrees. So I went back to using 0 degrees.

I also played with using MOTOR_ROTOR_ERPS_START_INTERPOLATION_60_DEGREES to 0 and it works but I think with some less torque.

Also, I think an adjustment of MOTOR_ROTOR_OFFSET_ANGLE is important. For my Q85, it is 5. With 0, I got instead 17kg instead of the 20kg.

I committed the code to master branch with the option MOTOR_ROTOR_ANGLE_STARTUP on main.h, so Geoff or others can play and see of 0 value is a good one.

I think the current default values are good and there is no need now to adjust any angle value or any "magic" angle values on the firmware. The values just follow the description of FOC and motor model application notes.
Got a slightly different result to you with this, with all the angles at your defaults I found startup from rest was a little rough with the motor 'growling' a little until the switch to angle interpolation.

Eventually found a setting for MOTOR_ROTOR_ANGLE_STARTUP of '15' gave the best combination of clean startup/good torque for my motor.
BBS02 V2 48v 750w, 12s lipo.
Q128H (36v 201rpm), KT36/48SVPR, LCD3, 48v 12s lipo.

Post Reply