I added the debounce logic for the entry and exit gate sensor
Question to Daba: Do you usually put these Debounce Logic rungs in a subroutine?
Yes, put all your input conditioning in one subroutine. One call (JSR) to that subroutine per scan is all you need. Nowadays in Logix5000 I would use an Add-On Instruction for each input, but you don't have that luxury with Logix500. Even then the AOI's would all be in one routine... tidy.
I use TOF now for 2 seconds after the car has cleared the input sensor and use the /TT of each timer to count cars in and out.
-The exit gate can't open if the car park is empty. This also prevent the counter to go under 0 value (-1,-2..) with the use of a EQU = o that blocks the exit gate and counter if the car park is empty.
Not the way I would do it....
If a car appears at the exit gate when the software
thinks the car-park is empty clearly indicates the software is
wrong, and has lost track of how many vehicles are in there.
Under these sort of circumstances, you have to let the
reality of the situation override the software, not the other way round. The reality is that there IS a car in the car-park, at the exit gate, trying to get out, irrespective of how many counts the counter has. Imagine the inconvenience to the driver if he can't get out of a car-park, just because the count has got screwed.
I would let the car out regardless of the count in the counter, but prevent the counter going below zero, that's all. It just needs one rung...
LES C5:0.ACC 0 CLR C5:0.ACC (or MOV 0 C5:0.ACC)
or you could put GRT C5:0.ACC 0 in the rung with the CTD instruction, either way stops the counter going negative, although I prefer the trap rung above, as it is more robust.