2 boot-up of the network without automatic start – Lenze PLC Designer PLC Designer (R2-x) CANopen for Runtime Systems User Manual

Page 25

Advertising
background image

L-force | PLC Designer - CANopen for Runtime Systems

CANopen-Master library

24

DMS 2.0 EN 05/2009 TD29

2.4.4.2 Boot-up of the network without automatic start
Sometimes it is required that the application determines the time at which the CANopen-Slaves should
be started. For this purpose option „Automatic startup“ of the CAN master must be activated in the
configuration. Then the application is responsible for starting the slaves.

The normal way to start a slave via a library is to call the method NodeStart of the respective slave.
This method call after the configuration effects that slaves, for which nodeguarding resp. heartbeat is
activated, will be started depending on their current status, which is contained in their
nodeguard/heartbeat message. If the current status of a slave is not yet „OPERATIONAL“, a „Start
Node“-NMT-command will be sent to the slave.

If the method is used to start a slave which does not use nodeguarding, the slave always will get sent
the complete SDO-set and afterwards a „StartNode“-command will be sent, if the startup was
o.k.(means the device type matched the one in the configuration). In order to start such a slave after
the automatic configuration phase (after which it needs no more configuration SDOs because it just
has received those), it is easier to self-generate a „Start Node“-NMT-command. For this purpose a call
of the CanOpenWriteMSG function block instance can be used (This instance always is available
globally in the manager library.)

CanOpenWriteMSG( wDrvNr := pCanOpenNode[xx].wDrvNr, dwCanID := 0,

ucLen := 2, bRtrFrame := FALSE,
ucByte1 := 16#01, ucByte2 := pCanOpenNode[xx].ucNodeNr);

Thus always one StartNode-NMT-command is put on the bus. The parameters of the module thereby
are read from the array containing the descriptions of the slaves.

IN order to start the complete network, the NMT message also – as described above – can be self-
generated: (This procedure always must be utilized for nodes which are working without
nodeguarding/heartbeat.)

CanOpenWriteMSG( wDrvNr := pCanOpenMaster[xx].wDrvNr, dwCanID := 0,

ucLen := 2, bRtrFrame := FALSE,
ucByte1 := 16#01, ucByte2 := 0);

This NMT command is named „Start All Nodes“.

Thereby however all node states must be adapted, in order to achieve that the library even sets on the
current state if the master has not started the nodes. So it is better to use the method StartAllNodes of
the master. Then the NMT command “Start All Nodes” will be created and the nodes states will be
updated.

In order to start a slave, which was brought to status 98 during boot-up (device type does not match
with the configured type), it is sufficient to use method SetNodeStatus(nNewStatus := 4). If the master
has been configured to start automatically, the node now will be started. Otherwise the application
must additionally call method NodeStart of the node:

pCanOpenNode[iNodeXX].NodeStart();

If the device type of the node did not fit the one in the configuration, the node has to be started (if
desired) by using the explicit generation of a NMT message, see above. The use of NodeStart will
only lead to a sending of the whole set of configuration SDOs with no Start Node command at the end.

For an optional slave which was not present at the start-up of the master and which therefore currently
is in status 97, the same procedure can be utilized. But also alternatively method NodeReset can be
called. This method always causes that the slave is re-configured and then started. (Indeed it will only
be started if the autostart-option is activated. Otherwise the node nevertheless must be started
manually.)

Advertising