Monitor Resolver Using Serial Communication
This example shows you how to use the resolver sensor to measure the rotor position. The resolver consists of two stator (secondary) windings placed orthogonally around the resolver rotor (primary) winding. After you mount the resolver sensor over a PMSM, the resolver rotor winding rotates with the shaft of the running motor. Meanwhile, the controller provides a fixed-frequency excitation signal (alternating sinusoidal or square pulse) to the primary 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.
The resolver uses the primary excitation input signal to generate the modulated secondary sine and cosine waveforms. It utilizes one winding to two winding transformations. The sine and cosine modulation occurs in the secondary windings because of the design and construction of these windings, which places them at positions that are 90 degrees apart.
After receiving the secondary signals, the controller samples them using ADC and normalizes them.
Resolver excitation methods
The example uses the following two excitation methods:
Sinusoidal excitation — The primary excitation signal is sinusoidal. This generates sinusoidal secondary waveforms after modulation.
Square pulse excitation — The primary excitation signal is a square-pulse signal. This generates square pulse secondary signals after modulation.
The example uses the Resolver Decoder block to compute the mechanical position of the resolver or motor. By default, this block uses a discrete step size that is identical to the sampling time used by the example. For more details about how the block functions with these excitation techniques, see Resolver Decoder.
The example includes these models:
mcb_resolver_f28069m — This model:
- Supports the sinusoidal excitation technique.
- Supports the LAUNCHXL-F28069M controller and BOOSTXL-DRV8305 inverter.
- Supports only one pole pair resolver.
- Computes mechanical position of the resolver or motor.
mcb_resolver_f28379d — This model:
- Supports the square-pulse excitation technique.
- Supports the LAUNCHXL-F28379D controller and BOOSTXL-DRV8305 inverter.
- Supports a resolver with any number of pole pairs.
- Computes mechanical position of the resolver or motor.
You can use these models only for code generation.
Required MathWorks Products
For the models mcb_resolver_f28069m and mcb_resolver_f28379d:
Motor Control Blockset™
C2000™ Microcontroller Blockset
The example provides 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 and Use Utility Functions.
Generate Code and Deploy Model to Target Hardware
This section shows you how 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. To use the host model, first 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 mechanical shaft angle from the controller. You can observe the computed shaft position in the Time Scope block in the host model.
The example supports these hardware configurations. To open the model, click the link or type the target model name in MATLAB®.
LAUNCHXL-F28069M controller + BOOSTXL-DRV8305 inverter: mcb_resolver_f28069m
LAUNCHXL-F28379D controller + BOOSTXL-DRV8305 inverter: mcb_resolver_f28379d
For connections related to the hardware configurations, see LAUNCHXL-F28069M and LAUNCHXL-F28379D Configurations.
Generate Code and Run Model on Target Hardware
1. Complete the hardware connections and open one of these target models:
mcb_resolver_f28069m — Use this model for the sinusoidal excitation technique.
mcb_resolver_f28379d — Use this model for the square-pulse excitation technique.
2. Load a sample program to CPU2 of the LAUNCHXL-F28379D controller to ensure that CPU2 is not mistakenly configured to use the board peripherals intended for CPU1. For example, load the program that operates the CPU2 blue LED by using the GPIO31 port (c28379D_cpu2_blink.slx). For more information about the sample program or model, see the Task 2 - Create, Configure and Run the Model for TI Delfino F28379D LaunchPad (Dual Core) section in Getting Started with Texas Instruments C2000 Microcontroller Blockset (C2000 Microcontroller Blockset).
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.
For details about the serial communication between the host and target models, see Host-Target Communication.
5. In the host model, select the hardware that you are using:
TI F28379D — Select this option for the target model mcb_resolver_f28379d.
TI F28069M — Select this option for the target model mcb_resolver_f28069m.
6. In the model initialization script associated with the target model, specify the communication port using the variable target.comport. The example uses this variable to update the Port parameter of the Host Serial Setup, Host Serial Receive, and Host Serial Transmit blocks available in the host model.
Alternatively, in the masks of the following host model blocks, you can manually select a communication Port:
mcb_resolver_host_read/Host Serial Setup
mcb_resolver_host_read/Serial Communication/Host Serial Receive/Data_Type_Float/ Host Serial Receive
mcb_resolver_host_read/Serial Communication/Host Serial Receive/Data_Type_Fixed_Point/ Host Serial Receive
7. If you want to change the default baud rate (in the host and target models), use the Host Serial Setup block mask to select a different Baud rate value.
8. Click Run on the Simulation tab to run the host model.
9. Open the Time Scope block in the host model.
10. Rotate the resolver shaft and observe the computed shaft mechanical position signal in the Time Scope block.