main content

control pmsm loaded with dual motor (dyno) using c2000 processors -凯发k8网页登录

this example uses field-oriented control (foc) to control two three-phase permanent magnet synchronous motors (pmsm) coupled in a dyno setup. motor 1 runs in the closed-loop speed control mode. motor 2 runs in the torque control mode and loads motor 1 because they are mechanically coupled. you can use this example to test a motor in different load conditions.

the example simulates two motors that are connected back-to-back. you can use a different speed reference for motor 1 and a different torque reference for motor 2 (derived from the magnitude and electrical position of the motor 2 reference stator current). motor 1 runs at the reference speed for the load conditions provided by motor 2 (with a different torque reference).

the example runs in the controller hardware board. you can input the speed reference for motor 1 and current reference for motor 2 using a host model. the host model uses serial communication to communicate with the controller hardware board.

current control loops in motor 1 and motor 2 control algorithms are offset by ts/2, where ts is the control-loop execution rate.

single cpu dyno models

the example includes the following models:

  • .

  • .

  • for qep based dyno mcb_pmsm_foc_f28379d_dyno example, refer (motor control blockset) .

you can use mcb_pmsm_foc_sensorless_dyno_f28379d and mcb_pmsm_foc_qep_dyno_f28069m models for both simulation and code generation. you can also use the open_system command to open the simulink® model. these models use timer0 as a base rate trigger. for example, use this command for a f28379d based controller:

open_system('mcb_pmsm_foc_sensorless_dyno_f28379d.slx');

dual cpu dyno models

the example includes the following models:

  • .

  • .

you can also use the open_system command to open the simulink® model.

note: dual core cpu models does not support simulation.

for example, use this command for a f28379d based controller:

open_system('mcb_pmsm_foc_dual_cpu1_f28379d.slx');

open_system('mcb_pmsm_foc_dual_cpu2_f28379d.slx');

ipc communication for dual core processors

the cpu1 transmits the following data to cpu2 through ipc channels:

  • torque reference

  • signal select

  • enable motor2(enmtr2ctrl)

the cpu2 transmits the debug signal according to the signal select of cpu1.

core1 transmits data to its allocated memory (core1-to-core2 message ram) and receives data from the allocated memory of core2 (core2-to-core1 message ram). similarly, core2 transmits data to its allocated memory (core2-to-core1 message ram) and receives data from allocated memory of core1 (core1-to-core2 message ram). for more information, refer .

peripheral block configurations for dyno setup

set the peripheral block configurations for this model. double-click on the blocks to open block parameter configurations. you can use the same parameter values if you want to run this example for other hardware boards.

  • epwm block configuration the epwm1/2/3 is offset by epwm time period from epwm4/5/6. this is achieved by sending a synchronization signal from epwm3 to epwm4 and setting the phase offset value of epwm4 as target.pwm_counter_period.

  • adc block configuration

the algorithm in this example uses an asynchronous scheduling. the pulse width modulation (pwm) block triggers the adc conversion. at the end of conversion, the adc posts an interrupt that triggers the main foc algorithm. for more information, refer .

for single cpu model:

  • adc channel for inverter 1

  • adc channel for inverter 2

for dual cpu model, the adc channels for inverter 2 is defined in the initialize function of the cpu1 model. in cpu2 model, we use memory copy blocks, to access the value of the adc registers.

configure the model

1. open the 'mcb_pmsm_foc_dual_cpu1_f28379d' and 'mcb_pmsm_foc_dual_cpu2_f28379d' model. this model is configured for ti delfino f28379d launchpad.

2. to run the model on other ti c2000 processors, first press ctrl e to open the configuration parameters dialog box. then, select the required hardware board by navigating to hardware implementation > hardware board.

3. the following screenshots show the scheduler configurations performed in the dual cpu model.

note:

  • for single cpu model, ensure that the base rate trigger is timer0.

  • ensure that the default parameter behavior is set to inlined (configuration parameters > code generation > optimization).

4. ensure that the baud rate is set to 12e6 bits/sec.

required mathworks® products

to simulate model:

  • motor control blockset™

to generate code and deploy model:

  • motor control blockset™

  • embedded coder®

  • c2000™ microcontroller blockset

  • fixed-point designer™ (only needed for optimized code generation)

prerequisites

1. obtain the motor parameters for both motor 1 and motor 2. we provide default motor parameters with the simulink® model that you can replace with the values from either the motor datasheet or other sources.

however, if you have the motor control hardware, you can estimate the parameters for the motor that you want to use, by using the motor control blockset™ parameter estimation tool. for instructions, see estimate pmsm parameters using recommended hardware (motor control blockset).

2. update the motor parameters (that you obtained from the datasheet, other sources, or parameter estimation tool) and inverter parameters in the model initialization script associated with the simulink® model. for instructions, see estimate control gains and use utility functions (motor control blockset).

for this example, update the motor parameters for both the motors in the model initialization script.

simulate model

this example supports simulation. follow these steps to simulate the model.

1. open or model included with this example.

2. click run on the simulation tab to simulate the model.

3. click data inspector on the simulation tab to view and analyze the simulation results.

4. input a different speed reference for motor 1 and a different current reference (load) for motor 2. observe the measured speed and other logged signals in the data inspector.

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 host model uses serial communication to command the target simulink® model and run the motor in a closed-loop control.

required hardware

the example supports this hardware configuration. 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 2 boostxl-drv8305 inverters:

  • launchxl-f28379d controller 2 boostxl-drv8305 inverters:

  • launchxl-f28379d controller 2 boostxl-drv8305 inverters:

  • launchxl-f28379d controller 2 boostxl-drv8305 inverters:

  • for launchxl-f28379d controller 2 boostxl-3phganinv inverters: , refer to (motor control blockset)

for connections related to the preceding hardware configuration, see .

generate code and run model on target hardware

1. simulate the target model and observe the simulation results.

2. complete the hardware connections.

3. the model automatically computes the adc (or current) offset values. to disable this functionality (enabled by default), update the value 0 to the variable inverter.adcoffsetcalibenable in the model initialization script.

alternatively, you can compute the adc offset values and update it manually in the model initialization scripts. for instructions, see .

4. compute the quadrature encoder index offset value and update it in the model initialization scripts associated with the target model. for instructions, see .

for this example, update the qep offset values in the pmsm_motor1.positionoffset and pmsm_motor2.positionoffset variables in initialization script.

5. open the target model. if you want to change the default hardware configuration settings for the model, see (motor control blockset).

6. to ensure that cpu2 is not mistakenly configured to use the board peripherals intended for cpu1, load a sample program to cpu2 of launchxl-f28379d, for example, a program that operates the cpu2 blue led by using gpio31 (c28379d_cpu2_blink.slx).

note:

  • for dual cpu model, you must build and download cpu1 and cpu2 models to respective cores of the processor. each core controls one motor on the dual motor control kit. two cores communicate each other using ipc. cpu1 model sends load torque request to cpu2. cpu2 sends data to be logged to cpu1.

  • after deploying the code, full power reset should be done on the launchpad to ensure proper execution of the code.

7. click build, deploy & start on the hardware tab to deploy the model to the hardware.

8. click the host model hyperlink in the target model to open the associated host model. these are the following host models:

  • .

  • .

  • .

you can also use the open_system command to open the host model:

open_system('mcb_pmsm_foc_host_model_dyno_f28379d.slx');

9. set the parameter port of the following blocks in the model to match the com port of the host computer. similarly you can perform the same configuration for other host models in this example:

  • mcb_pmsm_foc_host_model_dyno_f28379d > host serial setup

  • mcb_pmsm_foc_host_model_dyno_f28379d > serial communication > host serial receive

  • mcb_pmsm_foc_host_model_dyno_f28379d > serial communication > sci_tx > host serial transmit

10. click run on the simulation tab to run the host model.

11. change the position of the motor 1 switch to start, to run the motor.

12. update the motor 1 - reference speed (rpm) and motor 2 - iq ref (a) in the host model.

13. select the debug signals that you want to monitor, to observe them in the time scope block of host model.

other things to try

you can also use soc blockset™ to develop a real-time motor control application for a dual motor setup that utilizes multiple processor cores to obtain design modularity, improved controller performance, and other design goals. for details, see .

网站地图