Count the number of closed inputs in module 0.
The solution to this problem requires the use of operations that are included
in the integrative set. This means it is necessary to write the program as a
functional block and then call it from the OB1 for cyclic execution. It is not
possible to write the program in ladder format.
We will store the number of closed inputs in MB80 and use W10 as a pointer for
the input normally examined. The first part of the program in OB1 consists of
initiating these two variables at 0. The next statement calls the block FB4 that
contains the main part of the program.
As a result of the unconditional block call statement, the development continues
from the first statement in FB4.
The first two statements of this block load the complement of the input with the
pointer MW10 into RLC. The channel direction is in the high byte and the module
direction in the low byte. As MW10 is at 0, the first step will load the
complement of the status of E0.0.
The next statement is a conditional jump: If RLC = 1, that is, if the complement
of E0.0 is equal to 1, the input is open and the program continues after the INC
label. On the other hand, if the input is closed, this jump does not take place
and the program continues with the next statement.
The next four statements increase the value of MB80, that is the number that
represents the count of the number of inputs that have been found closed. This
value is first loaded into ACCU1 and then increased by 1 unit. The result is
then again transferred to MB80. The purpose behind these statements and the
preceding ones is to increase the variable MB80 if the input is closed and not
increase it if the input is open.
In both cases the program reaches the group of statements labelled as INC and
which, like the first action, increase the high byte of MW10, that is MB10 and
the byte that represents the number of the input channel in the controlled
loading operation seen earlier (for didactic purposes we have used a different
operation to increase the byte). The recently obtained value is then compared to
7. If the result is equal to or less than 7, then the input exists and we should
check its status by returning to the TEST label as specified in the conditional
jump statement. On the other hand, if the value is 8 then the channel does not
exist and we have to exit the block after having examined the eight possible
inputs, from E0.0 to E0.7.
The section of the program between the label TEST and the statement SPB = TEST
is performed eight times before returning to the starting block OB1 through the
final BE statement. Each time MW10 will count a different value: in a
hexadecimal succession of 0000, 0100, 0200, 0300, 0400, 0500, 0600, 0700; and
each time the group of statements B MW10 and UN E0.0 will load the RLC with the
complement of a different input of the module from the first to the last. The
part of the program that goes from L MB80 to T MB80 is only loaded if the input
normally checked is closed. This means that the increase of MB80 only takes
place under this condition and, as the initial value of this merker byte is
equal to 0, when execution of the block has been completed it will count the
number of closed inputs.

If we want to analyse the closed inputs in module 1, simply load 1 as the
initial value for MW10. It is also possible to determine the total number of
closed inputs for the two modules. All that is required is to call FB4 on two
occasions, the first time by initialising MW10 to 0 and the second time by
setting it to 1. On the other hand, for MB80, it is only necessary to initialise
it to 0 at the beginning of the OB1. We will leave the writing of this program
up to you.

More examples: [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ 18 ] [ 19 ] [ 20 ] [ 21 ] [ 22 ] [ 23 ] [ 24 ] [ 25 ] [ 26 ] [ 27 ] [ 28 ] [ 29 ] [ List
]
More PLCs examples: Not still available