7.6 Automation of parking garage
We are dealing with a simple system that can control 100 car at the maximum. Each time a car enters, PLC automatically adds it to a total sum of other cars found in the garage. Each car that comes out will automatically be taken off. When 100 cars park, a signal will turn on signalizing that a garage is full and notifying other drivers not to enter because there is no space available.
Signal from a sensor at the garage entrance sets bit IR200.00. This bit is a condition for execution of the following two instructions in a program. First instruction resets carry bit CY (it is always done before some other calculation that would influence it), and the other instruction adds one to a number of cars in word HR00, and a sum total is again stored in HR00. HR memory space is selected for storing a total number of cars because this keeps the status even after supply stops.
Symbol "#" in addition and subtraction instructions defines decimal constant that is being added or subtracted from a number of cars already in the garage. Condition for executing comparison instruction CPM is always executed because bit SR253.13 is always set; this practically means that comparison will be done in each cycle regardless whether car has entered or left the garage.
Signal lamp for "garage full" is connected to an output IR010.00. Working of the lamp is controlled by EQ (equal) flag at address SR255.06 and GR (greater than) flag at address SR255.05. Both bits are in OR connection with an output IR010.00 where the signal lamp is. This way lamp will emit light when a number of cars is greater than or equal to 100. Number of cars in a real setting can really be greater than 100 because some untrusting driver may decide to check whether there is any space left, and so a current number of cars can increase from a 100 to 101. When he leaves the garage, a number of cars goes down to 100 which is how many parking spots there are in fact.
Ladder diagram:
