RS Logix structured text

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi I need some help with RSLOgix 5000 Structured text
I want sound an audible if there is alarm bit but not an acknowedged bit

I have an 2 arrays of 4 DINTS, HMI_ALARM and HMI_ALARM_ACK

RS Logix is complaining about the word/bit referencing such as HMI_ALARM[iWord].iBit


Audible := 0 ;

For iWord := 0 to 4 BY 1 Do

For iBit := 0 to 31 BY 1 Do
If HMI_ALARM[iWord].iBit = 1 AND HMI_ALARM_ACK[iWord].iBit = 0 then
Audible := 1 ;
END_IF ;
End_For ;
End_For ;
 
To perform indirect addressing in Structured Text, surround all indirect elements with square brackets. Otherwise they are interpreted as though they were named elements of a user-defined tag, not as indirect values.

By itself, HMI_ALARM[iWord].[iBit] can be TRUE or FALSE, but IEC1131 Structured Text doesn't let you compare it to an integer value of 0 or 1 with an "=" operator. You just have to state the BOOL tag by itself, or as the argument of a NOT operator.

Also, limit your DO loop to the values 0, 1, 2, 3 if your array is a DINT[4].

This code should work:

Code:
Audible := 0 ;

For iWord := 0 to 3 BY 1 Do
For iBit := 0 to 31 BY 1 Do

If HMI_ALARM[iWord].[iBit] AND NOT(HMI_ALARM_ACK[iWord].[iBit]) then 
Audible := 1 ;
END_IF ;

End_For ;
End_For ;
 
Last edited:
Thanks for the responses. I realised about the 4 after i posted. I need to read up more on Structured text

Peter your reply is a good alternative
 
I have read that Control Logix I/O runs asynchronously to the PLC scan. I wonder if it will make a difference that you are turning Audible off each time before the checks? If it turns back on it will probably happen so fast that you don't hear it but if Audible drives a relay output there may be issues?

All this is speculation as I have no direct experience with Control Logix and ST.
 
As usual Peter has his eyes more wide open than most !

As long as the Acknowledge bits are cleared after the Alarm bit is cleared, a simple set of Exclusive OR instructions will work and be much faster.

Code:
Audible :=  (
	(HMI_ALARM[0] XOR HMI_ALARM_ACK[0]) OR  
	(HMI_ALARM[1] XOR HMI_ALARM_ACK[1]) OR 
	(HMI_ALARM[2] XOR HMI_ALARM_ACK[2]) OR 
	(HMI_ALARM[3] XOR HMI_ALARM_ACK[3])
	 ) <>  0 ;
 

Similar Topics

Good evening. I display the step number of a SFC on a display. Sometimes, on a trip, it goes quickly through many steps and I need to prove to...
Replies
1
Views
100
I am trying to learn structured text on the controllogix platform and have managed to fault the processor by creating an infinite loop. My problem...
Replies
21
Views
3,639
Hello, I please need your help why I cannot get the return parameter from the RET instruction to go into the return parameter in the JSR return...
Replies
6
Views
2,787
I am troubleshooting an issue on a controller with logic, function block and structured text. I am lost on how to read the structured text as...
Replies
8
Views
2,625
Hey! I'm looking for a way to reset a tag when the routine that sets the tag is disabled. For example: Routine 1 has the following If Tag1...
Replies
6
Views
1,803
Back
Top Bottom