|
This is my first time programming a PLC or Smart Relay and normally I am an embedded systems programmer. I am trying to build the circuit using WindLGC to determine direction. I have six photobeams. If Photobeam 1 is ON, then I open the gate and start a timer. If photobeam 2 is ON, photobeam 1 is OFF, then I reset timer for closing since I know that someone is coming through. However, the difficulty is for back-outs. If photobeam 1 is off, photobeam 2 is on, then photobeam 1 is on and then off, then I close the gate (as long as no one is on safety beam). The problem is determining direction using the circuit. How do I do this? Do I use a counter to increment and decrement ? Should I rely on the timer so that when it hits the timer it closes rather than immediately on back-out? It seems it should be closed immediately on back-out. I know how to do this in code, but circuits are new to me. The logic on paper makes sense but designing the circuit in the program is a little difficult. Any help anyone can provide would be really appreciated. |
|
What you need is an internal coil (bit) to hold the state of the logic, and at that point you have a classic state machine. Start by drawing out your states and counting how many there are. Assuming you don't have hundreds, resist the urge to represent the state with an integer because that will make it harder to understand the logic later. Just define one bit per state. Then write the logic in the PLC to make those states turn on in the right sequence. Use a sealed in rung to hold the state, or you can use an SR (set/reset) instruction if you need to hold the state through a processor reset. Therefore if you're in state 3, you can define transitions to state 2 or state 4, depending on the inputs, etc. That's how you can easily program your "back-out" logic. |


