field-凯发k8网页登录
this example implements the field-oriented control (foc) technique to control the speed of a three-phase permanent magnet synchronous motor (pmsm). the foc algorithm requires rotor position feedback, which is obtained by a quadrature encoder sensor. for details about foc, see (motor control blockset).
a closed-loop foc algorithm is used to regulate the speed and torque of a three-phase pmsm. this example uses c28x peripheral blocks from the c2000™ microcontroller blockset and mcb library blocks from motor control blockset™.
this example uses the quadrature encoder sensor to measure the rotor position. the quadrature encoder sensor consists of a disk with two tracks or channels that are coded 90 electrical degrees out of phase. this creates two pulses (a and b) that have a phase difference of 90 degrees and an index pulse (i). therefore, the controller uses the phase relationship between a and b channels and the transition of channel states to determine the direction of rotation of the motor.
required hardware
this example supports these hardware configurations. use the target model name (highlighted in bold) to open the model for the corresponding hardware configuration, from the matlab® command prompt.
f28035 control card drv8312-c2-kit inverter:
f28335 control card drv8312-c2-kit inverter:
launchxl-f280049c controller boostxl-drv8305 inverter:
three-phase pmsm with optional qep sensors attached to connector j4 of the drv8312-c2-kit inverter board or connector j12 of launchxl-f280049c.
for f28069m control card, launchxl-f28069m controller and launchxl-f28379d controller, refer to (motor control blockset).
for connections related to the preceding hardware configuration, see .
available models
the example includes these models:
note: for f28069m control card, launchxl-f28069m controller and launchxl-f28379d controller, refer to (motor control blockset).
you can use these models for both simulation and code generation. you can also use the open_system command to open the simulink® models. for example, use this command for a f28035 based controller.
open_system('mcb_pmsm_foc_qep_f28035.slx');
you may need to change the model parameters to fit your specific motor. match motor voltage and power characteristics to the controller. a conventional voltage-source inverter drives motor. the controller algorithm generates six pulse width modulation (pwm) signals using a vector pwm technique for six power switching devices. the inverter measures the current of the two motor inputs (ia and ib) input currents of the motor (ia and ib) using two analog-to-digital converters (adcs) and sends the measurements to the processor.
peripheral block configurations
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
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 .
configure the model
1. open the model. this model is configured for ti piccolo f2803x hardware.
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 model. you can use the same parameter values if you want to run this example for other hardware boards.
note:
sampling rate of the adc block should be same as the base rate of the model determined by the pwm period of the epwm block.
base rate trigger selection should be same as the interrupt triggered by the adc module. for more information, see model configuration parameters for texas instruments c2000 processors.
ensure that the default parameter behavior (configuration parameters > code generation > optimization) is set to inlined.
4. ensure that the baud rate is set to 1.5e6 bits/sec.
required mathworks® products
to simulate model:
for the models: mcb_pmsm_foc_qep_f28035, mcb_pmsm_foc_qep_f28335 and mcb_pmsm_foc_qep_f280049c
motor control blockset™
fixed-point designer™
to generate code and deploy model:
for the models: mcb_pmsm_foc_qep_f28035, mcb_pmsm_foc_qep_f28335 and mcb_pmsm_foc_qep_f280049c
motor control blockset™
embedded coder®
c2000™ microcontroller blockset
fixed-point designer™
prerequisites
if you obtain the motor parameters from the datasheet or other sources, update the motor parameters and inverter parameters in the model initialization script associated with the simulink® models. for instructions, see estimate control gains and use utility functions (motor control blockset).
simulate model
this example supports simulation. follow these steps to simulate the model.
1. open a 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.
generate code and deploy model to target hardware
this section instructs you to generate code and run the foc algorithm on the target hardware.
this 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.
note: for f28335 processor you need to use external ftdi for serial communication.
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 .
5. open the target model for the hardware configuration that you want to use. if you want to change the default hardware configuration settings for the model, see (motor control blockset).
6. click build, deploy & start on the hardware tab to deploy the target model to the hardware.
7. 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 a host model.
open_system('mcb_pmsm_foc_host_model.slx');
for details about the serial communication between the host and target models, see (motor control blockset).
8. set the parameter port of the following blocks in the model to match the com port of the host computer:
mcb_pmsm_foc_host_model > host serial setup
mcb_pmsm_foc_host_model > serial communication > host serial receive
mcb_pmsm_foc_host_model > serial communication > sci_tx > host serial transmit
9. update the reference speed value in the host model.
10. click run on the simulation tab to run the host model.
11. change the position of the motor switch to start, to start running the motor.
12. observe the debug signals from serial communication, in the time scope of host model.
more about:
(motor control blockset)
estimate pmsm parameters using recommended hardware (motor control blockset)
for f28069m control card, launchxl-f28069m controller and launchxl-f28379d controller, refer to (motor control blockset)