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.