| Contents | Index |
xPC Target Library for CAN
The Receive driver block retrieves data from a CAN network to be used within a block model. You can use as many instances of the Receive block in the model as required.
To use CAN_MESSAGE data types to transmit messages, use the CAN Unpack block to unpack individual signals from the received CAN messages.
Note
|

Defines the board from which the CAN messages defined by this block instance are to be retrieved. For more information about the meaning of the board number, see the Setup driver block. If just one board is present in the target system, select board number 1.
Selects the CAN port from which to retrieve the CAN message.
Selects the identifier range of the CAN messages retrieved by this block instance. If an application makes use of mixed standard and extended identifier ranges, at least two instances of this block must be used, each defining the corresponding identifier range.
If the CAN message data type is a CAN_MESSAGE data type, this range must match the Identifier type parameter of the connected CAN Unpack block.
Specifies the identifiers of the CAN messages retrieved by this block. It must be a row vector where the elements define a set of either standard or extended identifiers. Each element must be in the range between 0 and 2047 for standard identifiers, or 0 and 229 - 1 for extended identifiers. The number of identifiers for each CAN port in a model per physical CAN board cannot exceed 200. The number of elements defined here defines the number of output ports of the block. The block icon displays the selected identifier at each output port.
If the CAN message data type is CAN_MESSAGE, connect each output port to one CAN Unpack block. Verify that the Identifier parameter for each CAN Unpack block matches the receive block output port.
If the CAN message data type is not CAN_MESSAGE data type, each output port outputs the data frame being retrieved along with the CAN message. The signal leaving each output port is a scalar of type double representing the maximum size of 8 bytes of a CAN message data frame.
From the list, select:
Output vector of one double with just data.
Output vector of two doubles. First element of the vector contains the data, the second element contains the status.
Output vector of two doubles. First element of the vector contains the data, the second element contains the timestamp.
Output vector of three doubles. First element of the vector contains the data, the second element contains the status, the third element contains the timestamp.
One CAN_MESSAGE. You can extract the data, status, and timestamp from this message using a CAN Unpack block.
Refer to the Softing manual for more information. The function return codes are:
| Code | Description |
|---|---|
0 | No new data received. |
1 | Data frame received. |
2 | Remote frame received. |
-1 | Receive data frame overrun. |
-2 | Receive remote frame overrun. |
-3 | Object not active. |
-7 | Timeout firmware communication |
-99 | Board not initialized. |
Defines whether the CAN messages defined in this instance of the block initiate an interrupt from the CAN board each time they are received. If selected, you can use CAN messages to control model (target application) execution.
Defines the sample time at which the Send block is executed during a model (target application) run.
You can use as many instances of the Receive block in the model as required. For example, by using two instances of the block, you can check for different sample times at which CAN messages are retrieved. Or you can use multiple instances to structure your model more efficiently. You can define up to 200 receive objects for standard and extended identifiers for each CAN channel.

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |