Serial block doesn't work with simulink coder

眉间皱痕 提交于 2019-12-02 10:25:26

问题


I receive some data signals from Serial Port using Serial Receive block (and Serial Configuration block of course). I use it to move a marker in a video. It works during simulation but when I generate .exe file using Simulink Coder marker doesn't move during execution. It would seem that it does not receive data from serial.

*EDIT:*The original data is an int16 but the "source" is built on Arduino Mega2560 using Target Support Package and so using an Arduino serial send block it generates the source on USB COM port with a baud rate of 9600. Because Arduino serial block wants only uint8 I used a byte pack block before Arduino Serial block. The parameters of byte pack block are: 1)Input port data types = {'int16'} 2)Byte Alignment = 2 In model that receives I use Serial Receive block from instrument control toolbox with: (Serial Configuration Block:)

Baud Rate = 9600;
Data Bits = 8;
Stop Bits = 1;
Byte Order  = LittleEndian;
Flow Control = none;
Time Out = 10;
Header = none;
Terminator = none;
Data size = [2 1];
Data Type = uint8;
Enable blocking mode = flag;
Action when data is unavailable = output last received value;
Block sample time = (same sample time setted in the model built on Arduino)
I have connected this Serial Receive Block to a Byte Unpack block with:
Output dimensions = {[1]};
Output Port Data types = {'int16'} (data type of original signal)

Suggestions?

来源:https://stackoverflow.com/questions/21883900/serial-block-doesnt-work-with-simulink-coder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!