Hi @XCYRKDSDA , welcome to SimpleFOC!
The sensor_direction parameter can be set in open loop mode, and it will change the direction the motor turns when you apply a “positive voltage” (meaning a positive Q-axis voltage).
In closed loop FOC mode, the parameter cannot be chosen by the user. Is is calibrated by the system to ensure that positive voltage corresponds to positive angle. This is what we call “CW” direction.
If the natural direction of the sensor compared to the motor is such that positive voltage corresponds to negative sensor angle, then we set the motor_direction to “CCW” to correct this problem and keep the positive correspondence in the motor algorithm even though the sensor class is the opposite.
So you can’t change the parameter in closed loop mode, you have to set the correct value.
If you want to change the direction that the motor turns you can swap two of the phase wires. This should result in the opposite setting for motor_direction during the calibration.
Of course, for a given mounting orientation of the sensor within some setup, the physical “clockwise” direction is always the same. The sensor_direction parameter relates only to the relationship of the electrical commutation to the sensor. If you want to change the direction of the motor you would just use negative target values.