Sunteți pe pagina 1din 3

Keep Control of a Value

The control and manipulation of data allows the actual status of an action to
be reported for example; How many cars are currently in the car park?

Keep Control of a Value

Keep Control of a Value


From a previous section of user program a car can be detected entering or
leaving the car park. This information could be passed on to another section of
program through the use of internal coils and flags. In this example the flags
M070 and M071 represent the car entering or leaving the car park. When ever a
car enters the car park the current record of the number of cars in the car park is
incremented by 1, i.e. the contents of data register D030 has an INC instruction
performed on it.
Register D030 is continuously compared against the known maximum
number of cars that can be accommodated; The CMP instruction is driven by
special M coil M8000. When the values equal each other the car park is full,
hence the compare instruction turns on lamp, LP1 (Y004) announcing the car
park is full.
If however, a car leaves the DEC instruction (driven by the flag M071 when
the car leaves) decreases the data register D030 by 1 unit. While the number of
cars in the car park are less than the maximum the lamp, LP2 (Y003) is driven
encouraging drivers to enter.

S-ar putea să vă placă și