Adsread / adswrite, Example: sdo read via ads – BECKHOFF FC5101 User Manual

Page 56

Advertising
background image

Eiserstraße 5 / D-33415 Verl / Telefon 05246/963-0 / Telefax 05246/963-149

56

ADSREAD / ADSWRITE

Parameters

Description

NETID

The NetID is a string, 23 bytes in length, and is formed by default from the IP address of
the computer with an additional two bytes. It addresses the FC5101 card and can be found
under "ADS" in the System Manager.

PORT

Contains the ADS device's port number - this is the port number of the CANopen bus
device that is to be addressed.

IDXGRP

Corresponds to the 16 bit index in the CANopen object directory.

IDXOFFS

Corresponds to the 8 bit sub-index in the CANopen object directory.

LEN

The length of the parameter that is to be read or written, in bytes.

DESTADDR
(only ADS-
READ)

Contains the address of the buffer which is to receive the data that has been read. The
programmer is himself responsible for dimensioning the buffer to a size that can accept
‘LEN’ bytes. The buffer can be a single variable, an array or a structure, whose address
can be found with the ADR operator.

SRCADDR (only
ADSWRITE)

Contains the address of the buffer from which the data to be written is to be fetched. The
programmer is himself responsible for dimensioning the buffer to such a size that ‘LEN’
bytes can be taken from it. The buffer can be a single variable, an array or a structure,
whose address can be found with the ADR operator.

READ

The ADS command is triggered by a rising edge at this input.

TIMEOUT

States the time before the function is cancelled.

BUSY

This output remains TRUE until the block has executed a command, but at the longest for
the duration supplied to the ‘Timeout’ input. While Busy = TRUE, no new command will be
accepted at the inputs. Please note that it is not the execution of the service but its accep-
tance whose time is monitored.

ERR

This output is switched to TRUE if an error occurs during the execution of the command.

ERRID

Contains the command-specific error code of the most recently executed command. Is
reset to 0 by the execution of an instruction at the inputs.

The ERRID contains the general ADS ERROR CODES in the low word and the SDO-specific error codes in the
high word:

Bits 0...3 contain the SDO error class

Bits 4..7 contain the SDO error code

Bits 8...14 contain the additional code for the SDO abort

Bit 15 is always 1

Example: SDO Read via ADS

In the following example program (structured text) for the use of ADS services for SDO communication, object
0x1000, sub-index 0, from the node with port number 0x1001 is read. The DeviceType is CANopen. This is
coded as UnSigned32, and is therefore 4 bytes long.

SDO_READ(
StartReading := ReadStart,
CO_Index := 16#1000,
CO_SubIndex := 16#0,
DataLength := 4,
PortNr := 16#1001,
ADSNetID:='192.168.10.11.2.1'
);

Advertising
This manual is related to the following products: