## 3 Results
### Case Study: Control of Laboratory Hybrid System  
To verify the proposed software tool for hybrid systems control it was necessary to find an appropriate laboratory model. A DC motor with encoder was chosen; its parameters are in Table 2. An incremental encoder is used to measure speed for the feedback. The measured speed of the DC is the process value. The DC motor was connected to Arduino Uno using a motor shield module based on dual full bridge driver L298. Using the motor shield, it is possible to independently control speed and direction of rotation of the DC motor. For speed measurement the hardware interruptions functionality of Arduino Uno has been used. The speed of the motor is set by a pin denoted \"PWM A\". When the input is set to \"PWM = 255\" the Arduino program shows 186 rpm which approximately corresponds with parameters as stated by the manufacturer. Figure 11: Reachability graph. Figure 10: Petri Net for fire alarm (\(t_{2}\) is fired). The next step was measurement of the steady state I/O characteristics. The input (armature) voltage ranges from 0 V to 5 V which corresponds to a PWM signal from 0 to 255 (8-bit resolution), the sampling period was chosen--0.05 s.  
The resulting steady state I/O characteristics is in Figure 12.  
To be able to use linear dynamic models, the working points had to be chosen from linear parts of the I/O characteristics Two working points have been chosen (\(u_{P_{1}}\),\(y_{P_{1}}\)) and (\(u_{P_{2}}\),\(y_{P_{2}}\)) where:  
\[u_{P_{1}}=80\to y_{P_{1}}=140\;\text{rpm} \tag{1}\]  
\[u_{P_{2}}=170\to y_{P_{2}}=174\;\text{rpm} \tag{2}\] \begin{table}
\begin{tabular}{l c} \hline \hline
**Actuators Conditions** & \\ \hline Rated voltage & 6.0 V (DC) \\ \hline Temperature range & \(-20\;\text{\textdegree C}\rightarrow+60\;\text{\textdegree C}\) \\ \hline Humidity range & 0–90\% \\ \hline
**No-load characteristics** & \\ \hline No-load current & \(\leq\)200 mA \\ \hline No-load speed & \(185\pm 10\%\) rpm \\ \hline
**Load characteristics** & \\ \hline Rated load & 0.0883 N \(\cdot\) m \\ \hline Rated current & \(\leq\)550 mA \\ \hline Rated speed & \(135\pm 10\%\) rpm \\ \hline Starting torque & 0.4413 N \(\cdot\) m \\ \hline Locked-rotor current & \(\geq\)2.0 A \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Specification of DC motor. Figure 12: Steady state I/O characteristics of DC motor. Since the controller has been designed for a real system (fast dynamics, large noise, uncertainties), the controller parameters were tuned using practice-oriented design methods. The designed PID controller was implemented using the Arduino PID Library--[28]. Creation of a PID class object has the following syntax:  
PID (&Input, &Output, &Setpoint, Kp, Ki, Kd, Direction)  
* Input: controlled variable (double), rpm of the motor
* Output: control variable (double), in this case input voltage--PWM (0-255)
* Setpoint: setpoint (double), desired rpm of the motor
* Kp, Ki, Kd: tuning parameters (double)=0
* Direction: Either DIRECT or REVERSE--determines which direction the output will move when faced with a given error. The closed-loop scheme is in Figure 13. The monotype font was used for variables names in the Arduino program. The Setpoint is the desired speed (rpm). Due to the used data type in the Arduino program (long), multiples of ten of the setpoint are used. Using an extra order enables us to deal with an equivalent of a number with one decimal place. Output is the control variable ranging between 0 and 255 (8 bits) corresponding to the input voltage between 0 V and 5 V (PWM 0-255). Experiments showed that designing an effective PID controller for higher speeds (2 nd working point: \(\omega=176\) rpm) is not complicated. A satisfactory control performance can be achieved by tuning individual PID controller parameters. \[G_{R}=P+\frac{I}{s}+Ds \tag{3}\]  
However, it was not so easy to design an effective controller in the 1 st working point (\(\omega=140\) rpm); mostly, the closed-loop system was not stable. Hence, lower P and I values had to be used.