Pid control for speed and position at the same time with a AS5600 rotary sensor

I'm trying to setup a PID controller that controls speed and position of a dc motor. I need the speed to ramp up and down at a certain rate. I also need the motor to follow a set position that is updated. I know how to do both separately, but I've never done both at the same time. Does anyone have any references or know a way about going about this? Any help would be appreciated.


Speed just comes down to the motor being in a given position at a given time. PID is the way you achieve that position (the setpoint). So PID shouldn't need to know anything about speed. You handle the simple calculation of when the setpoint should change in your sketch code and pass that to the PID algorithm.

If you tune the D term correctly it should arrive at its destination with zero velocity. Is this not what you want?