Hi,
I need to add some code to an existing program to provide error messages for all sensor faults. The address range of the sensors are M140.0 -> M159.7. The current method utilises pointers to load the address i.e LAR1 P#M140.0 into a Diagnostic block where it is broke down in to a number which decides which Textlist entry is displayed on the HMI.
Before this i want add my timeout block to generate an Error message if the sensor is active for more than a pre-determined time.
In the simulator the code below seems to work ok, However in actual operation the timer(#fault_Timer) doesn't timeout?
Could anybody give me some "Pointers"(no pun intended!!)
Thanks again
STL
I need to add some code to an existing program to provide error messages for all sensor faults. The address range of the sensors are M140.0 -> M159.7. The current method utilises pointers to load the address i.e LAR1 P#M140.0 into a Diagnostic block where it is broke down in to a number which decides which Textlist entry is displayed on the HMI.
Before this i want add my timeout block to generate an Error message if the sensor is active for more than a pre-determined time.
In the simulator the code below seems to work ok, However in actual operation the timer(#fault_Timer) doesn't timeout?
Could anybody give me some "Pointers"(no pun intended!!)
FUNCTION "Sensor Timeout" : VOID
TITLE =
VERSION : 0.1
VAR_INPUT
State : BOOL ; //Test for 1 ~ State=True / Test for 0 ~ State=False
Fault_Timer : TIMER ;
Fault_time : S5TIME ;
Reset : BOOL ;
DB_No : BLOCK_DB ;
Offset : DWORD ; //Value to Minus From Address Register
Station_in_front : BOOL ;
END_VAR
VAR_OUTPUT
Alarm_State : BYTE ; //1 = On 2 = Off ~ 0 no processing
END_VAR
VAR_TEMP
SaveAR1 : DWORD ;
Address : DWORD ;
Byte_Value : WORD ;
END_VAR
BEGIN
NETWORK
TITLE =Reset
A #Reset;
R #Fault_Timer;
NETWORK
TITLE =Run conditions
AN #Station_in_front;
BEC ;
NETWORK
TITLE =Zero Alarm status list
L 0;
T #Alarm_State;
NETWORK
TITLE =Save the contents of AR1 for later processing
TAR1 ;
T #SaveAR1;
T #Address; //Load from AR1
NETWORK
TITLE =Check Address range
L DW#16#FFFF; //Byte filter
AD ;
SRW 3;
T #Byte_Value;
L 140; //Min Address
>=I ;
A( ;
TAK ;
L 159; //Max Address
<=I ;
) ;
JC OK; // Address range OK
JU END; // If out of range ~ Restore AR1 + End Block
NETWORK
TITLE =Sensor should be off
OK: A #State;
JC NW5;
AN M [AR1,P#0.0];
L #Fault_time;
SD #Fault_Timer;
A #Fault_Timer;
JC NW6;
JU END;
NETWORK
TITLE =sensor should be on
NW5: A M [AR1,P#0.0];
L #Fault_time;
SD #Fault_Timer;
A #Fault_Timer;
JC NW6;
JU END;
NETWORK
TITLE =Send Error Message state ON/OFF
//
//
//
NW6: AN #State;
JC OFF;
L 1;
JU WRT;
OFF: L 2;
WRT: T #Alarm_State;
NETWORK
TITLE =Send Sensor Number Message
//Message 1 = 40.0 for m140.0
//
L #Address;
L DW#16#FFFF; // mask off all except Byte/Bit area
AD ; // Apply 32 bit Mask
T #Address;
L #Offset; // Minus Offset to Point to first message address
SLD 3; // Move to Byte Area of the Pointer
-D ; // Subtract from Original Value
LAR1 ;
OPN #DB_No;
A #Fault_Timer;
= DBX [AR1,P#0.0]; // Write Message
NETWORK
TITLE =Block End restore address register 1
END: L #SaveAR1;
LAR1 ;
END_FUNCTION
Thanks again
STL