A permanent magnet synchronous motor (PMSM) with a quadrature encoder sensor requires an initial position to start the motor. As you do not have a method to determine the initial position at the beginning (before starting the motor), run the motor in open-loop and ensure that the quadrature encoder index pulse is read at least once. At the quadrature encoder index pulse, the quadrature encoder sensor resets its position to align with the mechanical angle of the motor. The motor switches from an open-loop run to closed-loop speed control to maintain the reference speed. This step is only applicable for a quadrature encoder sensor and not for a Hall position sensor. A Hall sensor outputs the initial position of the rotor segment from Hall signal port inputs.
Follow these steps to implement an open-loop motor run with a transition to closed-loop control:
Control/Control_system subsystem to your model. This adds the
logic to run the motor in open-loop. This subsystem switches the control
from open-loop to closed-loop if EnClosedLoop input is
1. Add an input port
EnClosedLoop. This adds the Data Store Read blocks
for Enable and SpeedRef. Add the Data
Store Memory blocks Enable,
EnClosedLoop, and SpeedRef in the
topmost level of the model.
When the open-loop run begins, the sign of SpeedRef decides the direction of the initial motor run. If SpeedRef is negative, the motor spins in the opposite direction during the open-loop run.
Scaling/Calculate Position and Speed subsystem to your model.
This adds the
IndexFinder block. When quadrature encoder
index pulse is detected for the first time,
port is set to
1. Add an output port
IndexFound and rename it to
Connect the output port EnClosedLoop from the Input Scaling subsystem to the input port EnClosedLoop in the Control_System subsystem as shown in this figure.
Control/Speed_Ref_Selector subsystem to your model. This block
speed_ref block when closed-loop control begins.
For a smooth transition from open-loop to closed-loop, the speed measured is
used as the speed reference during the open-loop run. Add a Data Store Write
block SpeedRef to the
PI_Controller_Speed input port.
In the plant model, a step input is added to simulate the IndexFinder
block for simulation. Rename the step input to
Switch to closed
loop. See the
Motor - Plant Model/Sensor_Measurments subsystem for the step
input for switching to closed-loop. Select the step time of
0.1 and sample time of
Create Data Store Memory blocks for EnClosedLoop,
Enable, and SpeedRef.
Enable block is used to reset the PI integrator
before running the motor. Add these default values in the Data Store Memory
blocks: Enable =
The Data Store Memory blocks are used to share data across the subsystem.
Run the simulation and observe the speed reference and the speed feedback.