Monitor Resolver Using Serial Communication
This example operates the resolver sensor to measure the rotor position. The resolver consists of two orthogonally placed stator (secondary) windings placed around the resolver rotor (primary) winding. After you mount the resolver sensor over a PMSM, the resolver rotor winding rotates along with the shaft of the running motor. Meanwhile, the controller provides a fixed frequency excitation signal (either alternating sinusoidal or square pulse signal) 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.
Therefore, the resolver uses 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 — When the primary excitation signal is sinusoidal. This generates sinusoidal secondary waveforms after modulation.
Square pulse excitation — When 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 which 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 sinusoidal excitation technique.
- Supports LAUNCHXL-F28069M controller + BOOSTXL-DRV8305 inverter.
- Supports only one pole pair resolver.
- Computes mechanical position of resolver or motor.
mcb_resolver_f28379d — This model:
- Supports square pulse excitation technique.
- Supports LAUNCHXL-F28379D controller + BOOSTXL-DRV8305 inverter.
- Supports resolver with any number of pole pairs.
- Computes mechanical position of resolver or motor.
You can use these models only for code generation.
You can also use the open_system command to open these Simulink® models. For example, use this command for a F28069M based controller:
Required MathWorks® Products
For the models mcb_resolver_f28069m and mcb_resolver_f28379d:
Motor Control Blockset™
Embedded Coder® Support Package for Texas Instruments™ C2000™ Processors
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 and Use Utility Functions.
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 mechanical shaft angle from the controller. You can observe the computed shaft position in the Time Scope block of the host model.
The example supports these hardware configurations. You can also use the target model name to open the model for the corresponding hardware configuration, from the MATLAB® command prompt.
LAUNCHXL-F28069M controller + BOOSTXL-DRV8305 inverter: mcb_resolver_f28069m
LAUNCHXL-F28379D controller + BOOSTXL-DRV8305 inverter: mcb_resolver_f28379d
For connections related to the preceding 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 — If you are using sinusoidal excitation technique.
mcb_resolver_f28379d — If you are using square pulse excitation technique.
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 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 — If you are using the target model mcb_resolver_f28379d.
TI F28069M — If you are using the target model mcb_resolver_f28069m.
6. In the masks of the following host model blocks, 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.