To Latch or Unlatch; That is the question! Help Please!

donl517

Member
Join Date
Dec 2005
Location
Michigan
Posts
127
I am not a novice programmer but I have never used the N7 registers the same way I would use a B3. However I am modifying a program for a customer and the original author used the N7 registers.

I have read several posts and as I understand it the N7 registers behave exactly the same as a B3 when addressed througn XIC, XIO, OTE. If that is all correct then when a bit is latched in an AB Micrologix 1500 it HAS to be unlatched later in the program. This is true for B3 and N7 correct?

So if you saw:
B3:0/0(L)
B3:0/1(L)

And there were no (U) instructions for either of these anywhere in the program once they went true they would stay on forever correct? (even through power loss)

So if they are then used like this:

B3:0/0XIO B3:0/1XIC

They would cancel each other out and the rung would never go true correct?

Either I am losing my mind or this program should never have worked. There are 15 latched bits that are never unlatched anywhere in this program. Does anyone have any thoughts here?

Thanks a million,
Don
 
Is anything writing to the word level of the bits?
Do a find all and see what references.
I like to use a N7 int to contain my status bits, then write a 0 to the whole word when I want to clear it all.
 
Also,

If you zip the program up I can tell you real quick exactly where they are getting unlatched.
 
So if he used N7:21 and latched several of the bits and then used a FLL instruction with source=0 Destination=#N7:21 Length=1 That would clear the latch of each of the bits? Would the same apply to the B3 Registers?
 
Edited for clarity:

Both will work. The clear will be faster, as it's not an array type instruction.

Mov 0 will also work for the N7 type registers.
 
Last edited:
I have use latches that never get unlatched, they are only used for testing purposes. Most of the time I go back and remove them but it is possible that I could forget one.

Another reason could be an HMI is being used to unlatch the bits.
 

TYPE-A

CR1 CR1
---| |---+-------------( ) ALWAYS ON
|
CR1 |
---|/|---+

CR2 CR2 CR2
---| |-------|/|-------( ) ALWAYS OFF

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

TYPE-B

CR3 CR3
---|/|-----------------( SET ) ALWAYS ON (SET or LATCH)

CR4 CR4
---| |-----------------( RST ) ALWAYS OFF (RESET or UNLATCH)


= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

For those PLCs that allow Rungs to be constructed of Outputs without Inputs...

TYPE-C

CR5
-----------------------( SET ) ALWAYS ON (SET or LATCH)

CR6
-----------------------( RST ) ALWAYS OFF (RESET or UNLATCH)


.
Some PLCs have an ALWAYS-ON bit... some don't.

Sometimes it's just easier to make one than it is to try to remember the identity of the built-in one. And then, since you are building it anyway, you might as well build the converse bit. It is easier to relate to the positive version of Always ON and Always OFF, rather than the positive form of Always ON and the negative form of Always ON. After all, in terms of language logic, "NOT Always ON" does not necessarily mean "Always OFF"!

ALWAYS
CR20 OFF CR100
---| |-------| |-------( ) This bit will Always be OFF

CR30 CR200
---| |---+-------------( ) This bit will Always be ON
|
ALWAYS |
ON |
---| |---+


.
If the rungs used to control the state of the Always ON and Always OFF bits are at the top of the code, then every scan begins (after those two rungs) with the ALWAYS-ON bit being ON, and the ALWAYS-OFF bit being OFF.

HOWEVER, once the program moves beyond those rungs... the value of Always ON and Always OFF bits can be manipulated, in subsequent rungs, in any manner you wish. This applies to both bit-type data and variable-type data. And there are dozens of ways to manipulate ANY data type!

As to unlatching a permanently latched bit by means of an HMI... that becomes problematical.

If the HMI can write directly to the Control Relay Image Table... independent of the CPU... then yes... the bit can be unlatched, and, if that happens while the CPU is in the middle of processing the Ladder, then that bit will be unlatched from that point in the program onward - until the next scan.

Can you see the problem?
 
CroCop said:
Edited for clarity:

Both will work. The clear will be faster, as it's not an array type instruction.

Mov 0 will also work for the N7 type registers.

OK I have had time to sleep on it and think about this. I can see the benefit in using either one of these approaches. But, why would you use both of them in the same program?

Thanks,
Don

To clarify I mean the B3 and the N7 registers.
 
Last edited:
Clear - quick
Move 0 - could be another number functioning as a mask, like a move 1
FFL - Arrays of Words to clear

I personally use the Move 0, and don't use the others.
 
Sorry about that your response came before my edit. To clarify I mean using this approach with B3 & N7. Is there any logical reason/advantage to use both of these the same way in the same program?

Thanks,
Don
 
donl517 said:
Sorry about that your response came before my edit. To clarify I mean using this approach with B3 & N7. Is there any logical reason/advantage to use both of these the same way in the same program?

Thanks,
Don

Yes. If you're sending a message between a couple of PLCs, you can put an array of integers together and send them at once. You can pack up the boolean status bits to an integer and send them as part of the single message.
 
Greetings Don,



from the flow of what’s been said, it looks like you’ve already got a handle on things ... I just want to nail down one idea for sure ... in post #5 you asked:



How about CLR Dest=B20:0 Would that unlatch everthing in B20?



the answer is “maybe” ... but then again “maybe not” ... to give you a definite answer, we need to know how big is B20? ...



basic idea: CLR Dest=B20:0 would indeed “unlatch” all 16 bits (“everything”) in the 16-bit word B20:0 ... but the B20 address that you specified references a “file” which might (or might not) contain more words than just B20:0 ...



if you’re ok with those ideas then I’d say you’re all set to go ... if not, then post again and we’ll nail things down for you ... (I’ve got a good hunch that you just meant to say “B20:0” both times in your question ...



now going a little bit further ... here’s a trick that will USUALLY help you find the answer to annoying little puzzles like your original question ...



usage.JPG




by going to the Data Table and clicking the “Usage” button, you can usually get a pretty good idea of what “level” of control is being used on various addresses ... for examples:



(1) the OTL (Latch) instruction is using/controlling/referencing the single bit B20:0/2 ... this puts the “X” on the usage chart ...



(2) the CLR (Clear) instruction is using/controlling/referencing the 16-bit word B20:0 ... this puts the “W” in the “FW” column of the usage chart ...



(3) the FLL (Fill File) instruction is using/controlling/referencing the 3-word "file" structure B20:2 through B20:4 ... this puts the “Fs” in the “FW” column of the usage chart ...



Caution! ... you might have noticed that I keep saying “usually” instead of “always” ... the reason is that if your program is using Indirect Addressing, then all bets are off ... specifically, indirect addressing will not show up on the “Usage” chart at all ... and while we’re on the subject of “weird control” I’ll mention one more thing too ... in many applications it’s possible for something like an HMI/SCADA system to write into the status of a bit and effectively “latch” or “unlatch” it ... and of course this type of control would not show up anywhere at all in your program logic either ...



PS ... and to Phil if you’re reading this ... thanks a million for the wider picture format ... I for one am very glad it’s back ...
 
Last edited:

Similar Topics

Hi everyone. First time poster here. I am very new to PLC programming (my programming background is more in computers). I have a question with...
Replies
12
Views
3,186
Good day all. I have a question pertaining to an unlatch instruction. Unfortunately I'm not able to share the program however, I have attached...
Replies
8
Views
3,965
Hello All, Can someone see what I did wrong here. My "PA" bit never seems to get energized despite hitting "SOFTKEY7" many times
Replies
5
Views
706
Hi guys, I have a question regarding studio 5000 with processor 1769-L33ER V33.011 and Factorytalk View SE V12. I have an home-made pop-up...
Replies
3
Views
1,534
I'm troubleshooting a machine for a customer right now, and the output that is not working needs this bit to go high to activate the coil. But the...
Replies
36
Views
13,539
Back
Top Bottom