First Out Alarming

echos

Member
Join Date
Nov 2010
Location
Edmonton
Posts
49
Hi am a very new to PLC programming, and have been asked to test a program for first out alarming. I am waiting for a PLC to test the code but in the mean time I have received the code offline and am trying to figure it out. I have attached the file to this and have some questions on how instructions execute.

My initial question is if a PLC execution is from left to right, top to bottom when an alarm comes in
how will Rung 6 ever execute.


Note:1 to alarm (cannot see how this would work if 0 to alarm)

Rung 5: Say an alarm comes in, First_out_sd_in becomes a 1, first_out_sd_on is already 0,
so 0 or 1 =1 which makes first_out_sd_on a 1.
then this rung stops executing as input bit FO_SD_BIT is set to 1 (if rung 6 executes)

if the logic is execute left to right, top to bottom

Rung 6 first_out_sd_in & first_out_sd_on will always be equal when an alarm came in, because first_out_sd_in and
first_out_sd_on are both 1 from OR instruction on Rung 5 already???


I have some other questions but once I can understand how the PLC executes these intructions hopefully they will get
cleared up.
 
Last edited:
You are correct that the code is scanned left-to-right and top-to-bottom, but I think you overlook the fact that NOTHING is done by the PLC until the entire scan is finished (with the exception of certain instructions that are designated as "immediate"). Therefore, for the duration of ONE scan, rung 6 will be true and FO_SD_BIT will get latched in the 'set' condition. FO_SD_BIT will remain 'set' until something in the program (that you've not posted here) causes it to be 'reset'. (Note: Set refers to true or 1; Reset means false or 0)

The key is not to think that the intermediate bits or outputs are changing state as the program scan takes place. The PLC takes a "snapshot" of ALL the input conditions, then sets outputs accordingly. Remembering this will save you hours of tail-chasing time when trouble-shooting. Trust me.

Bill
 
Thanks Bill

It is not the bit that i am confused about it is the OR, and NEQ instructions, for example in Rung 5 say a 1 comes into SD_IN, it will OR it with SD_ON (0) and then put dest (the result 1) back into SD_ON.

Then when we come into Rung 6 we expect them not to be equal even thought the previous instruction made them equal?

sorry for my lack of plc
 
You are treating the variables (eg FIRST_OUT_SD_IN) as if they can only hold a 0 or 1 value. Actually any of the bits within the word may be set. As we don't have any other logic we can't be sure this would happen, but it can happen and probably does since full words are used.

Rung 5 - The contents of 'FIRST_OUT_SD_IN' are bitwise merged by using the OR with any bits which happen to already be on in 'FIRST_OUT_SD_ON'.

Rung 6 - Assuming there was some newly set bit in bit in 'FIRST_OUT_SD_IN' then this is detected by the NEQ. The one shot assures that further processing only happens once. 'FO_SD_BIT' is set as a signal for future processing to deal with this. The XOR preserves in 'FIRST_OUT_FO_SD' then previous bits which were set.

Rung 7 - The AND preserves in 'FIRST_OUT_SD_ON' a copy of the bits from 'FIRST_OUT_SD_IN'

In this small set of rungs we do not see any further processing for 'FIRST_OUT_FO_SD' or 'FIRST_OUT_SD_ON'. We also don't see the conditions which reset 'FO_SD_BIT'.

Your analysis must change from a 0/1 type to the full bitwise pattern.

If you wish to post more then we can help to a greater extent. Look through the code for instructions which affect individual bits of 'FIRST_OUT_SD_IN'. These may be latches and unlatches of individual bits or the movement of numeric values into this variable.
 
Thanks Bernie

I have uploaded more code. I know FIRST_OUT_SD_IN is an array, but i want to think of it as a single bit for now. For example say I replace FIRST_OUT_SD_IN with FIRST_OUT_SD_IN.0 and FIRST_OUT_SD_ON with FIRST_OUT_SD_ON.0 so to take it just for one case so that they can only hold a 0 or a 1 value.

My question is does the OR instruction execute before the NEQ, if this is the case then I cannot see how NEQ will ever be not equal as the OR instruction will make them equal.

Or does the OR and the NEQ instruction work at the exact same time which I think could see the instruction working
 
My question is: does the OR instruction execute before the NEQ,
Yes, and it is a Bitwise Inclusive OR instruction, so if the Source A is 1 bit different from the old Source B, then the Destination will NOT EQUAL Source A.
If this is the case, then I cannot see how NEQ will ever be not equal, as the OR instruction will make them equal.
No, the OR instruction will not make them equal. "OR" does not perform the same logical function as "MOV" or "SET". In the truth table below, notice that Destination is only equal to Source A for some cases (when Source A = Source B AND when Source B = 0).
 
OR Truth Table
Source A Source B Dest
0 0 0
0 1 1
1 0 1
1 1 1

 
Last edited:
As some instructions, like the NEQ, are analyzing the ENTIRE WORD it is invalid to analyze the logic for only one bit at a time. The NEQ takes into account previous states in FIRST_OUT_SD_ON. Without the entire code we cannot tell to what state previously treated bits are represented. The result of the NEQ is true if any of the states (particularly the 0 states) in FIRST_OUT_SD_IN are different than the now merged group of states.

Give up trying to analyze it one bit position at a time. It is meant as a whole word analysis. Check the response if bit zero is a 0 but some other bit is newly a 1. You are using too narrow of an understanding of the code. Sometimes the whole is greater than the sum of its parts.
 
Thanks Lancie1

Take my PLC example where I have Source A: X Source B: Y Dest: Y. Say Source A = 0, Source B = 0, and then Source A changed to a 1, from the truth table 1 (Source A) OR 0 (Source B) = 1 (Destination).

What I don't get is that my destination is the same as Source B, so will the result of the OR (which is 1) replace Source B with a 1 (since it is also the destination), and thus make them equal.

I would understand if my destination was a different tag, but how can the same tag have both 1 and 0
 
Are you preaching to me (the choir), Bernie? I merely used the truth table to illustrate that the Destination for the OR instruction is not necesarily equal to Source A. Period.
 
Last edited:
I know that Source A will always stay the same, but since Source B and Dest our the same address, does B get over written in OR instruction? If so it will make A and B equal.



"Take my PLC example where I have Source A: X Source B: Y Dest: Y. Say Source A = 0, Source B = 0, and then Source A changed to a 1, from the truth table 1 (Source A) OR 0 (Source B) = 1 (Destination).

What I don't get is that my destination is the same as Source B, so will the result of the OR (which is 1) replace Source B with a 1 (since it is also the destination), and thus make them equal.

I would understand if my destination was a different tag, but how can the same tag have both 1 and 0?"

I would understand if i had SourceA SourceB DestC. I would like to take it like I am just comparing bits (not words) as I find that easier to understand. However it is the OR instruction itself I am not getting.

Can someone please help me

I will be doing a PLC course in Jan, but need to understand this now

Thanks in advance
 
but since Source B and Dest our the same address, does B get over written in OR instruction? If so it will make A and B equal.
Yes, A is ORed with OLD B, then OLD B gets overwritten with the NEW B, but A is still unchanged by the OR operation, so A is not necessarily equal to NEW B.

Think of it as like a math equation that is evaluated each time (scan of the PLC). D = A + Old D. D gets changed each scan, but A is still whatever it was.
 
So it is more a less a move from Dest back to B (since they are the same thing).

In the PLC code I was given it is 1 to alarm, therefore when A and B are both 0's everything is good, as soon as get alarm (A=1) the result from the OR will make B also =1, therefore they will be equal and I cannot see how the NEQ would ever work.

Again I apologise for my lack of understanding.
 
I dunno, maybe when I get a PLC and download program it will work. I am just really trying to understand the logic.
Here are my thoughts:
Both A & B need to both be 0 starting out A=0=No Alarm B=0=No Latch, when A goes into Alarm (1) the OR instruction will make B also 1 which would make them the same before it gets to NEQ instruction.

:oops:
 
In the PLC code I was given it is 1 to alarm, therefore when A and B are both 0's everything is good, as soon as get alarm (A=1) the result from the OR will make B also =1, therefore they will be equal and I cannot see how the NEQ would ever work.
I agree. It seems that there is an error in one or the other of the rungs. If the OR causes A to equal B, but then later the NEQ depends on A being not equal to B, then there never will be an alarm. Do you have an earlier version of the program to compare to this version? It could be that one instruction got changed for a test and was never put back.

Looking at it some more, it appears that Rung 5 has got misplaced. What Rung 5 is doing is making the old alarm word equal to the new alarm word. This should only be done AFTER all the other stuff, after the new alarm and First Out bit has been set. So it should be placed after Rung 7, and be enabled by the First Out Bit XIC. Now, old Rung 6 becomes the place where a new alarm is found (FIRST_OUT_SD_IN not equal to FIRST_OUT_SD_ON).
 
Last edited:

Similar Topics

Is there any benefit to using ALMD instructions in a Studio 5000 project when the HMI is using FTView ME? We are currently triggering our alarms...
Replies
2
Views
3,407
Hi there, I've spent over a day now struggling with setting up an alarm and event server for FTView10. Poor documentation tells me they have...
Replies
3
Views
2,010
So I'm looking at putting in a cellular alarm. I'll have about 4-6 alarms, and I would like to send out text messages to a list of phone numbers...
Replies
16
Views
4,142
Anyone else playing with this today? Just got it to work right now with FTV SE.
Replies
4
Views
1,957
Hi, Not specific to any manufacturer of PLC or HMI/Scada but looking for best approach. To ensure a HMI/Scada receives the alarm I assume most...
Replies
3
Views
1,236
Back
Top Bottom