"The drawbridge example"
Long time i was looking for an example for the AFSM and than suddently -talking about the parking places at schiphol airport (AMS)- i decided to choose a drawbridge (?). Parking places at the P2 parkingplace are identified by typical dutch objecs like "wooden shoes", "cheese" and .. "drawbridge". The drawbridge i used for the AFSM example is a typical dutch bridge; with signs for the ships, signs for the road and barriers to hold up the traffic and ofcourse the brigedeck.
Here a simple explanation for the working of the example:
The operator (bridge keeper) has 4 buttons on his theoretical simple desk; 3 request buttons; e.g. "open bridge", "close barriers", "close bridge". The 4th button is the safety stop. In the idle state, the red sign for the ships is activated. When there is a ship waiting for the bridge to open, the operator starts the sequence by pressing the "open bridge" button. When pressed, the roadsigns are activated; the roadsigns exitst of 2 red lamps and are now blinking at a rate of 500mS. It is not possible to directly activate the barriers; the operator has to wait for 10 sec to get permission for closing the barriers. When the cars have stopt for the bridge and the 10s have passed, the request for closing the barriers is accepted and the barriers get a command to close. After the barriers have reached there end positions, the bridge deck motor is commanded and the deck is going to open for ships. Now both signs for the ships are activated; in order to get the ships ready for passing the bridge. When the deck is in the upper position, only the green sign is activated; ships can pass the bridge. After passing the bridge, the operator can make the request for lowering the bridge deck. This request is only accepted when there are no ships present under the bridge deck. When accepted, the bridge motor is commanded to lower the bridge deck. When the bridgedeck reached the end position, the barriers are commanded to open for traffic. When the barriers reached there end position, the roadsigns are turned off and traffic may pass the bridge. The bridge is again in the idle state.
That's all for the working, now the technical implementation of the AFSM:
First of all define all necassery I/O for this control and the possible states of the bridge object:
The naming of the I/O tags is not very professional, just logical names. It applies not to any standard like S88.
- The request button for opening the bridge (reqBridgeOpen)
- The request button for closing the barriers (reqBarriersClose)
- The request button for closing the bridge (reqCloseBridge)
- Safety stop button (Stop)
- Conformation contact bridge open (confBridgeOpen)
- Conformation contact bridge closed (confBridgeClosed)
- Conformation barriers down (confBarriersDown)
- Conformation barriers up (confBarriersUp)
- Input for activate simulation of conformation signals (Simulation)
- Activation of canal signs (signCanalRd & signCanalGn)
- Activation of road signs (signRoadLower & signRoadUpper)
- Activate bridge deck motor (BridgeMotor)
- Direction of bridge deck motor (BridgeUp)
- Activation of barrier motors (BarrierMotors)
- Direction of barrier motors (BarriersUp)
- Distance measurement:
- measurement distance to possible object under the bridge (measBridgeDock)
Possible states of the bridge, the activation of outputs and transistions to another states
The bridge is in the idle state, normal road traffic is possible. The red canal sign is activated. When the operator is pressing the "reqBridgeOpen" botton, two transitions are made; to state "roadSignOn" and to state "WaitToCloseBarriers".
The road signs are activated to warn traffic. The upper and lower road sign blink in a freqency of 500mS. The road signs are deactivated when the barriers are back in the upper position by a transition to the "END" state.
The red canal sign is activated. It is not possible for the operator to lower the barriers directly from the request to close the bridge. He has to wait for an amount of time before the button "reqBarriersClose" is accepted by the control. After the time-out a transistion to "enableCloseBarriers" is made.
The red canal sign is activated. The operator is able to request closing the barriers. When pressing the "reqBarriersClose" a transition to state " BarriersClosing" is made.
The red canal sign is activated. The barrier motors are activated to go down (output "BarrierMotors" is activated, output "BarriersUp" is not activated). When reaching the lower position "confBarriersDown" the transition to state "BridgeOpening" is made.
The canal signs (red en green) are both activated; ships are signaled to prepare for passing the bridge. Command "BridgeMotor" is activated and also "BridgeUp". When reachting to upper position of the bridge "confBridgeOpen", the transition to state "BridgeOpen" is made.
The green canal sign is activated. Ships can pass the bridge. When all ships passed the bridge, the operator may request the closing of the bridge by pressing button "reqBridgeClose". The command is only valid when the distance of the distance measurement to possible objects under the bridge is greater than a given value. When the distance is valid and the button "reqBridgeClose" is pressed, a transition is made to state "BridgeClosing".
The red canal sign is activated. Command "BridgeMotor" is activated. When the bridge is in back in the lower position "confBridgeClosed", a transition to "BridgeClosed" is made.
The red canal sign is activated. Command "BarrierMotors" and "BarriersUp" is activated. The barriers are going up tp there home position. When all barriers are up a transition to state "BarriersUp" is made. In state RoadSignOn a transition to the end state is made when the barriers are in the upper position again.
The red canal sign is activated. Now the bridge is closed for boots and open for trafic and the barriers are up again, a transition to the idle state is made. A new request for opening the bridge can be made by the bridge keeper.
All software for the drawbridge example is available under folder "software".
In the example you can see that a windows popup is created by a click on the process value.
The Raspberry PI3 debug app: