Monitor Resolver Using Serial Communication

This example operates the resolver sensor to measure the rotor position. The resolver consists of two orthogonally placed stator windings placed around the resolver rotor winding. After you mount the resolver sensor over a PMSM, the resolver rotor winding rotates along with the shaft of the running motor. The controller provides a fixed frequency alternating excitation signal to the resolver rotor winding. When the resolver rotor rotates, the resolver stator windings produce output (secondary sine and cosine) signals that are modulated with the sine and cosine of the shaft angle or position. After receiving the secondary signals, the controller samples and normalizes them.


The example includes this model:

  • mcb_resolver_f28069m

You can use this models only for code generation. You can use the open_system command to open the Simulink® model. For example, use this command for a F28069M based controller:


Required MathWorks® Products

For the model: mcb_resolver_f28069m

  • Motor Control Blockset™

  • Embedded Coder®

  • Embedded Coder® Support Package for Texas Instruments™ C2000™ Processors

  • Fixed-Point Designer™


We provide default inverter parameters with the target model. If you want to change the default values, you can update the inverter parameters in the model initialization script associated with the Simulink® model. For instructions, see Estimate Control Gains from Motor Parameters.

Generate Code and Deploy Model to Target Hardware

This section instructs you to generate code and run the FOC algorithm on the target hardware.

The example uses a host and a target model. The host model is a user interface to the controller hardware board. You can run the host model on the host computer. The prerequisite to use the host model is to deploy the target model to the controller hardware board. The controller in the target model uses the Resolver Decoder block to process the sampled and normalized secondary sine and cosine signals to obtain the shaft (or motor) position. The host model uses serial communication to command the target model and obtain the computed shaft angle from the controller. You can observe the computed shaft position in the Time Scope block of the host model.

Required Hardware

This example supports this hardware configuration. Use the target model name (highlighted in bold) to open the model for the corresponding hardware configuration, from the MATLAB® command prompt.

  • LAUNCHXL-F28069M controller + BOOSTXL-DRV8305 inverter: mcb_resolver_f28069m

For connections related to the preceding hardware configuration, see LAUNCHXL-F28069M and LAUNCHXL-F28379D configurations.

Generate Code and Run Model on Target Hardware

1. Complete the hardware connections and open the target model mcb_resolver_f28069m.

2. Load a sample program to CPU2 of LAUNCHXL-F28379D, for example, program that operates the CPU2 blue LED by using GPIO31 (c28379D_cpu2_blink.slx), to ensure that CPU2 is not mistakenly configured to use the board peripherals intended for CPU1.

3. Click Build, Deploy & Start on the Hardware tab to deploy the target model to the hardware.

4. Click the host model hyperlink in the target model to open the associated host model. You can also use the open_system command to open the host model. For example, use this command for the F28069M based controller:


For details about the serial communication between the host and target models, see Host-Target Communication.

5. In the Serial Receive and Serial Configuration block masks of the host model, select a Communication port value.

6. If you want to change the default baud rate (in the host and target models), use the Serial Configuration block mask in the models to select a different Baud rate value.

7. Click Run on the Simulation tab to run the host model.

8. Open the Time Scope block in the host model.

9. Rotate the resolver shaft and observe the computed shaft position signal in the Time Scope block.