Specifications
4 CAN I/O Support
4-54
Example
Let’s consider an A/D converter module with a CANOpen interface. After the
node has been powered up, the module is in pre-operational mode, which is
common for CANOpen nodes. At least two initialization messages have to be
sent to the node in order to get the module fully operational.
The first message puts the node from pre-operational into operational mode.
The second message programs the module in such a sense, that each time the
converted A/D value differs for more than 10 mVolts from the former
conversion, a CAN-message is automatically sent out, with the converted value
as the data frame.
After the target application has been started and the node is properly
initialized, the node will automatically send out CAN message, which the xPC
target application receives and then processes the contained frame data.
Before the target application execution is actually stopped, the module (node)
has to be brought back into pre-operational mode. This is achieved by sending
out one corresponding termination message.
The initialization and termination message struct for this example could look
as follows.
% put node into operational mode
init(1).port=1;
init(1).type=’Standard’;
init(1).identifier=1536+11;
init(1).data=[hex2dec(’22’),hex2dec(’23’),hex2dec(’64’),hex2d
ec(’00’),hex2dec(’01’)];
init(1).pause=0.02;
% program node to send CAN messages with converted A/D values
automatically
init(2).port=1;
init(2).type=’Standard’;
init(2).identifier=0;
init(2).data=[hex2dec(’01’),11];
init(2).pause=0;
% put node back into pre-operational mode
term(1).port=1;
term(1).type=’Standard’;