I’m using this dual FOC v3.2 circuit to control two small pumps. The manufacturer provides an example open loop speed control, but they didn’t do anything with the current sensor that the hardware includes.
Looking at some code examples, it seems like adding current sensing lets you set the current limit to avoid things like damaging the motor? Am I right in thinking that by saving the current at different commanded velocities, I’d also be able to graph over time when the pump needs cleaning? Like over time as the pump clogs more, the same velocity command will result in needing higher current?
Other than sensing current and setting current limit, does instantiating the current_sense do more for speed control? Like does it make speed control more efficient or better controlled? Looking at the code, it looks like it’s only setting the current limit and reading back the current? It’s not using the current parameters in any kind of control loop?
// Initialize Motor and Driver
BLDCMotor motor = BLDCMotor(pole_pairs);
BLDCDriver3PWM driver = BLDCDriver3PWM(pwm1, pwm2, pwm3, enable);
// ... driver/motor init ...
// Initialize Current Sensing
InlineCurrentSense current_sense = InlineCurrentSense(R_shunt, gain, pinA, pinB);
// ... current sense init ...
void setup() {
// ... driver/motor setup ...
// Choose Open Loop Velocity
motor.controller = MotionControlType::velocity_openloop;
// Set Current Sensing
motor.torque_controller = TorqueControlType::foc_current;
// Set Voltage and Current limits
motor.voltage_limit = 10; // Volts
motor.current_limit = 2; // Amps
// Velocity limit (rad/s)
motor.velocity_limit = 100;
motor.init();
current_sense.init();
motor.linkCurrentSense(¤t_sense);
motor.initFOC();
}
void loop() {
motor.move(target_velocity);
motor.loopFOC(); // Runs current control
}