The thing that I’d like to ask, perhaps, looks like a noob question. However, I would like to deeply understand the code and possibly solve my doubts
I noticed that in the loopFOC(), the function setPhaseVoltage() is called, which receives the voltages q and d.
Instead, in move() function the voltages q and d are computed but not used (?).
Shouldn’t the function move() calls setPhaseVoltage() and therefore remove it from loopFOC()?
Normally, the loopFOC() is called before than move():
Perhaps, I am missing something here…
In simplefoc the
move function represents the motion control loop. It will calculate the necessary torque command to be sent to the motor in order to maintain set point velocity, angle or torque (in torque mode the
move doesn’t do much).
loopFOC function implements the torque control and then sets the pause voltages to the motor using the FOC algorithm. If the current measurements are not used it basically only represents the FOC algorithm because the torque control loop is trivial.
If you look into the docs you’ll see that when explaining the different motion/torque control loops, the blush square in the graphs represents the
loopFOC and the everythibg around is the
We could combine the two functions yes and call the
loopFOC inside of the
move but the we have chosen this approach for many reasons actually:
- torque control (
loopFOC) is in many cases intendet to run on a much higher frequency than the motion control (
move). One of the ways is by using
- to give the users a simple way to implement their own motion control loops, and maybe avoid using the
- create a clear distinction in between motion control code, the torque control and the FOC algo.
What you are absolutely right is that it is strange to call the
loopFOC first and then the
move. This is the way we’ve set it in the beginning and it stayed that way till now, but the proper way would be to call the
move first and then the