Hi all,
My requirement is, i have to do throttle control which varies from 0 - 100% and i shall control the rpm from 0 to max in that mode, i have to operate in 3 modes with different rpm’s. I have given a single maximum Iq reference value in all 3 modes of 18000 counts (60A). But in no load conditions and other conditions the actual Iq value is very less and does not go to the max and i am unable to control the motor. It is immediately going to the full rpm, one method i want to try is controlling the Vq in different modes with different and vary as per the throttle. This is one final major issue i need to clear. Please help.
I don’t quite understand the question… it sounds like you’re running in torque control mode when you really want velocity control.
Yes i am doing torque control.
I think instead of saying Vq I can say I am controlling the modulation index, is it ok to control the modulation index?
I have not come across the idea of modulation index when related to motor control… I’m not sure it’s a usual way to talk about it.
We use pulse width modulation of a square wave carrier to produce the output current waveforms. In this scheme, I think the voltage limit (Uq) or current limit (Iq) correspond to the modulation index. If Uq-max equals Upower-supply/2 the modulation index is 100%.
I think applying throttle 0-100% mapping to Iq 0-Iq max corresponds to the idea of a throttle controlling torque, you problem is just that depending on the situation you need much less throttle, and your motor is getting much too much current. I’d say this is the reason cars have transmissions…
But this is 2 wheeler application and there is no transmission. When I change the modulation index it is basically controlling the voltage applied to motor. I am finding difficult to know iq range in different conditions. Controlling Vq will it be a problem?
I don’t think that’s a problem if it performs better for you
I made the mistake, if i do voltage control or modulation control it is leading to huge vibration and it is not the best strategy as you told. But i don’t know the Iq values under different conditions i need to study and understand transmission and control Iq. This is hub wheel motor and direct drive.
One possibility is to use MotionControlType::torque and set both the target current and motor.voltage_limit in proportion to the throttle signal. That will prevent it from accelerating to high speed at low throttle.
The problem is i do not know the target current.
Is this with SimpleFOC? If so perhaps you can share your code and we can see if we spot any problems…
Have you tested how much current the motor can handle continuously without ever getting too hot? Run it at constant current for long enough to reach equilibrium, touch it, and if it’s painful to keep your hand in contact with it for more than a few seconds, it’s too hot. Open loop mode is handy for applying constant current without moving.
You can use a higher current limit than that, but then it will be up to the rider to monitor the temperature and avoid overheat. Or if you have a temperature sensor on the motor, you can reduce the current limit when it gets hot, and perhaps alert the rider so they’re not confused by the sudden loss of torque.
It may feel better if you ramp up the torque more quickly at first.
float x = 0.3, y = 0.8;
if(throttle < x) target = (throttle/x) * (motor.current_limit*y);
else target = (motor.current_limit*y) + ((throttle-x)/(1.0-x) * (motor.current_limit*(1.0-y));
i.e. ramp up to 80% torque over the first 30% of throttle, and then ramp up the remaining 20% torque over over the remaining 70% of throttle. So you get plenty of torque at low speed, and then it’s mostly increasing the allowed maximum speed.
And set motor.voltage_limit = throttle * driver.voltage_power_supply * 0.58;
(assuming you’re using SpaceVectorPWM, that is the maximum without saturating). So max speed increases linearly with throttle, and the torque ramp can be adjusted until it feels right.
Thank you for the support, I am still performing the lab testing under no load and limited load conditions before i put it in vehicle.
As a first step under no load conditions with throttle i need to control from 0 to 250 rpm in one mode, 0 - 350 rpm in another mode and 0 - 420 rpm in another mode
This is the code i have implemented for Vq and Iq control according to throttle
#define IQ_RAMP_UP_STEP (50u)
#define IQ_RAMP_DOWN_STEP (75u)
#define VQ_RAMP_UP_STEP (10u)
#define VQ_RAMP_DOWN_STEP (1u)
#define IQMAXFORWARD (18000u)
// Vq control
DirCtrl_ModeParams_t mode_params = DirCtrl_GetParamsForMode(current_mode);
temp_mi = ((uint32_t)mode_params.vq_limit * throttle_percent);
vq_target = (uint16_t)(temp_mi/100);
Update_VqRamp(vq_target);
CircleLimitationM1.MaxModule = vq_effective;
// Hold the max iq throughout the modes only vary the MI
temp = ((int32_t)iq_max * throttle_percent);
iq_target = (int16_t)(temp / 100);
/* Vq ramp update instead of sudden fall */
void Update_VqRamp(uint16_t vq_target)
{
if(vq_effective < vq_target)
{
// Ramp up quickly
vq_effective += MIN(VQ_RAMP_UP_STEP, vq_target - vq_effective);
}
else if (vq_effective > vq_target)
{
// Ramp down slowly
vq_effective -= MIN(VQ_RAMP_DOWN_STEP, vq_effective - vq_target);
}
}
void Update_IqRamp(int16_t iq_target)
{
if (iq_effective < iq_target)
{
// Ramp up quickly
iq_effective += MIN(IQ_RAMP_UP_STEP, iq_target - iq_effective);
}
else if (iq_effective > iq_target)
{
// Ramp down slowly
iq_effective -= MIN(IQ_RAMP_DOWN_STEP, iq_effective - iq_target);
if(iq_effective < 0)
{
iq_effective=0;
}
}
}
void Throttle_RampUpdate(uint8_t raw_throttle)
{
if (raw_throttle > ramped_throttle)
{
ramped_throttle += MIN(THROTTLE_RAMP_UP_STEP, raw_throttle - ramped_throttle);
}
else if (raw_throttle < ramped_throttle)
{
ramped_throttle -= MIN(THROTTLE_RAMP_DOWN_STEP, ramped_throttle - raw_throttle);
}
// Clamp to max throttle
if (ramped_throttle > MAX_THROTTLE)
{
ramped_throttle = MAX_THROTTLE;
}
}
In the waveform my setpoint Iq is very high but the actual Iq is very less as there is minima load.
I have main difficulty in controlling the rpm otherwise the motor runs ok i was able to run motor upto 40Kg Load.
This throttle performance is really good i removed all the ramping functions, thank you.
Can you please tell me if the below algorithm will work or need to fine tune
#define CountToAmpsFactor (280u)
actual_iq = GetActualIq();
if(iq_target > actual_iq){
iqdelta = iq_target - actual_iq;
}
filtered_delta_iq = FilterIq(iqdelta);
filtered_delta_amp = filtered_delta_iq/CountToAmpsFactor; // in terms of amps
if(filtered_delta_amp > THRESHOLDAMP){
iq_max -= filtered_delta_amp;
}
The main purpose of the logic is, the max Iq shall be adjusted dynamically based on load,
The algorithm runs every time the target Iq goes to zero. I have not decided on the THRESHOLDAMP and not yet tested.
Why don’t you just set iq_max = iq_target? It looks like you’re measuring actual_iq and decrementing iq_max until that condition is met.
I am trying many algorithms, but nothing is working out. I am trying to find out how the standard controllers are implementing but not able to figure out.
My requirement is different modes (3) with different speed limits under all load conditions.
I am controlling using torque control mode (i don’t want speed control mode as ride is not smooth).
If i consider one mode and give suppose Iqmax = 15000, and the vehicle is of full load then i can control with throttle (0% - 0 - 100% - 15000 Iq) and the speed goes from 0 - 400 rpm, this is fine and can achieve it.
But suppose the vehicle is trying to run without load for some initial testing / verification, then if i give throttle to 10% it goes to full rpm and it cannot be controlled with throttle beyond 10% is the issue.
Now the problem is how to identify if it is full load or no load or with some x load and adjust the max iq.
I do not want to check for rpm and control iq then it will become speed control, i tried that but it is creating oscillations in the transition rpm.
I tried limiting the Vq but when i am doing mode switching if the rpm is high and due to high back emf i get the over voltage fault, i need to control Vq very carefully, the Iq control was looking smooth compared to Vq control and it was very hard.
So, can you please suggest what is the best method i can follow? Did anyone face this issue?
Not yet i am planning to move asap after seeing so much support and work going on. I will plan to buy hardware.
I had the same problem with back EMF spike just a couple days ago. I solved it by ramping the voltage limit, similar to PIDController’s output_ramp code. Perhaps we should move that code to its own class for easier reuse.