I need to design a field-oriented-control (FOC) controller for a permanent magnet synchronous motor (PMSM) with position sensor. In the starting process where the motor goes from zero speed to rated speed, the controller should be able to control the motor to produce constant torque. After the motor reaches rated speed, the controller should controller the motor to maintain the speed even when the motor load varies in certain range. I know PMSM is normally controlled with a speed loop and Id/Iq loop, and Iq loop is the one that controls the torque. So, what would this controller look like or how different loops are used to realize such a motor control process? Is it like Iq controller only during starting process and then add the speed controller once it reaches rated speed? If yes, how to switch the Iq_ref smoothly from a constant value to the output of speed controller without causing a sudden change of motor torque?
The typical structure is, as you mention, a Id/Iq loop and a speed loop. However, you don't "switch between" them. Normally, the Iq-controller would take a requested torque as input (equivalent to a certain Iq), and control the motor to achieve this, using feedback from current sensors, while the speed-controller, would take a requested speed as input, and produce a torque-request as output.
You still need the torque-controller to control the motor, but now you can ask the outer conroller for a speed instead of a torque. The output of the speed-controller will typically be limited to be within the rated torque of the motor.
If I understand your goal correctly, you need to tune this system so that when the input to the speed-controller (the outer controller) steps from zero to the rated speed, the response of the motor (its step response) is smooth and controlled, without overshooting the speed, or overloading anything. After all, you will need to lower the torque request before you hit the required speed, otherwise you will overshoot. How early you need to lower it, is what the speed-controller will figure out.
How this tuning is done will depend on what kind of (mechanical) load the motor is driving, and how known the various parameters are.
Have a look on my answer to similar question.
What you describe is an ordinary FOC control loop made of cascaded loops: position, speed, torque.
In the starting process where the motor goes from zero speed to rated speed, the controller should be able to control the motor to produce constant torque.
See, the speed \$\Omega\$ is differentiated to get the \$\alpha\$ and then multiplied by J to get the torque setpoint. The velocity controller just corrects the velocity error.
When the drive reaches the setpoint speed, then the speed controller output just sets the torque that is needed to overcome the load torque.
Is it like Iq controller only during starting process and then add the speed controller once it reaches rated speed?
Iq and Id are current controllers, they are always present and working.
If yes, how to switch the Iq_ref smoothly from a constant value to the output of speed controller without causing a sudden change of motor torque?
The speed controller and the feedforward path does it for you. Keep in mind that is up to you to ramp the velocity, possibly in S-shape and write the correct value for the J.