Beispiel: sdo write per ads – BECKHOFF FC5101 Benutzerhandbuch

Seite 58

Advertising
background image

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

58

TMOUT := T#1s
);
END_IF
1:
ADSRead(READ:= FALSE);
IF ADSRead.err THEN
state := 2;
ReadDataAvailable := TRUE;
Error := ADSRead.ErrId;
ELSE
IF NOT ADSRead.busy THEN
state := 2;
ReadDataAvailable := TRUE;
END_IF
END_IF
2:
ADSRead(READ:= FALSE);
state := 0;
END_CASE

Beispiel: SDO Write per ADS

Im folgenden Beispielprogramm (Strukturierter Text) für die Verwendung der ADS Dienste für die SDO Kom-
munikation wird Objekt 0x6200, Subindex3 aus dem Knoten mit der Portnummer 0x1001 beschrieben. Es han-
delt sich um digitale Ausgänge auf einem E/A Knoten.

(* Data to be written *)
WriteData[0] := 16#55;

(* write Object *)
SDO_WRITE(
StartWriting := WriteStart,
CO_Index := 16#6200,
CO_SubIndex := 3,
DataLength := 1,
PortNr := 16#1001,
WriteData := WriteData,
ADSNetID:='192.168.10.11.2.1'
);
IF SDO_WRITE.WriteDataFinished THEN

WriteStart := FALSE;
WriteError := SDO_WRITE.Error;
END_IF

Der aufgerufene Funktionsbaustein SDO_WRITE ruft seinerseits mehrfach die ADSWRITE Funktion auf. Er
sieht wie folgt aus (zunächst die Variablendeklaration):

FUNCTION_BLOCK SDO_WRITE
VAR_INPUT
ADSNetID:STRING(23); (* The AMSNetID addresses the FC5101 card. Can be empty
if only one local single channel card is present*)
PortNr:WORD; (* The Port No. addresses the CANopen Node (see System
Manager) *)
CO_Index:DWORD; (* This is the Index of the CANopen Object Dictionary
Entry*)
CO_SubIndex:DWORD; (* This is the Sub-Index of the CANopen Object Dictionary
Entry*)
DataLength:DWORD; (* This is the Length of the CANopen Object Dictionary
Entry*)
StartWriting:BOOL; (* only reset to FALSE after WriteDataFinished=TRUE*)
WriteData:ARRAY[0..255] OF BYTE; (*This array contains the data to be written to
the CANopen Object Dictionary*)
END_VAR
VAR_OUTPUT
WriteDataFinished:BOOL;
Error:DWORD;
END_VAR
VAR

Advertising
Dieses Handbuch ist für die folgenden Produkte bezogen werden: