Main Content

主机目标通信

Motor Control Blockset™ uses a communication interface between the host model and the target model to control the motor and observe feedback.

Host Model

The host model is a user interface for the controller hardware board. Run the host model on the host computer. Before you run the host model on the host computer, make sure to deploy the target model on the controller hardware board.

主机模式命令,控制,和交流ata with the target hardware. You can perform these operations using the host model available in the Motor Control Blockset:

  • Find the serial communication port (COM port) in the host system. For more details, see Find Communication Port section in this page.

  • 使用串行设置块配置串行端口和波特速率。

  • Start or stop the motor.

  • Specify the motor speed.

  • 通过使用时间范围和显示块,查看主机从目标接收的调试或输出信号。

目标模型

目标模型在控制器硬件板上运行。将目标模型部署到控制电动机的嵌入式目标硬件。目标模型与主机模型通信以从用户接收命令(例如,启动或停止电动机的命令)。电动机控制区块中可用的目标模型执行的一些常见操作:

  • Serial communication with the host model to receive user commands and exchange binary data.

  • Read data from the position and current sensors attached to the motor and inverter.

  • 通过运行控制算法并处理反馈来控制电动机速度和扭矩。

  • Generate duty cycle inputs for the inverter.

  • Enable fast serial data monitoring for debugging the signals.

Serial Communication Blocks

主机和目标模型通过使用这些电动机控制模块块相互作用,该模块可以启用串行通信:

  • Host Serial Receive

  • Host Serial Setup

  • Host Serial Transmit

Using these blocks you can monitor, control, and customize the motor operation in real time. For example, you can view the debug signals, stop or start the motor, and change the motor speed without repeated deployment of the target model.

Fast Serial Data Monitoring

The Motor Control Blockset example models use the fast serial data monitoring algorithm, which performs control and diagnostic operations through the host model. This algorithm enables you to observe data from the target device at the same rate as the execution sample time (for example, PWM frequency of 20kHz). This, in turn, helps in diagnostics and analysis of transients.

评估委员会通常会在USB连接上提供串行通信,以实现快速的串行传输。在Texas Instruments™Launchpad硬件板上运行的模型发送信号IaIbcurrents over the serial interface.

For example, consider a situation where a model needs to sample two signals A and B every 50 µs and send them to the host model for monitoring and debugging. To fulfil this requirement, the Motor Control Blockset examples divide the entire signal data into packets of 600 data points. Therefore, a packet from signal A combined with a signal B packet results in 1200 data points. Using this approach, the target hardware sequentially sends a pair of data packets (from signals A and B) to the host model. The target further groups these packet pairs into sections. Each section begins with a header and ends with a terminator. Following a header, the host model starts buffering the data points until it receives a terminator, after which Simulink®reads the buffered data that you can monitor.

要读取缓冲数据,我们选择Enable blocking mode和setData sizeto[2 n]Sample timeton*50µs in theHost Serial Receiveblock parameter dialog box. Using this configuration, theHost Serial Receive块读取2×n数据点每个n×50µs。我们选择一个值nsuch that the Simulink host model can run efficiently in real time.

Motor Control Blockset examples follow this approach because Simulink shows high efficiency when processing big packets of data at low data speeds and the target hardware (used by Motor Control Blockset) efficiently processes smaller data packets at higher data speeds.

Use the host model to receive these signals on your host computer. The Motor Control Blockset examples implementing Field Oriented Control (FOC) algorithm for the F28379D LaunchPad usemcb_pmsm_foc_host_model_f28379d.slx. Examples that implement the FOC algorithm for the F28069M targets, usemcb_pmsm_foc_host_model_f28069m.slx. The Motor Control Blockset also provides other host models for the application-based examples.

Selecting COM port and baud rate

Select the appropriate COM port that matches your board in the Host Serial Setup, Host Serial Receive, and Host Serial Transmit blocks of the host model. Adjust the baud rate for your board:

Texas Instruments LaunchPad Baud Rate

F28027 LaunchPad

3.75e6

F28069发射台

5.625e6

F28377S Launchpad

12e6

F28379D LaunchPad

12e6

After you deploy the target model on the target device, run the host model and observe the debug signals update at 20 kHz, on the time scope. You can use the same technique to monitor other signals on other processors.

Note

SCI_A通常连接到FTDI芯片,该芯片允许在启动板板,对接站和ISO控制卡上对USB进行串行传输。

Find Communication Port

Use these steps to find the serial communication port in the Device Manager of Windows®PC, after you connect the target hardware to your system:

  1. OpenDevice Manageron your Windows PC.

  2. Look for an entry under港口(com&lpt)titledUSB Serial Port (COMX),其中x是一个数字。You can note down this number to configure the serial setup block in the host model.

If you face difficulty in finding the COM port, follow these steps to determine the COM port:

  1. OpenDevice Manageron your Windows PC.

  2. Look for an entry under港口(com&lpt)titledUSB Serial Port (COMX),其中x是一个数字。如果有多个COM端口,则可以断开并重新连接C2000板并观察设备管理器中的更新以确定COM端口。

  3. Alternatively, follow these steps to determine the correct port name for the connected target hardware:

    1. Right-click a communication port and clickProperties.

    2. In theDetailstab, selectHardware Idsproperty.

    3. If the port indicates the following IDs, the communication port belongs to the connected TI’s C2000™ controller hardware board:

      • VID: 0403

      • PID: A6D0

  4. If you do not see or find the right port in港口(com&lpt), 导航Texas Instruments Debug Probes并遵循以下步骤:

    1. Right-clickXDS100 Class Auxiliary Port Properties和selectProperties. Navigate toAdvancedtab and selectLoad VCP.

    2. Right-clickXDS100 Class Debug Port Properties和selectProperties. Navigate toAdvancedtab and clearLoad VCP.

    3. Disconnect and reconnect the USB cable to the system and observe the updates in Device Manager to determine the COM port. The system now displays the COM port that belongs to the connected TI’s C2000 controller hardware board.

    Tip

    VCP stands for Virtual COM Port (for devices that support serial over USB communication).

  5. IfTexas Instruments Debug Probes不要出现在设备管理器中,扩展Universal Serial Bus controllersin the Device Manager and follow these steps:

    1. Right-clickTI XDS 100 Channel B和selectProperties. Navigate toAdvancedtab and selectLoad VCP.

    2. Right-clickTI XDS 100 Channel A和selectProperties. Navigate toAdvancedtab and clearLoad VCP.

    3. Disconnect and reconnect the USB cable to the system and observe the updates in Device Manager to determine the COM port. The system now displays the COM port that belongs to the connected TI’s C2000 controller hardware board.

  6. If Device Manager does not detect the target hardware, follow these steps:

    1. Check that the target hardware is connected to the system.

    2. Check if the device drivers are installed correctly. Generally, device drivers are installed with the Code Composer Studio™(CCS). Check if the CCS software is installed on your system. Alternatively, try re-installing the device drivers suggested by Texas Instruments.

    3. Check if the serial connection cable is intact.

    4. If the problem persists, try connecting the hardware to another system and check if Device Manager detects the hardware.

    5. If you still face the problem, the target hardware may be faulty.

Add Debug Signals from Target Hardware

The host models included in the Motor Control Blockset examples provide a list of signals in theDebug signalssection. You can select these signals and monitor them using the time scope available on the host model for debugging purposes.

您只能一次向本节添加一对调试信号。另外,您可以修改列表中的现有项目(例如,Speed_ref & Speed_feedback) to show the signals that you want. However, this procedure explains how to add a new pair of debug signals to theDebug signalssection.

  1. Double-click the Debug signals radio button to open the block parameters dialog box. Add a new state value (for example,6-Id_ref_PU & Iq_ref_PU) to the existing list.

  2. Open the block parameters dialog box of theDebug_signals固定块中可用TXsubsystem of the host model. Set the constant to the new state value that you added in step 1 (for example, change the value5to6).

  3. Open the target model associated with the host model and open theCurrent Control/Debug_signalssubsystem.

  4. Add two more inputs to the mux block highlighted in the following figure:

  5. Open the block parameters dialog box of theSelectorblock and set theInput port sizeparameter value to the number of inputs now available in the mux (for example, change the value from9to11).

  6. Connect the new signals (for example,Id_ref_PUIq_ref_PU) to the new mux ports that you added in step 4.

  7. Open the block parameter dialog box of theMultiport Switchblock and set the数据端口数parameter to the number of debug signal pairs now available in the host model (for example, change the value from5to6).

  8. 添加一个具有向量值的常数块,该矢量值指示MUX上的新信号位置(例如,使用矢量[10, 11]for the mux inputs that you added in step 4). Connect this constant block to the newly added port on theMultiport Switchblock.