Herunterladen Inhalt Inhalt Diese Seite drucken

Beispiel In Strukturiertem Text - ABB GATE-P1 Originalbetriebsanleitung

Inhaltsverzeichnis

Werbung

Verfügbare Sprachen

Verfügbare Sprachen

5.4.3.5 Beispiel in strukturiertem Text

Das nachfolgende Beispiel in strukturiertem Text zeigt den Empfang der Fehlernummern von allen
Pluto Stationen am Bus. Die jeweilige Fehlernummer wird im lokalen Pluto Systemregister SR11
gespeichert.
PROGRAM MAIN
VAR
(*output data value*)
outPlutoId AT %Q*: UINT;
outPlutoAddress AT %Q*: UINT;
(*input data value*)
inPlutoId AT %I*: UINT;
inPlutoData_0 AT %I*: UINT;
inPlutoData_1
AT %I*: UINT;
(*state of the state machine*)
State: UINT := 0;
(*the requested PLUTO id number 0-31*)
pluto: UINT := 0;
(*counter for counting the number of different response message*)
respBad: UDINT := 0;
respTimeout: UDINT := 0;
respOK: UDINT := 0;
(*data storage for the respons value if a OK response*)
respLastValue_0: UINT := 0;
respLastValue_1: UINT := 0;
END_VAR
(*This state machine will retrive the Pluto error code stored in SR11 (address 11) from the PLUTO.*)
(*Note this program doesn't have any error handling which shall be added for production use.*)
CASE State OF
0:
(*This is the start state of the state machine.*)
(*This will set request data (pluto number, memory address and memory type.*)
(*Start the retrieval by setting the bit 15.*)
outPlutoId := pluto;
outPlutoAddress := 16#8000+11;
outPlutoId := outPlutoId + 16#8000;
State := 1;
1:
(*This is next step where the program waits for an respone on bit 15, bit set*)
IF inPlutoId >= 16#8000 THEN (*wait to get bit 15 set in the PLUTO id input response*)
outPlutoId := pluto;
State := 2;
END_IF
2:
(*This is next step where the program waits for a response on bit 15, bit cleared*)
IF inPlutoId < 16#8000 THEN
State := 3;
END_IF
3:
(*In this state the program will check the response bit 11, 10 and 9*)
(*Note need to test highest value first and the lower and lower value*)
IF inPlutoId >= 16#0800 THEN
respOK := respOK + 1;
respLastValue_0 := inPlutoData_0;
respLastValue_1 := inPlutoData_1;
State := 0;
ELSIF inPlutoId >= 16#0400 THEN
respTimeout := respTimeout +1;
State := 0;
ELSIF inPlutoId >= 16#0200 THEN
respBad := respBad + 1;
State := 0;
END_IF
(*Use this code if you want to loop more pluto units*)
(*Note that response value 0/1 shall be stored in an array or similar if used in a system*)
IF State = 0
THEN
pluto := pluto + 1;
IF pluto > 31 THEN
pluto := 0;
END_IF
END_IF
END_CASE
(*output data, Pluto Unit Id
(*output data, Local Data Address
(*input data, Response Pluto Unit Id [word 0]*)
(*input data, Local Data Value
(*input data, Local Data Value
(*set PLUTO id number*)
(*set value type and memory address*)
(*set the bit 15 of PLUTO data*)
(*goto next state*)
(*clear the bit 15 of PLUTO data*)
(*goto next state*)
(*wait to get bit 15 cleared in the PLUTO id input response*)
(*goto next state*)
(*check if response bit 11 is set => response OK*)
(*count number of OK response message*)
(*get response value 0*)
(*get response value 1*)
(*goto start state*)
(*check if response bit 10 is set => response timeout*)
(*count number of timeout response message*)
(*goto start state*)
(*check if response bit 9 is set => response bad*)
(*count number of bad response message*)
(*goto start state*)
(*move to next pluto if state set to 0*)
(*next pluto*)
(*if over high limit of pluto*)
(*set low pluto number*)
34
[word 0]*)
[word 1]*)
[word 1]*)
[word 2]*)
2TLC172009M0110_D

Werbung

Inhaltsverzeichnis
loading

Inhaltsverzeichnis