- Set all of the command sizes to the max command size and pad the shorter commands with some sort of null character that the hardware will ignore, this solution depends on the hardware.
- Avoid the Simulink Serial blocks and instead open a serial object through Stateflow with the MATLAB functions, and then write the data as necessary using "fwrite" (This method requires additional MATLAB programming skills, and is prone to error if "fclose" is not correctly called).
- Alternatively, you can use the Simulink Serial blocks. You can encapsulate the Serial Send block in a Function Call block with one input. Then, in the Stateflow chart, create two parallel states: one for the controller, and one for a serial interface. The controller adds data into a buffer, and the serial interface reads the buffer and sends data out one at a time along with an output event to activate the Serial Send block.
variable size signal of Serial Send block in Simulink
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi, I'm working on simulink for sending motor signal to servo motors through Serial Send block. I need to send some kinds of commands and the lengths differs in each states, but Serial Send block doesn't support variable size signal. How can I send different size commenads through serial communication?
Thank you.
댓글 수: 0
채택된 답변
Kiran Felix Robert
2020년 11월 4일
Hi Koki,
It is my understanding that you are trying to send Variable size data signals over the serial send block, Unfortunately, the Serial Send block does not currently support inputs with variable size . The input data size is set upon compilation time, and will not change during execution. Though there are a few few workarounds, you can follow either of the following.
Kiran Felix Robert
댓글 수: 0
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!