- Binary format: data is packed into bytes, in a format specified by the device. You cannot interpret the data just by looking at the stream of bytes and must have knowledge about the format to encode/decode it properly.
- ASCII format: device sends strings back and forth, which are usually user-readable.
Packing and Unpacking Messages
5 ビュー (過去 30 日間)
The CAN Pack/Unpack blocks provide a mechanism to specify the structure of a message using the signals table containining the field name, start bit, length etc for each value sent.
Are there similar blocks that provide the same mechanism for specifiying the message format but that aren't specifically for sending CAN messages?
I have a model to update which currently does all of the bit packing/shifting/concatenation in a very manual and time consuming way.
回答 (1 件)
Dimitri MANKOV 2022 年 7 月 20 日
There are different formats used by serial devices to send and receive data. The Simulink model thus must be able to produce (send) and understand (receive) data in the required format. Simulink is designed to handle numerical data, while the actual serial data may be strings or bytes of data in a particular format. This means that some encoding/decoding using blocks included with Simulink Real-Time is necessary. Configuration of the lower-level serial protocol may also be needed, depending on the external device requirements.
Typically, serial devices communicate using either:
There are several Simulink Real-Time examples showing how this encoding can be done here. In addition, Speedgoat recently released a series of product examples with their latest I/O Blockset version (v9.4.1), including an example showing a typical RS485 configuration. You can check them out here.
I hope this is helpful!