Getting started closed loop torque control

Hi! I recently discovered simpleFOC and have tried to follow the (excellent!) tutorials here. They have worked well until I try to use Step run: " Step 3. Closed-loop control - torque using voltage"

I am using a nema17 stepper motor with a TB6612 driver controlled by an ESP32. The AS5600 is the magnetic sensor I am using.

ESP32-DRV: Configuring 2PWM in group: 0 on timer: 0
ESP32-DRV: Configuring 1 operators.
ESP32-DRV: Configuring 2 comparators.
ESP32-DRV: Configuring 2 generators.
ESP32-DRV: Configuring center-aligned pwm.
ESP32-DRV: Enabling timer: 0
ESP32-DRV: MCPWM configured!
MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.
MOT: sensor_direction==CW
MOT: PP check: fail - estimated pp: 74.47
MOT: Zero elec. angle: 2.37
MOT: No current sense.
MOT: Ready.
Motor ready.

This is the serial output. I have tried using the pp/scanner example, and when running it with

float pp_search_voltage = 6; // maximum power_supply_voltage/2
 float pp_search_angle = 20*M_PI; // search electrical angle to turn

I would find the 50 PP, but running the example as is, I get the same result as here, 75 ish.

When I try to run the code (with 50pp or 75pp) the motor does not move, but it shakes and resists when I try to move the shaft manually.

Any ideas? Thanks :slight_smile:

I also seem to have an issue with the MotionControlType::angle_openloop. It works fine running the motor in velocity_openloop, but running it in position, it does not move, only a very short buzzing noise from the motor.

Update: I switched out the ESP32 with an STM32, and now it works much better. I used a cheapo knockoff esp32.

1 Like