Digital I/O Bit-Unpacking

Extract data frames (not recommended)


Simulink® Real-Time™ Library of Drivers No Longer Recommended for Use


This block is used to extract data frames. Its input port is typically connected to an output port of a digital I/O block. The block has one input port of data type uint32 (a scalar), which represents the data frame entity from which the signals are extracted and leaving the block at its output ports. The number of output ports and the data type of each output port depend on the settings in the block's dialog box. See CAN Bit-Unpacking for an example of how to use a bit-unpacking block.

Block Parameters

Bit Patterns

Lets you define the bit patterns in a flexible way. The data type entered in the field must be a MATLAB® cell array vector. The number of elements in the cell array define the number of output ports shown by this block instance. The cell array elements must be of type double array and define the position of each bit of the incoming value (data typed output port) in the incoming uint32 value (data frame).

Sign extend

Select this check box to enable sign extension. If you select this check box and unpack the data frame into a signed type (int8, int16, or int32), the block performs sign extension. For example, if the bit pattern is [0:4], and the data type is int8, you are extracting 5 bits into an 8-bit wide signed type. In this case, bits 5, 6, and 7 are the same as bit 4, resulting in sign extension. This functionality enables you to pack and unpack negative numbers without losing precision. In the example from CAN Bit-Unpacking, you can pack and unpack numbers in the range [-16 : 15] (a fictitious int5 type).

Data Types

From a data type perspective (output ports), the block behaves like a Simulink Source block. Therefore, the data types of the output ports must be defined in this field. The data type entered must be a MATLAB cell array vector of the same length as the bit pattern cell array. The cell array elements must be of type char and define the data type of the corresponding output port. The following values are supported:

  • boolean

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

This block inherits the sample time of the driving blocks.

Was this topic helpful?