Post on 07-Jul-2015
description
Sometimes, deadlocks in PC supported automation systems can be a real headache if it designed poorly.
When a deadlock occurs, system stops by making it impossible to free up without intervention.
1 2 3
Boxes move this way
Assume that we have a conveyor carrying boxes, and scanning each boxes barcode and store it in computer database.
We should have an ordinary PC – PLC handshake system
Network delays or PC unstability may cause delays in this handshake.
Following legend is intended to visualise PC – PLC handshake, only two signals are included. Barcode data is omitted.
1 2 3
Way Data ValuePLC to PC Data Save Request False
PC to PLC Data Saved False
Initially, Box 1 is not on the station yet, and is ready for receiving a box data
Let's see a normal operation. When Box 1 comes to the station, PLC gets the product presence information from sensor and transfers it to the PC by setting 'Data Save Request' flag to 'True'
1 2 3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved False
When PC gets boxes information, it updates a database table and informs PLC by setting 'Data Saved' flag to 'True' when completed.
1 2 3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved True
Then PLC sends the Box 1, and clears its 'Data Save Request'
1 2 3
Way Data ValuePLC to PC Data Save Request False
PC to PLC Data Saved True
And PC clears its 'Data Saved' flag.
1 2 3
Way Data ValuePLC to PC Data Save Request False
PC to PLC Data Saved False
This is a complete cycle without any problem. In normal conditions, this cycle is repeated by many times between PC and PLC
2 3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved False
However, PC is not stable as PLC, sometimes it can be late to give an answer to PLC.
In this case, PLC will not send the box until it gets a response from PC.
2 3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved False
4
Normally it is not a big problem, may be less than a second of waiting may occur.
2 3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved True
4
But what may happen if PC have a temporary hang at this moment? PLC resets its 'Data Save Request' but PC could not find a chance to see it yet.
2 3
Way Data ValuePLC to PC Data Save Request False
PC to PLC Data Saved True
4
But what may happen if PC have a temporary hang at this moment? PLC resets its 'Data Save Request' but PC could not find a chance to see it yet.
And unfortunately, Box 3 come to the station.
3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved True
4 5
Before hanging, PC set the 'Data Saved' flag for Box 2 and did not realised that Box 3 is on the station. PC is assuming that Box 2 never leaved the station
3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved True
4 5
2
Now there are two possibilities according to the poorness of design:
Possibility 1: Deadlock. PC and PLC mutually waits each other to reset their flag.
3
Way Data ValuePLC to PC Data Save Request True
PC to PLC Data Saved True
4 5
2
Now there are two possibilities according to the poorness of design:
Possibility 2: Miss the Box 3 without recording its data into database
3
Way Data ValuePLC to PC Data Save Request False
PC to PLC Data Saved False
4 5
Bye bye Box 2 !
'State analysis' of a system is important. A poor design may cause unwanted results.
In next post, we will do a state analysis for the single station with a single task.
http://indanotes.blogspot.com