This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
(this question is likely similar to another recent question titled "How to eliminate the effect of reverse ampere force"
I have a need to limit torque (basically current) in one direction differently from the other direction of motion.
I am using lab05b and also lab10a (which adds overmodulation). Both work well but I have not found a way to limit torque differently in one direction of rotation versus the other.
I have found and changed settings outMin,outMax in ctrl.h, which does allow me to limit torque differently for different directions, but this limits the modulation instead of the torque setpoint.
Limiting the modulation severely limits the speed, which is not useful to me. I simply want to limit, the negative torque setpoint output of the speed PI controller differently from the positive torque setpoint output.
It may be that I simply stumbled into the wrong outMin to limit, but I have hard a hard time trying to understand the program flow because so many functions are inline so I cannot step through them with breakpoints.
Is there any documentation for these lower level functions?
Can you point me to the general area where I should be experimenting in the code?
Thanks
Set the negative and positive torque current by calling the functions as below.
TRAJ_setMinValue(obj->trajHandle_spd, gNegTorqueCurrent);
TRAJ_setMaxValue(obj->trajHandle_spd, gPosTorqueCurrent);
Thanks, but where do I set this and why does it affect speed control? I'm not doing position control.
lt looks like these are set to zero in ctrl.c and I can't find any references to these being set again.
Notably, trail_Handle_Iq is not set here (or anywhere I can find).
Can you give me more hints ?
In ctrl.c, I see (lines 422-443)
// set the default Id current trajectory module parameters
TRAJ_setIntValue(obj->trajHandle_Id,_IQ(0.0));
TRAJ_setTargetValue(obj->trajHandle_Id,_IQ(0.0));
TRAJ_setMinValue(obj->trajHandle_Id,_IQ(0.0));
TRAJ_setMaxValue(obj->trajHandle_Id,_IQ(0.0));
TRAJ_setMaxDelta(obj->trajHandle_Id,_IQ(0.0));
// set the default the speed trajectory module parameters
TRAJ_setIntValue(obj->trajHandle_spd,_IQ(0.0));
TRAJ_setTargetValue(obj->trajHandle_spd,_IQ(0.0));
TRAJ_setMinValue(obj->trajHandle_spd,_IQ(0.0));
TRAJ_setMaxValue(obj->trajHandle_spd,_IQ(0.0));
TRAJ_setMaxDelta(obj->trajHandle_spd,_IQ(0.0));
// set the default maximum speed trajectory module parameters
TRAJ_setIntValue(obj->trajHandle_spdMax,_IQ(0.0));
TRAJ_setTargetValue(obj->trajHandle_spdMax,_IQ(0.0));
TRAJ_setMinValue(obj->trajHandle_spdMax,_IQ(0.0)); // not used
TRAJ_setMaxValue(obj->trajHandle_spdMax,_IQ(0.0)); // not used
TRAJ_setMaxDelta(obj->trajHandle_spdMax,_IQ(0.0)); // not used
In CTRL_runOnLine_User() (line 2344 in ctrl.h) I am able to change the current limit in one direction as desired, but even though I think I am only limiting Iq, the no-load speed is limited. See below, where I have commented out outMin = -outMax and replaced it with outMin = -outMax / 3;
For instance, the max no load speed in the positive direction is 2400 RPM and this requires 350mA from the supply. If I apply load, I can easily draw over 2.5A.
Max loaded current in the negative direction is about 1A (that's good), but the max speed is only about 750 RPM and at that speed, the no-load current is under 200mA.
(around line 2470 in ctrl.h)
// get the feedback value
fbackValue = CTRL_getIq_in_pu(handle);
// set minimum and maximum for Id controller output
outMax = _IQsqrt(_IQmpy(maxVsMag,maxVsMag) - _IQmpy(CTRL_getVd_out_pu(handle),CTRL_getVd_out_pu(handle)));
//outMin = -outMax;
outMin = -outMax / 3; // bozo x (limits current, but also speed)
// set the minimum and maximum values
PID_setMinMax(obj->pidHandle_Iq,outMin,outMax);
// run the Iq PID controller
PID_run(obj->pidHandle_Iq,refValue,fbackValue,CTRL_getVq_out_addr(handle));
}
lt looks like these are set to zero in ctrl.c and I can't find any references to these being set again.
Notably, trail_Handle_Iq is not set here (or anywhere I can find).
Can you give me more hints ?
If you just want to set the limitation value once during initiation, you only need to change the USER_MOTOR_MAX_CURRENT in user.g according to the motor.
If you want to change the value online, you just need to set the value to the variable as mentioned above, and call these functions in background loop as below to call CTRL_setSpd_ref_krpm().
// set the speed reference
CTRL_setSpd_ref_krpm(ctrlHandle,gMotorVars.SpeedRef_krpm);
// set the maximum torque current
TRAJ_setMinValue(obj->trajHandle_spd, gNegTorqueCurrent);
TRAJ_setMaxValue(obj->trajHandle_spd, gPosTorqueCurrent);