## 2 Materials and Methods  
As a basis for the newly developed SW tool, the open-source PNEditor was chosen [23]. In this editor it is possible to model systems using basic Petri nets. The software application is implementedin Java. It is released under an open-source license. Its main advantage is well-structured code, clear design and direct support from developers. It also contains the possibility of determining the boundedness of the Petri net and it can inspect P (place) invariants and T (transition) invariants. The disadvantage is that it supports only basic Petri nets. As part of the solution of our research, it was necessary to add a support for timed Petri nets interpreted for control. The developed extension of this tool is called PN2 ARDUINO and was fully tested in [24; 25]. The main aim of the proposed article is to present the developed software for control of discrete-event and hybrid systems verified on laboratory discrete-event and hybrid systems. There are several Petri net-based control concepts. Petri net as a control logic must be connected with the controlled system (e.g., using a microcontroller). One of the main aspects of the control system design is the question whether the Petri net's logic should be stored in the microcontroller or in the personal computer (PC) able to communicate with the microcontroller. Both approaches have their advantages and disadvantages. If the Petri net's logic is stored in the microcontroller, the main advantage is the control unit independence from the software application (program on a PC). The Petri net logic is modeled using a PC, and then the Petri net is translated into a program code which is loaded into the microcontroller. Afterwards, the PC and the microcontroller can be disconnected. Another advantage is the capability of real-time control. Disadvantages include limited computational and memory resources of the microcontroller, need for repeated program compiling and its uploading into the microcontroller (mainly during the development phase). The proposed solution is shown in Figure 1.  
When the Petri net's control logic is stored on a PC in a specialized SW application, it is possible to control the system directly. In the microcontroller, only the program with communication protocol is stored. This communication protocol (in our case Firmata [26]) is used for communication between the PC and the microcontroller. This solution eliminates the necessity of recompiling and reuploading the program during the development. The next advantage is the elimination of restrictions on computing and storage resources because a PC has almost unlimited resources compared with a microcontroller. One of the disadvantages is that the control system cannot respond in real time. The proposed solution is shown in Figure 2. These differences are specified in Table 1.  
Figure 1: Basic scheme of proposed solution—Petri net’s logic in microcontroller. Figure 2: Basic scheme of proposed solution—Petri net’s logic in personal computer (PC). New software module PN2 ARDUINO is based on the second approach (Figure 2) so the Petri net runs on a personal computer. For communication between SW application and microcontroller, the Firmata protocol [26] has been used. Firmata is a protocol designed for communication between a microcontroller and a computer (or a mobile device like a smartphone, tablet, etc.). It is based on MIDI messages [27]. MIDI (musical instrument digital interface) message is made up of 8-bit status byte which is generally followed by 1 or 2 data bytes. Firmata protocol can be implemented in firmware of various microcontrollers; mostly Arduino-family microcontrollers are used. On the PC, a client library is needed. These libraries are available for many languages like Java, Python,.NET, PHP, etc. On the Arduino side, the Standard Firmata 2.3.2 version is used, the client application on the PC is based on Firmata4j 2.3.3 library which is programmed in Java.