Specifications
Defining Initialization and Termination CAN Messages
4-53
Defining Initialization and Termination CAN Messages
The CAN Setup driver blocks for all supported CAN boards allow the definition
of CAN-messages to be sent out during initialization and termination of the
target application (once at the beginning of each application run and once
before an application run is stopped). The main purpose for sending out those
messages is to initialize or terminate other CAN nodes on the network. This is
for example the case for CANOpen or DeviceNet nodes. Even if xPC Target
doesn’t provide direct support of those CAN application layers, communication
with those nodes can usually be done over ‘standard’ CAN messages as long as
the nodes have been properly initialized. The initialization and termination
fields of the Setup blocks are intended for this purpose.
The initialization and termination CAN-messages are defined by using
MATLAB struct arrays with CAN specific field names. This is the same concept
as used for the RS-232, GPIB and general Counter driver blocks found in the
xPC Target I/O library. Refer to those driver blocks and their help for
additional information about this basic concept.
The CAN Setup block specific field names are the following.
Port — Selects the CAN port over which the message has to be sent out. Valid
values are either 1 or 2 (double).
Type — Defines if the message to be sent out is of type Standard or Extended.
Valid values are either ‘Standard’ or ‘Extended’ (strings).
Identifier — Defines the identifier of the message. The value (scalar) itself has
to be in the corresponding identifier range (Standard or Extended).
Data — Defines the data frame to be sent out along with the CAN message. The
value has to be a row vector of type double with a maximum length of 8. Each
element of the vector defines one byte, where the first element defines the data
for byte 0 and the eight’s element the data for byte 7. Each element can have a
value between 0 and 255 (decimal). The data frame size is defined by the length
of the row vector.
Pause — Defines the amount of time in seconds the Setup block waits after this
message has been sent out and before the next message defined in the struct
array is parsed and sent out as well. Valid values are in between 0 and 0.05
seconds. Some CAN nodes need some time to settle before they can accept the
next message, especially when the just received message puts the node in a
new operational mode. Use this field to define those necessary idle times.