Modeling of PLC programs with High-level Coloured
Petri Nets
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A.
Yaroslavl State University
2017
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Programmable Logic Controller (PLC) 2/12
INPUTS OUTPUTS
PROGRAM
EXECUTION
PLC characteristics.
Inputs: sensors, limit switches, buttons, meters . . . .
Outputs: electromagnetic relays, motors, light indicators . . . .
Working cycle: reading from inputs,
program execution,
writing to outputs.
Wide sphere of application.
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
The approach to constructing programs 3/12
Proposed sequence of writing PLC-programs:
Creating LTL-specification
G X( ¬_V ∧ V ⇒ FiringCond )
G X( _V ∧ ¬V ⇒ FiringCond )
Translation to SMV language and verification
case{ ∼V & next(FiringCond ) : next(V ) := 1;
V & next(FiringCond ) : next(V ) := 0;
default : next(V ) := V ; }.
Translation to IEC 61131-3 standard lanuages
IF NOT _V AND FiringCond THEN V := 1 ;
ELSIF _V AND FiringCond THEN V := 0; END_IF.
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
PLC-programming by LTL-specification 4/12
Conditions for program variables:
1 Each variable value must not change more than once per one
pass of PLC working cycle.
2 The value of each variable must change at only one place in
the program.
G X( V >_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr )
G X( V <_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr )
GX(V =_V ⇒ ¬(OldValCond ∧ FiringCond) ∧ ¬(OldValCond ∧ FiringCond ))
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Restrictions of the approach 5/12
Typical PLC Tasks:
Hydraulic system
Library lift
Installation for preparation of mixtures
Installation for lime dosage
The approach is applicable for discrete tasks of logical control,
requiring PLCs with binary inputs and outputs. SMV allows to build
models with 259 states.
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Translation to Petri net 6/12
LTL-specification:
G X( V >_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr );
G X( V <_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr ).
Common scheme of a transition of Petri net:
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Installation for preparation of mixtures 7/12
PVlv
LS0
LS1
LS2
Mtr
Tank 2
Tank 1
Vlv2
Vlv1
Tank 2 empty
Tank 1 empty
MS
EVlv
Emergency
valve
Pouring
valve
TS1
TS2
Level 2
Level 1
Level 0
Finished
Proper
Spoiled
Mixture
Component 2Component 1
Components in reservoir
Vlv1
Vlv2Working
On
Motor
Error
Motor
Valves
Vlv1
Vlv2
PVlvPVlv
EVlv
Control panelScheme of installation
Reservoir
Valves / lampsSwitches
PLC OutputsInputs
SBPVlv Open pouring valve Open pouring valve PVlv
Open valve 1
1 1
2 Vlv1SBVlv1 Open valve 1
2
SBVlv2 Open valve 2
3
SBMtr Start motor
5
Sensors
LS0 Level sensor 0
8
LS1 Level sensor 1
9
LS2 Level sensor 2
10
Open valve 2
3 Vlv2
Start motor
5 Mtr
MS Motor sensor
11
Open emergency valve
4 EVlvSBEVlv Open emergency valve
4
TS1 6
TS2 Tank sensor 2
7
States / lamps
Mixture is proper
6
7
Mixture is spoiled
8
Component 2 in mixture
10
Component 1 in mixture
9
11
MxIsFin
MxIsPrp
MxIsBad
C1InMx
C2InMx
MtrErr
Mixture is finishedTank sensor 1
Motor error
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Petri Net 8/12
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Consistent behaviour of sensors 9/12
Additional fine-tuning program model for corresponding to the
actual behaviour of the PLC programs
G( X( S) ⇒ Cond1 ),
G( X(¬S) ⇒ Cond1 ).
G( ¬S ∧ X( S) ⇒ Cond2 ),
G( S ∧ X(¬S) ⇒ Cond2 ).
These formulas are written in guard condition of Input transition.
Some examples:
(not p_TS1 orelse TS1 orelse p_Vlv1),
(not p_TS2 orelse TS2 orelse p_Vlv2),
(not MS orelse p_Mtr),
(LS0 orelse not LS1 andalso not LS2)
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Examples of temporal properties 10/12
“Overspending”. Components will never be added to the
spoiled mixture.
G(¬(MxIsBad ∧ (Vlv1 ∨ Vlv2)))
“Spoiled product”. The spoiled mixture will never be drained
through valve “PVlv”.
G(¬(MxIsBad ∧ PVlv))
“Spoiled mixture”. Spoiled mixture can not be proper or
finished.
G(¬(MxIsBad ∧ (MxIsPrp ∨ MxIsFin)))
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Conclusion 11/12
CPN Tools provides availabilities to:
show data flows from input variables to outputs
demonstrate dependences between inputs, outputs and
program variables
visualize possible concurrent blocks
modeling resources and timing with tokens
make simulation modeling for checking some class of properties
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
Thank you!
Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets

TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets

  • 1.
    Modeling of PLCprograms with High-level Coloured Petri Nets Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Yaroslavl State University 2017 Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 2.
    Programmable Logic Controller(PLC) 2/12 INPUTS OUTPUTS PROGRAM EXECUTION PLC characteristics. Inputs: sensors, limit switches, buttons, meters . . . . Outputs: electromagnetic relays, motors, light indicators . . . . Working cycle: reading from inputs, program execution, writing to outputs. Wide sphere of application. Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 3.
    The approach toconstructing programs 3/12 Proposed sequence of writing PLC-programs: Creating LTL-specification G X( ¬_V ∧ V ⇒ FiringCond ) G X( _V ∧ ¬V ⇒ FiringCond ) Translation to SMV language and verification case{ ∼V & next(FiringCond ) : next(V ) := 1; V & next(FiringCond ) : next(V ) := 0; default : next(V ) := V ; }. Translation to IEC 61131-3 standard lanuages IF NOT _V AND FiringCond THEN V := 1 ; ELSIF _V AND FiringCond THEN V := 0; END_IF. Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 4.
    PLC-programming by LTL-specification4/12 Conditions for program variables: 1 Each variable value must not change more than once per one pass of PLC working cycle. 2 The value of each variable must change at only one place in the program. G X( V >_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr ) G X( V <_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr ) GX(V =_V ⇒ ¬(OldValCond ∧ FiringCond) ∧ ¬(OldValCond ∧ FiringCond )) Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 5.
    Restrictions of theapproach 5/12 Typical PLC Tasks: Hydraulic system Library lift Installation for preparation of mixtures Installation for lime dosage The approach is applicable for discrete tasks of logical control, requiring PLCs with binary inputs and outputs. SMV allows to build models with 259 states. Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 6.
    Translation to Petrinet 6/12 LTL-specification: G X( V >_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr ); G X( V <_V ⇒ OldValCond ∧ FiringCond ∧ V = NewValExpr ). Common scheme of a transition of Petri net: Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 7.
    Installation for preparationof mixtures 7/12 PVlv LS0 LS1 LS2 Mtr Tank 2 Tank 1 Vlv2 Vlv1 Tank 2 empty Tank 1 empty MS EVlv Emergency valve Pouring valve TS1 TS2 Level 2 Level 1 Level 0 Finished Proper Spoiled Mixture Component 2Component 1 Components in reservoir Vlv1 Vlv2Working On Motor Error Motor Valves Vlv1 Vlv2 PVlvPVlv EVlv Control panelScheme of installation Reservoir Valves / lampsSwitches PLC OutputsInputs SBPVlv Open pouring valve Open pouring valve PVlv Open valve 1 1 1 2 Vlv1SBVlv1 Open valve 1 2 SBVlv2 Open valve 2 3 SBMtr Start motor 5 Sensors LS0 Level sensor 0 8 LS1 Level sensor 1 9 LS2 Level sensor 2 10 Open valve 2 3 Vlv2 Start motor 5 Mtr MS Motor sensor 11 Open emergency valve 4 EVlvSBEVlv Open emergency valve 4 TS1 6 TS2 Tank sensor 2 7 States / lamps Mixture is proper 6 7 Mixture is spoiled 8 Component 2 in mixture 10 Component 1 in mixture 9 11 MxIsFin MxIsPrp MxIsBad C1InMx C2InMx MtrErr Mixture is finishedTank sensor 1 Motor error Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 8.
    Petri Net 8/12 RyabukhinD. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 9.
    Consistent behaviour ofsensors 9/12 Additional fine-tuning program model for corresponding to the actual behaviour of the PLC programs G( X( S) ⇒ Cond1 ), G( X(¬S) ⇒ Cond1 ). G( ¬S ∧ X( S) ⇒ Cond2 ), G( S ∧ X(¬S) ⇒ Cond2 ). These formulas are written in guard condition of Input transition. Some examples: (not p_TS1 orelse TS1 orelse p_Vlv1), (not p_TS2 orelse TS2 orelse p_Vlv2), (not MS orelse p_Mtr), (LS0 orelse not LS1 andalso not LS2) Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 10.
    Examples of temporalproperties 10/12 “Overspending”. Components will never be added to the spoiled mixture. G(¬(MxIsBad ∧ (Vlv1 ∨ Vlv2))) “Spoiled product”. The spoiled mixture will never be drained through valve “PVlv”. G(¬(MxIsBad ∧ PVlv)) “Spoiled mixture”. Spoiled mixture can not be proper or finished. G(¬(MxIsBad ∧ (MxIsPrp ∨ MxIsFin))) Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 11.
    Conclusion 11/12 CPN Toolsprovides availabilities to: show data flows from input variables to outputs demonstrate dependences between inputs, outputs and program variables visualize possible concurrent blocks modeling resources and timing with tokens make simulation modeling for checking some class of properties Ryabukhin D. A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets
  • 12.
    Thank you! Ryabukhin D.A., Kuzmin E. V., Sokolov V. A. Modeling of PLC programs with High-level Coloured Petri Nets