Here's a typical scene:
Our parts conveying center is operating as usual. At the end of the day we shutdown the system BUT we don't want to remove all the parts currently in process. In other words, when we come back to the factory in the morning, we want to just power up the machine and continue where we left yesterday. We don't want to go through a reset cycle as that would take time away from our production. How can we do it?
Well, we must remember the status of our conveying system... was it moving up or down? Here's what our conveying system looks like:
_
| 0 |{-}<--- limit switch (a)
((MOTOR SPIN DOWN SECTION))
0000 0001 0501
---| |---|---|/|-----( )--
|
0501 |
---| |---+
If the tray starts at the bottom, limit switch b (0001) is physically on and limit switch a (0000) is physically off. So, logic flows to the motor (0500) and it spins, moving the tray up. Notice that 0500 is latched on now and the limit switch b (0001) becomes physically off.
Eventually the tray hits the top limit switch a (0000) which unlatches 0500 and forces (motor spin down) 0501 to turn on. When the tray goes down enough to hit limit switch b (0001), the cycle will repeat.
BUT, if we lose power and the tray is somewhere between limit switches a and b, the latch on either 0500 or 0501 will be lost when power to the PLC is returned. In that case we need a "homing button" to return the tray to a "home" position. What if we don't want the tray to return home, but rather we want it to continue in the direction it was going before we lost power? In that case we need to use "retentive relays". Retentive relays simply retain their status when when the plc powers off and then back on again. So, if the relay was off when the power was lost, it will be off when the power returns. And, if the relay was on when the power was lost then it will again be on when the power returns.
Typically, a plc has internal utility relays that can be made to be retentive or not. Most will not have a function to make the real world outputs retentive. So, let's then modify the program to include retentive internal utility relays. In our example, we'll use two and they'll be addressed as 1000 and 1001.
INTERNAL RELAYS
retentive relay (c) = 1000
retentive relay (d) = 1001
INPUTS
limit switch (a) = 0000
limit switch (b) = 0001
OUTPUTS
motor spin up = 0500
motor spin down = 0501
The ladder logic will NOW look like this:
((MOTOR SPIN UP SECTION))
0001 0000 1000
---| |---|---|/|-----( )--
|
1000 |
---| |---+
1000 0500
---| |---------------( )--
((MOTOR SPIN DOWN SECTION))
0000 0001 1001
---| |---|---|/|-----( )--
|
1001 |
---| |---+
1001 0501
---| |---------------( )--
So, now if the power is lost and then returned, 1000 and 1001 will retain their status as just before power was lost. Then the motor will continue moving in the direction it was going before the power loss.