# A Program Model of Fuzzy Interpreted Petri Net to Control Discrete Event Systems
## 3 The Formal Basis and the Conception of FIPN
### Algorithm of the Program Generation Based on FIPN
Appendix A presents the part of the program created as a declaration of variables, and Appendix B shows the part of the program that is executed repeatedly in the cycles of PLC. Both parts are created based on the net from Figure 5.

## 6 Conclusions

In this paper, the formal description of the PLC program based on FIPN and the method to create this program are proposed. Additionally, the formal basis and conception of using FIPN, the creation of an exemplary diagram based on FIPN in FIPN-SML and the automatic code generation for this diagram are shown. The code generated is in the ST language and can be applied to PLC at low cost and with little effort. The presented approach also allows for a significant reduction of the program implementation time to control DES. The work of the control system can be better visualized using analogue sensors in comparison to the discrete PNs. The application of FIPN allows resources to be modelled by the structure of the net, offers software tool support, and provides automatic generation of executable code. An additional advantage of the formal description presented in this paper is its generality. The proposed formalism does not limit the solution only to the ST language or other languages from IEC 61131:2013, but it provides the opportunity to use it beyond the PLC area. However, some functionalities still need improvement. Apart from modularity, which is the subject of an author's article considered in another journal, the authors will: extend automatic code generation to other languages supported by the IEC 61131-3; add to the FIPN-SML a component that

Figure 5: View of exemplary FIPN. automatically investigates properties of FIPN; and extend the generated PLC program in regard to the diagnostic module based on [52]. **Author Contributions:** [PERSON] and [PERSON] prepared the conception and the formal description of the proposed solution; they both made the literature review; [PERSON] implemented the proposed solution in FIPN-SML. **Conflicts of Interest:** The author declares there to be no conflict of interest. ## Appendix A

The part of the program created as a declaration of variables which is generated based on the net from Figure 5:

**PROGRAM MAIN VAR**

_(*Marking*)_

ml:REAL:=1;

m2:REAL:=1;

m3:REAL:=1;

m4:REAL:=0;

m5:REAL:=0;

_(*New marking*)_

mn1:REAL:=1;

mn2:REAL:=1;

mn3:REAL:=1;

mn4:REAL:=0;

mn5:REAL:=0;

_(*Capacity*)_

k1:REAL:=1;

k2:REAL:=2;

k3:REAL:=1;

k4:REAL:=1;

_(*Line weight*)_

p1_t1:REAL:=1;

p2_t1:REAL:=1;

p3_t2:REAL:=1;

t2_p5:REAL:=1;

t1_p4:REAL:=1;

p2_t2:REAL:=1;

_(*Active transition*)_

a1:800L:=FALSE;

a2:800L:=FALSE;

_(*Tet*)_

tet1:REAL:=0.0;

tet2:REAL:=0.0;

_(*Dtet*)_

dtet1:REAL:=0.0;

dtet2:REAL:=1.0;

_(*Output signal*)_

01:800L:=TRUE;

02:800L:=FALSE;

03:800L:=FALSE;04:B00L:=TRUE; (*Input signal*)  IN1:REAL; END_VAR

## Appendix B

The part of the program that is executed repeatedly in the cycles of PLC and generated based on the net from Figure 5:

_(*Checking sensors*)_

det1:=CalcDet (tet1, IN1);

_(*Checking active transition*)_

al:=LAIn (al, m1, tet1) AND AIn2 (al, m1, p1_t1, k1, m2, p2_t1, k2) AND AOut1 (al, m4, t1_p4, k4);

a2:=LAIn (a2, m3, tet2) AND AIn2 (a2, m3, p3_t2, k3, m2, p2_t2, k2) AND AOut1 (a2, m5, t2_p5, k5) AND LC(a2, (m1<1)); _(*New marking*)_

InMn2 (al, dtet1, mm1, p1_t1, k1, mn2, p2_t1, k2);

OutMn1 (al, tet1, dtet1, mn4, t1_p4, k4);

InMn2 (a2, dtet2, mm3, p3_t2, k3, mn2, p2_t2, k2);

OutMn1 (a2, tet2, dtet2, mn5, t2_p5, k5);

_(*On Marking Changed*)_

Mchg2 (m1, mn1, 01, TRUE, 02, FALSE);

Mchg0 (m2, mn2);

Mchg1 (m3, mn3, 04, TRUE);

Mchg2 (m4, mn4, 01, FALSE, 02, TRUE);

Mchg2 (m5, mn5, 04, FALSE, 03, TRUE);

## References

* (1) [PERSON]; [PERSON] Finitely recursive process models for discrete event systems. _IEEE Trans. Autom. Control_**1988**, 33, 626-639. [CrossRef]
* (2) [PERSON]; [PERSON] The control of discrete event systems. _Proc. IEEE_**1989**, 77, 81-98. [CrossRef]
* (3) [PERSON]; [PERSON] Analysis and control of discrete event systems represented by Petri nets.