硬件:FOC驱动器
算法:FOC算法
疑问:
卡丁车可以在下坡的时候无阻力的遛坡,这样速度就可以很快,电瓶车也是如此。我近日想要通过手头的一块FOC的驱动器,基于FOC算法实现类似的无阻力的下坡效果,发现:
- FOC速度闭环效果可以实现防遛坡效果
- FOC速度开环效果依然会有一定的阻力,阻碍遛坡
- FOC力矩模式,无法以速度为调节,不满足使用条件
那么我应该对FOC代码中哪一部分进行调节呢?
思路:
- 想要遛坡就要降低电流,当以一定速度下坡时,降低原本的闭环电流,那么应该用什么条件来触发电流降低呢?这里,我查看了simpleFOC的驱动代码,一时半会难以想出解决办法:例如因外力原因,速度偏大,那么电机也会增大电流来抑制速度;速度偏低,电机也会增大电流来增加速度;只有当负载变轻的时候,电流才会减小来降低速度?
case MotionControlType::velocity:
// velocity set point - sensor precision: this calculation is numerically precise.
shaft_velocity_sp = target;
// calculate the torque command
current_sp = PID_velocity(shaft_velocity_sp - shaft_velocity); // if current/foc_current torque control
// if torque controlled through voltage control
if(torque_controller == TorqueControlType::voltage){
// use voltage if phase-resistance not provided
if(!_isset(phase_resistance)) voltage.q = current_sp;
else voltage.q = _constrain( current_sp*phase_resistance + voltage_bemf , -voltage_limit, voltage_limit);
// set d-component (lag compensation if known inductance)
if(!_isset(phase_inductance)) voltage.d = 0;
else voltage.d = _constrain( -current_sp*shaft_velocity*pole_pairs*phase_inductance, -voltage_limit, voltage_limit);
}
break;
case TorqueControlType::foc_current:
if(!current_sense) return;
// read dq currents
current = current_sense->getFOCCurrents(electrical_angle);
// filter values
current.q = LPF_current_q(current.q);
current.d = LPF_current_d(current.d);
// calculate the phase voltages
voltage.q = PID_current_q(current_sp - current.q);
voltage.d = PID_current_d(-current.d);
// d voltage - lag compensation - TODO verify
// if(_isset(phase_inductance)) voltage.d = _constrain( voltage.d - current_sp*shaft_velocity*pole_pairs*phase_inductance, -voltage_limit, voltage_limit);
break;
default:
// no torque control selected
SIMPLEFOC_DEBUG("MOT: no torque control selected!");
break;
}