Macro functions for CANopen
Valid for S300, S700
Table of Contents
All macro functions which can be used with the CAN bus in a multi axis system are called via the function
FUNCTIONa(Can-function, output parameters, input parameters).
Depending on the number of input and output parameters a different function has to be called.
All described functions are called via a macro function
FUNCTIONa(Can_Function, Output Parameter, Input Paramater)
Depending on the number of input and output parameters a different function has to be called.
Examples
FUNCTION(PLCSENDSYNC);
- Function PLCSENDSYNC doesn't need parameters
FUNCTION4(PLCREADSDO,RET,VAL0,VAL1,COBID);
- Function PLCREADSDO has one input parameter (COBID) and 3 output parameters (RET,VAL0, VAL1)
PLCSENDSYNC
This function starts the sending of a SYNC-telegram.
| Function parameter | Type | Range | Description |
| - | |||
| Function result | Type | Range | Description |
| - | |||
| Function call | |||
| FUNCTION(PLCSENDSYNC); | |||
PLCSENDNMT
Network management of the CAN-bus, when using the CANopen-profile. CANopen-nodes can be started or stopped.
| Function parameter | Type | Range | Description |
| addr | int | 0 - 127 | CAN-address of a configured CANopen-node, 0, if all CANopen-nodes shall be enabled together |
| cmd | int | 1,2,128 - 130 | NMT command 1 - NMT operational 2 - NMT stop 128 - NMT enter preoperational state 129 - NMT reset node 130 - NMT reset communication |
| Function result | Type | Range | Description |
| ret | int | 0 .. 2 | 0 – function parameters OK 1 – invalid node has been addressed 2 – undefined NMT command |
| Function call: | |||
| FUNCTION3(PLCSENDNMT, RET, ADDR, CMD); | |||
PLCCNFGSDO
Configures one of four possible SDO-receive-channels
| Function parameter | Type | Range | Description |
| addr | int | 1 .. 127 | Address of a CANopen node to which a service-channel shall be established |
| cmd | int | 0, 1 | Connection command 0 – destroy connection 1 – establish connection |
| Function result | Type | Range | Description |
| ret | int | 0 .. 5 | 0 – function parameters OK 1 – all four possible SDO channels are used 2 – the node address is already in use 3 – CAN address outside the valid range 4 – no more RAM available in the device 5 – wrong command |
| Function call: | |||
| FUNCTION3(PLCCNFGSDO, RET, ADDR, CMD); | |||
PLCWRITESDO
Send a ServiceDataObject to the CAN bus. This telegram is used to exchange parameters with single nodes and is an acknowledged service. The response to this telegram is written to a data buffer. This response can be read directly by val, if the timeout wasn't over, when the response came, i.e. with ret = 0, or later, if the timeout value was too short (ret = 2), via the function PLCREADSDO.
| Function parameter | Type | Range | Description |
| addr | int | 1 .. 127 | address of a CANopen-node, to which a SDO-request should bes sent to |
| rwflag | int | 0, 1 | Access type 0 – read value 1 – write value |
| index | int | 1000h .. 7FFFh | index of the CANopen object dictionary entry |
| subindex | int | 0 .. 255 | subindex of the CANopen object |
| val | int | int | value only used for writing |
| timeout | int | int | timeout for SDO response (in milliseconds) |
| Function result | Type | Range | Description |
| ret | int | 0 .. 3 |
0 – function parameters OK, SDO response is in val,either 0 with correct writing of a CAN object or the object value with reading of an object |
| Function call: | |||
| FUNCTION7(PLCWRITESDO, RET, ADDR, RWFLAG, INDEX, SUBINDEX, VAL, TIMEOUT); | |||
PLCREADSDO
Read the SDO-response to a request sent by using PLCWRITESDO, if the timeout there was set to 0 or a too small value.
| Function parameter | Type | Range | Description |
| val | int | int | if ret = 0 the value of the SDO response, if ret = 3 SDO abort code |
| addr | int | 1 .. 127 | address of the CANopen-node, which SDO-response shall be read. |
| Function result | Type | Range | Description |
| ret | int | 0 .. 2 | 0 – function parameters OK 1 – not configured CAN address was used 2 – no more data (had been read before) 3 – SDO abort telegram, sent SDO telegram had a negative acknowledge, abort code in val |
| Function call: | |||
| FUNCTION3(PLCREADSDO, RET, VAL, RET); | |||
PLCCNFGRXPDO
Configure one of eight possible PDO-receive-channels to CANopen-nodes.
| Function parameter | Type | Range | Description | |
| cobid | int | 0x181-0x1FF, 0x281-0x2FF, 0x381-0x3FF, 0x481-0x4FF |
COB-identifier of a CANopen-node, to which a process data channel shall be established | |
| cmd | int | 0, 1 | Connection command 0 – destroy connection 1 – establish connection |
|
| Function result | Type | Range | Description | |
| ret | int | 0 .. 4 |
0 – function parameters OK |
|
| Function call: | ||||
| FUNCTION3(PLCCNFGRXPDO, RET, COBID, CMD); | ||||
PLCWRITEPDO
Send ProcessDataObject to the CAN Bus.
| Function parameter | Type | Range | Description |
| cobid | int | 0x201-0x27f, 0x301-0x37f, 0x401-0x47f, 0x501-0x57f |
COB-identifier to a CANopen-node, which had been configured before |
| val0, val1 | 2 * int | int | CAN Data to be sent. Sequence on the CAN bus: val0 LSB .. val0 MSB, val1 LSB .. val1 MSB |
| bytes | int | 1..8 | Number of data bytes to be transferred |
| Function result | Type | Range | Description |
| ret | int | 0 .. 1 | 0 – function parameters OK 1 – wrong identifier |
| Function call: | |||
| FUNCTION5(PLCWRITEPDO, RET, COBID, VAL0, VAL1, BYTES); | |||
PLCREADPDO
Read a buffer of a configured ProcessDataObject that came via CAN Bus.
| Function parameter | Type | Range | Description |
| val0, val1 | 2 * int | int | Transferred CAN data. Sequence on the CAN bus: val0 LSB .. val0 MSB, val1 LSB .. val1 MSB |
| cobid | int | 0x181-0x1ff, 0x281-0x2ff, 0x381-0x3ff, 0x481-0x4ff |
COB-Identifier of the CANopen-node, to which the process data channel had been established |
| Function result | Type | Range | Description |
| ret | int | 0 .. 1 | 0 – function parameters OK 1 – no data in buffer |
| Function call: | |||
| FUNCTION4(PLCREADPDO,RET,VAL0,VAL1,COBID); | |||
Home >
Knowledge Base >
FAQs >
Downloads >