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

Basia said:
casainho said:
Basia said:
casainho said:
Please explain what documentation are you following and which step is asking you that information.

I want to set up the correct FOC. picked up 131, but the wheel does not turn very quickly. if you increase the degree - increases the speed and current.
Please post here the instructions you are reading about setup that value.
I measure the battery current and change the angle settings. Sometimes the wheel does not turn, sometimes the wheel turns very badly. I picked up the value of the angle 131 (the smallest current), but the wheel does not rotate at maximum rpm and in the other direction. I chose the angle arbitrarily.
Here the instructions at config-example.h:

// This value should be near 0. When measured with an oscilloscope, for a Q85 motor, the offset is 5
// You can try to tune with the whell on the air, full throttle and look at batttery current: adjust for lower battery current
#define MOTOR_ROTOR_OFFSET_ANGLE 0
 
I met big angles in this topic, some people wrote about 127, 221, 60, 80 ...
Later I'll try to start the setting from 0 and move through 5 degrees.
 
Basia said:
I met big angles in this topic, some people wrote about 127, 221, 60, 80 ...
Later I'll try to start the setting from 0 and move through 5 degrees.
Also stancecoke told you on last messages for you to read config-example.h.
 
casainho said:
Basia said:
I met big angles in this topic, some people wrote about 127, 221, 60, 80 ...
Later I'll try to start the setting from 0 and move through 5 degrees.
Also stancecoke told you on last messages for you to read config-example.h.

I can not configure the controller. instructions at config-example.x is already obsolete, many new settings.

I have the wheel spinning itself after releasing the throttle ...

what's wrong with me in the file config.h ?

I have a scooter with a wheel of 8 inches 350-500 watts. I do not have a PAS.
 

Attachments

  • config.h
    1.4 KB · Views: 53
Basia said:
casainho said:
Basia said:
I met big angles in this topic, some people wrote about 127, 221, 60, 80 ...
Later I'll try to start the setting from 0 and move through 5 degrees.
Also stancecoke told you on last messages for you to read config-example.h.

I can not configure the controller. instructions at config-example.x is already obsolete, many new settings.

I have the wheel spinning itself after releasing the throttle ...

what's wrong with me in the file config.h ?
You need to follow config-example.h to build your config.h file.
 
casainho said:
Basia said:
casainho said:
Basia said:
I met big angles in this topic, some people wrote about 127, 221, 60, 80 ...
Later I'll try to start the setting from 0 and move through 5 degrees.
Also stancecoke told you on last messages for you to read config-example.h.

I can not configure the controller. instructions at config-example.x is already obsolete, many new settings.

I have the wheel spinning itself after releasing the throttle ...

what's wrong with me in the file config.h ?
You need to follow config-example.h to build your config.h file.

I set up. the wheel is spinning without throttle (
how to setup ? my battery 48v
#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 25
#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP 10
I do not understand
 
Basia said:
casainho said:
Basia said:
casainho said:
Also stancecoke told you on last messages for you to read config-example.h.

I can not configure the controller. instructions at config-example.x is already obsolete, many new settings.

I have the wheel spinning itself after releasing the throttle ...

what's wrong with me in the file config.h ?
You need to follow config-example.h to build your config.h file.

I set up. the wheel is spinning without throttle (
how to setup ? my battery 48v
#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 25
#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP 10
I do not understand
Does it spin with throttle unconnected? And with throttle connected?
 
Casainho can you explain whats the difference between "MOTOR_CURRENT" and "BATTERY_CURRENT" in your code?
Both are measured from the 100mOhm shunt, so both are actually battery currents?
I want to understand how the phase current limiter works. The MOTOR_PHASE_B_CURRENT is by design close to 0 as we correct the ui8_angle_correction, right? So how do we know the current :?:
 
dr_lulz said:
Casainho can you explain whats the difference between "MOTOR_CURRENT" and "BATTERY_CURRENT" in your code?
Both are measured from the 100mOhm shunt, so both are actually battery currents?
I want to understand how the phase current limiter works. The MOTOR_PHASE_B_CURRENT is by design close to 0 as we correct the ui8_angle_correction, right? So how do we know the current :?:

There are 2 different ADC measurements from the shunt circuit, one represent MOTOR PHASE CURRENT ("MOTOR_CURRENT") and the other the BATTERY CURRENT.

MOTOR_PHASE_B_CURRENT is even another signal, specifically only motor phase B current.

Where you read MOTOR_CURRENT, it should be MOTOR PHASE CURRENT:
Code:
  if ((UI8_ADC_BATTERY_CURRENT > ui8_adc_target_battery_current_max) || // battery max current, reduce duty_cycle
      (ui8_adc_motor_current > ui8_adc_target_motor_current_max) || // motor max current, reduce duty_cycle
      (ui16_motor_speed_erps > MOTOR_OVER_SPEED_ERPS) || // motor speed over max ERPS, reduce duty_cycle
      (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--;
    }
  }

MOTOR_PHASE_B_CURRENT is only used for FOC, specifically to read "FOC Id current" at a very specific rotor position and then we can control "FOC Id current" to be zero and so get max torque per amp (efficiency).
 
dr_lulz said:
Casainho can you explain whats the difference between "MOTOR_CURRENT" and "BATTERY_CURRENT" in your code?
Both are measured from the 100mOhm shunt, so both are actually battery currents?
SEE HERE my notes about that: 2018.02.20 - Reading motor phase current from the DC link current (shunt) -- https://opensourceebikefirmware.bitbucket.io/development/heets_and_application_notes--Endless-sphere.com_forum_messages--2018.02.20_-_Reading_motor_phase_current_from_the_DC_link_current_(shunt).html
 
casainho said:
Basia said:
casainho said:
Basia said:
I can not configure the controller. instructions at config-example.x is already obsolete, many new settings.

I have the wheel spinning itself after releasing the throttle ...

what's wrong with me in the file config.h ?
You need to follow config-example.h to build your config.h file.

I set up. the wheel is spinning without throttle (
how to setup ? my battery 48v
#define PWM_DUTY_CYCLE_RAMP_UP_INVERSE_STEP 25
#define PWM_DUTY_CYCLE_RAMP_DOWN_INVERSE_STEP 10
I do not understand
Does it spin with throttle unconnected? And with throttle connected?

throttle is connected. I press the throttle - the wheel starts to spin, release the throttle - the wheel does not stop. this is not cruise control
 
Basia said:
throttle is connected. I press the throttle - the wheel starts to spin, release the throttle - the wheel does not stop. this is not cruise control
Maybe because you are using a lab power supply and not a battery??
 
casainho said:
Basia said:
throttle is connected. I press the throttle - the wheel starts to spin, release the throttle - the wheel does not stop. this is not cruise control
Maybe because you are using a lab power supply and not a battery??

I use a 48v battery. I'll record a video later.
 
stancecoke said:
I'm planning to test this things at the testbench:

1. keeping erps and dutycycle constant, adjust advance angle to optimum battery current
2. keeping erps and advane angle constant, adjust the dutycycle to optimum battery current

I've done the second test now, also. No surprise, behavior is like described before. The advance angle value of 146 seems to be the best for the tested speed of about 11 erps. In the lower graph, you can see, that the DC rail voltage increases while regen.

duty cycle influence at different advance angles.PNG



casainho said:
As I see, we don't amplify BEMF voltage but instead reduce battery phase voltage by reducing the duty-cyle and so that way the current will flow to battery.

The step-up-converter effect of the PWM can be shown very good, if the battery is not connected and the controller is only powerd by the 5v of programming interface (motor running as generator at 11 erps and DC=0, means 50%).



regen voltage without battery connected.jpg

regards
stancecoke
 
And so what are your conclusions? I must say I don't understand where you want to arrive.

Changing the angle value and/or duty-cycle value?
 
casainho said:
And so what are your conclusions?

my conclusion is to set the advance angle to a neutral value (127) and let the PI-controller control the current to the desired value for regen. Most times the duty cycle will run to zero as you can't reach the desired current (if you set 8A in the config.h for example) at moderate speeds. This is the way I've implemented regen before, but I thougt we could improve that, as many BionX users tell, that they can achieve e.g. 600W :shock: regen power. This must be downhill at 50 km/h... we had a discussion at the german forum about that...

regards
stancecoke.
 
Basia said:
casainho said:
Basia said:
throttle is connected. I press the throttle - the wheel starts to spin, release the throttle - the wheel does not stop. this is not cruise control
Maybe because you are using a lab power supply and not a battery??

I use a 48v battery. I'll record a video later.
[youtube]CcSq3_qbpWY[/youtube]
[youtube]oZ1CpjuJOJs[/youtube]
 
stancecoke said:
casainho said:
And so what are your conclusions?
my conclusion is to set the advance angle to a neutral value (127) and let the PI-controller control the current to the desired value for regen.
So that means that motor should stop with the angle value at zero. So this is the angle between current and BEMF (rotor magnetic flux) - and that angle will increase as motor increases in speed and current and as you tested, should be zero when braking to stop the motor. I would say that as the angle increases with speed and current, it should also decrease when braking and then return to the zero value when motor is stopped - that is what makes sense and not abruptly put it to zero value.

So, for it to decrease, the both phase current and speed changes, with speed decreasing (it will always, decrease, right?) and current will always invert in signal but can increase or decrease the amplitude.

Seems logic that we need to look a current direction/signal. I think that I saw phase current signal invert 180 degrees when braking and if that happens, so mantain the same logic for increase/decrease the angle will mean that will work as expect. On current code I invert the logic of increasing/decreasing the angle when regen and so that is why it should run away from the correct value.

On TSDZ2, FOC angle is calculated as Iphase*w*L / Vphase. I am not doing regen on TSDZ2 as It doesn't regen by design, so my angle is always positive. What if I had to do FOC also for regen? w and L are always positive, as also Vphase. Only Iphase changes in signal to be negative and that would get a asin(-value) and so giving a negative angle value!

So I think that is it. When regen, Iphase changes in signal and then we need to "decrease" the angle. And yes, currently I think that we should keep reading the angle at the same rotor position / BEMF / rotor magnetic flux.
 
I'm confused, how can I fix it? (((
[youtube]Mrh2Cx6gcyw[/youtube]
why the motor does not stop? How to change the direction of rotation? corner 133 is the only correct one that rotates the motor quickly and quietly.
On the stock firmware, the wheel rotated in the normal direction.
 
Basia said:
I'm confused, how can I fix it? (((
[youtube]Mrh2Cx6gcyw[/youtube]
If you are using "my" code, which I am familiar with, I would say that on the previous video that issue does not happen if you are riding the device... That is regen happening very slowly as that wheel has a very small mass.

On the last videos, when it accelerates without pushing the throttle, it is usually also regen working but in wrong conditions, like using a lab power supply instead of a battery.

This is the only piece if code that will increase duty-cycle automatically/without user pushing the throttle:

Code:
else if ((UI8_ADC_BATTERY_VOLTAGE > ((uint8_t) ADC_BATTERY_VOLTAGE_MAX)) || // verify battery max voltage limit
      (UI8_ADC_BATTERY_CURRENT < ui8_adc_target_battery_regen_current_max) || // verify battery max regen current limit
      (ui8_adc_motor_current < ui8_adc_target_motor_regen_current_max)) // verify motor max regen current limit
  {
    if (ui8_duty_cycle < 255)
    {
      ui8_duty_cycle++;
    }
  }
 
casainho said:
Basia said:
I'm confused, how can I fix it? (((
[youtube]Mrh2Cx6gcyw[/youtube]
If you are using "my" code, which I am familiar with, I would say that on the previous video that issue does not happen if you are riding the device... That is regen happening very slowly as that wheel has a very small mass.

On the last videos, when it accelerates without pushing the throttle, it is usually also regen working but in wrong conditions, like using a lab power supply instead of a battery.

This is the only piece if code that will increase duty-cycle automatically/without user pushing the throttle:

Code:
else if ((UI8_ADC_BATTERY_VOLTAGE > ((uint8_t) ADC_BATTERY_VOLTAGE_MAX)) || // verify battery max voltage limit
      (UI8_ADC_BATTERY_CURRENT < ui8_adc_target_battery_regen_current_max) || // verify battery max regen current limit
      (ui8_adc_motor_current < ui8_adc_target_motor_regen_current_max)) // verify motor max regen current limit
  {
    if (ui8_duty_cycle < 255)
    {
      ui8_duty_cycle++;
    }
  }

powered by a 48v battery. settings changed only in the java-tool Code as in my file motor.c
 
Basia said:
powered by a 48v battery. settings changed only in the java-tool
I am losting my time while you don't follow only the config-example.h.
 
casainho said:
Basia said:
powered by a 48v battery. settings changed only in the java-tool
I am losting my time while you don't follow only the config-example.h.

I deleted this code and the throttle is working fine but the maximum speed has decreased to 35km/h
 
Basia said:
casainho said:
Basia said:
powered by a 48v battery. settings changed only in the java-tool
I am losting my time while you don't follow only the config-example.h.

I deleted this code and the throttle is working fine but the maximum speed has decreased to 35km/h
Verify if MOTOR_ROTOR_OFFSET_ANGLE is the best possible and aslo what should be the ERPs speed at that 35km/h, can't be higher than 525.
 
casainho said:
Basia said:
casainho said:
Basia said:
powered by a 48v battery. settings changed only in the java-tool
I am losting my time while you don't follow only the config-example.h.

I deleted this code and the throttle is working fine but the maximum speed has decreased to 35km/h
Verify if MOTOR_ROTOR_OFFSET_ANGLE is the best possible and aslo what should be the ERPs speed at that 35km/h, can't be higher than 525.
why this code reduces the maximum speed by 20-25 km/h? with this code speed 55-57
I can not find another angle of the motor. well working angles can be multiple?
 
Back
Top