Counters?!?!

Glad we could help.

But wait, there's more! The following will allow an arbitrary sequence of daily A/C or B/C combinations, up to the number of scheduled days (4 or 5 or 6) defined by the rotary switch. It's basically a hand-rolled SQO instruction.
Untitled.png
 
Ok, so my schedule is working as should but output is not turning on when equal comparison is true. I have an EQU comparing ACC from counter compared to N71. But when ACC is 1 it will not energize output. Any thoughts? I'm sure I don't have the two values set to the same format or something like that. Thanks again for reading
 
Do you have multiple rungs with OTE instructions referencing the same address? That's a common beginner mistake which most of us have made, sometimes more than once.

I do have multiple rung triggering the same output using EQU to ACC for different values of the schedule. I did notice when testing that the last 2 lines will energize output. Should everything for output A be on the same rung with a lot of branches?
 
I do have multiple rung triggering the same output using EQU to ACC for different values of the schedule. I did notice when testing that the last 2 lines will energize output. Should everything for output A be on the same rung with a lot of branches?

Yes...in a PLC the scan is sequential before the outputs get updated to the modules. So the last instance of the OTE will be the determining logic. Think of an OTE as simply writing a 1 or 0 to the address. Your first OTE writes a 1, but the last one writes a 0. The result will be no output, because the final value is 0 when the physical output gets updated. The output address is just a memory storage location. Unless it's an immediate type output, it doesn't update the module output until end of scan.

This holds true for internal bits too...any address that's used in an OTE should only be used once in an OTE. It's referred to as a destructive instance.
 
Last edited:
Should everything for output A be on the same rung with a lot of branches?
:ROFLMAO:

Almost everyone does this. Once.

Welcome to the brotherhood; by doing this you have completed your initiation; we are having jackets made up.

TL;DR

The problem you encountered is called a "duplicate destructive bit reference." It is most definitely a user (programmer) coding error; it is in no way a fault in the PLC or its firmware.

An OTE, when evaluated, always writes no more and no less than exactly one of two values, either a 1 or a 0, to its bit operand. The OTE does not care a whit what the value of that bit was before writing the new value, so it may overwrite

  • a 0 with another 0, or
  • a 0 with a 1, or
  • a 1 with a 0, or
  • a 1 with another 1.
As @robertmee explained, if two (or more) OTE instructions, which both write to the same bit* are evaluated during the same scan cycle, then the OTE that is evaluated latest (last in time) during that scan cycle will determine the value of that bit at the end of that scan cycle, and the actions of all OTEs evaluated earlier in that scan cycle performed on the value that bit will be overwritten by, and lost to, the latest OTE evaluation performed.

* i.e. the same location in PLC memory,

So, if you had something like this,
Code:
     |   in0     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0000 +---] [-----( )---+
     |                 |
     |   in1     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0001 +---]/[-----( )---+
     |                 |
     |   in2     [COLOR=#0000ff][B]out   [/B][/COLOR]|
0002 +---] [-----( )---+
     |                 |
then only the last rung 0002 would have any effect on the final value for the out bit. So if the value of in1 was 0 and the value of in2 was 0, then even though a 1 would be written as the value of the out bit by the OTE on rung 0001, that value of 1 would be overwritten with a value of 0 on rung 0002.

Caveat: I offer the following for instructional purposes only, to aid in understanding how PLCs work, and not in any way, shape, or form as a recommendation.

If you had instead done something like this,
Code:
     |   in0     [B][COLOR=#0000ff]out[/COLOR][/B]   |
0000 +-+-] [-+---( )---+
     |                 |
     |   in1     [B][COLOR=#0000ff]out   [/COLOR][/B]|
0001 +-+-]/[-+---( )---+
     | |     |         |
     | | [B][COLOR=#0000ff]out [/COLOR][/B]|         |
     | +-] [-+         |
     |                 |
     |   in2     [B][COLOR=#0000ff]out   [/COLOR][/B]|
0002 +-+-] [-+---( )---+
     | |     |         |
     | | [B][COLOR=#0000ff]out [/COLOR][/B]|         |
     | +-] [-+         |
     |                 |
then any value of 1 written to the out bit on rungs 0001 and 0002 would be ORed with the result of the contact on hte left side of rung 0003 and written to the out bit i.e. if (in0 value was 1 OR in1 value was 0 OR in2 value was 1), then the value of the out bit would be 1. In other words it would have behaved like you originally thought the other incorrect would behave.

Again, I do not recommend this, and the (hopefully) obvious solution is to put all of the contacts evaluating in0, in1, and in2 in a single construct with 3 parallel branches, and rung the single output of that branched construct to a single OTE that is writing to the out bit.

Another possible approach would be this:
Code:
     |   in0     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0000 +---] [-----( )---+
     |                 |
     |   in1     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0001 +---]/[-----(L)---+
     |                 |
     |   in2     [COLOR=#0000ff][B]out   [/B][/COLOR]|
0002 +---] [-----(L)---+
     |                 |
Again, I am not recommending this, but only using it to illustrate how the PLC works.

In this case, the OTLs -(L)- instructions can only write a 1 to their operand**; they cannot write a 0. So if any of the contacts on the left evaluate to True, then a value of 1 will end up in out. Note that the first output instruction is an OTE: that ensures that a 0 is written to out if none of the contacts on the left evaluate to True.

The real point to be made here, and what you should burn into your mind, is that PLC programming is primarily about time, and the scan cycle***, are the clock. Knowing when something is happening is more important than knowing what is happening.

** and then only if their input rungs are True
*** plus the order of operation of rungs and instructions within the scan cycle

If this is not clear, then know that there is nothing new under the sun: I suggest you search this forum for the terms "duplicate" and "destructive," and you will find many more posts about this topic; perhaps one of those will flip the switch for you.
 
:ROFLMAO:

Almost everyone does this. Once.

Welcome to the brotherhood; by doing this you have completed your initiation; we are having jackets made up.

TL;DR

The problem you encountered is called a "duplicate destructive bit reference." It is most definitely a user (programmer) coding error; it is in no way a fault in the PLC or its firmware.

An OTE, when evaluated, always writes no more and no less than exactly one of two values, either a 1 or a 0, to its bit operand. The OTE does not care a whit what the value of that bit was before writing the new value, so it may overwrite

  • a 0 with another 0, or
  • a 0 with a 1, or
  • a 1 with a 0, or
  • a 1 with another 1.
As @robertmee explained, if two (or more) OTE instructions, which both write to the same bit* are evaluated during the same scan cycle, then the OTE that is evaluated latest (last in time) during that scan cycle will determine the value of that bit at the end of that scan cycle, and the actions of all OTEs evaluated earlier in that scan cycle performed on the value that bit will be overwritten by, and lost to, the latest OTE evaluation performed.

* i.e. the same location in PLC memory,

So, if you had something like this,
Code:
     |   in0     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0000 +---] [-----( )---+
     |                 |
     |   in1     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0001 +---]/[-----( )---+
     |                 |
     |   in2     [COLOR=#0000ff][B]out   [/B][/COLOR]|
0002 +---] [-----( )---+
     |                 |
then only the last rung 0002 would have any effect on the final value for the out bit. So if the value of in1 was 0 and the value of in2 was 0, then even though a 1 would be written as the value of the out bit by the OTE on rung 0001, that value of 1 would be overwritten with a value of 0 on rung 0002.

Caveat: I offer the following for instructional purposes only, to aid in understanding how PLCs work, and not in any way, shape, or form as a recommendation.

If you had instead done something like this,
Code:
     |   in0     [B][COLOR=#0000ff]out[/COLOR][/B]   |
0000 +-+-] [-+---( )---+
     |                 |
     |   in1     [B][COLOR=#0000ff]out   [/COLOR][/B]|
0001 +-+-]/[-+---( )---+
     | |     |         |
     | | [B][COLOR=#0000ff]out [/COLOR][/B]|         |
     | +-] [-+         |
     |                 |
     |   in2     [B][COLOR=#0000ff]out   [/COLOR][/B]|
0002 +-+-] [-+---( )---+
     | |     |         |
     | | [B][COLOR=#0000ff]out [/COLOR][/B]|         |
     | +-] [-+         |
     |                 |
then any value of 1 written to the out bit on rungs 0001 and 0002 would be ORed with the result of the contact on hte left side of rung 0003 and written to the out bit i.e. if (in0 value was 1 OR in1 value was 0 OR in2 value was 1), then the value of the out bit would be 1. In other words it would have behaved like you originally thought the other incorrect would behave.

Again, I do not recommend this, and the (hopefully) obvious solution is to put all of the contacts evaluating in0, in1, and in2 in a single construct with 3 parallel branches, and rung the single output of that branched construct to a single OTE that is writing to the out bit.

Another possible approach would be this:
Code:
     |   in0     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0000 +---] [-----( )---+
     |                 |
     |   in1     [COLOR=#0000ff][B]out[/B]   [/COLOR]|
0001 +---]/[-----(L)---+
     |                 |
     |   in2     [COLOR=#0000ff][B]out   [/B][/COLOR]|
0002 +---] [-----(L)---+
     |                 |
Again, I am not recommending this, but only using it to illustrate how the PLC works.

In this case, the OTLs -(L)- instructions can only write a 1 to their operand**; they cannot write a 0. So if any of the contacts on the left evaluate to True, then a value of 1 will end up in out. Note that the first output instruction is an OTE: that ensures that a 0 is written to out if none of the contacts on the left evaluate to True.

The real point to be made here, and what you should burn into your mind, is that PLC programming is primarily about time, and the scan cycle***, are the clock. Knowing when something is happening is more important than knowing what is happening.

** and then only if their input rungs are True
*** plus the order of operation of rungs and instructions within the scan cycle

If this is not clear, then know that there is nothing new under the sun: I suggest you search this forum for the terms "duplicate" and "destructive," and you will find many more posts about this topic; perhaps one of those will flip the switch for you.

Wonderfully described! I swear I saw a light come on over my head as I was reading this.:p
 
Wonderfully described! I swear I saw a light come on over my head as I was reading this.:p
You are on the way. Maybe I should change my handle to PLC Pedant.

If you really want to lock it in, I suggest you watch this video series, and watch it repeatedly until you "see" the narration before Ron says it.

Also studying the Ladder Logic patterns at this site will give you the tools used over and over in programming and debugging PLCs.

* 10-11 minutes per video; the whole thing takes less than 2h, and @Ron Beaufort is a far more accomplished teacher than me.
 

Similar Topics

Hi Hope you all are doing well. Iam working on a project with some AOI. I also hate no online edits... lol. My problem occurs when I use a UDT...
Replies
2
Views
157
iFIX 5.5. We have alarm count database tags with SIM driver and I/O address = "C:AREA-SD:ACK" which is suppose to count the acknowledged alarms in...
Replies
16
Views
1,406
https://www.youtube.com/watch?v=zTOOYWMJg9M . Specifically see 1:46 to 2:11. 3. The Cell PLC is in constant communication with two other field...
Replies
14
Views
3,159
Does the 1100 only have 1 high speed counter, but it can have multiple inputs? And so then the 1400 has 6 HSC and you have a choice of multiple...
Replies
1
Views
1,716
I have a questions on counters and accumulators and how do the accumulators work as a preset? I have a program that uses the accumulators as the...
Replies
26
Views
8,609
Back
Top Bottom