# A Hands-On Laboratory for Intelligent Control Courses
## 4 Practical Sequence
### Control Loop Construction  
The segment proposes the creation of the control loop illustrated in Figure 1, selecting the power stage, encoder, motor and connections. The motor selected to carry out the project is model f2260 from the Maxon company; its specifications are exposed in Table 4. The motor selected for the application handles a maximum current of 16 A. The power stage must be designed to withstand this intensity. In addition, a 12 V supply voltage is utilized with a model BTS7960B H-bridge. As shown by the characteristics of the motor selected for the project, a maximum current of 16 A is needed to activate the motor. The selection of the power stage should comply with this requirement besides working with 12 V, which is the motor supply voltage. A H-bridge model BTS7960B was selected to satisfy the power needs. It is recommended to employ a commercial circuit already assembled such as the IBT_2 model H-bridge for the Arduino platform, which internally contains the BTS7960B bridge and control components that allow it to have the following characteristics:  
* Operating voltage 5-27 V
* Motor speed control through PWM frequency up to 25 kHz
* Control in both directions of the motor
* Maximum current capacity up to 30 A  
Table 5 presents the connection pins of this H-bridge to the acquisition card. Pins 3 and 4 are always active and pins 5 and 6 are not used. The position of the motor is obtained from an encoder from the Yumo company and the B950 model was selected. Its characteristics are listed below:  
* An operating voltage of 5-24 V of direct current
* A resolution of 1024 PPR
* Z signal that can be easily adjusted
* It has protection against short circuits
* Maximum current consumption of 70 mA
* Three exit signs A, B and Z
* Open collector output configuration \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameters** & **Values** \\ \hline Nominal voltage & 12 V \\ \hline No-load speed & 2220 RPM \\ \hline No-load current & 200 mA \\ \hline Nominal speed \(\omega(t)\) & 1810 RPM \\ \hline Nominal torque \(\tau(t)\) & 276 mNm \\ \hline Nominal current \(i(t)\) & 2.94 A \\ \hline Starting current & 16.6 A \\ \hline Initial torque \((T_{i})\) & 1660 mNm \\ \hline Max. efficiency & 77\% \\ \hline Resistance (R) & 1.44 \(\Omega\) \\ \hline Inductance (L) & 0.56 mH \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Motor characteristics. * Maximum frequency response of 100 kHz
* 20 \(\Omega\) insulation resistance  
As mentioned above, the encoder signals are connected to pins 24 and 26 of the dsPIC that correspond to port B, using the encoder quadrature, which consists of the microcontroller reading both signals A and B from the encoder and, depending on which one is read first, determines the direction of rotation of the motor. The Z signal is not used in this project. In order for the student to interact with the controller results, a Graphical User Interface (GUI) is provided. The GUI files are \"union.fig\" and \"union.mat\", which can be downloaded from [48]. The GUI consists of two main buttons. The \"system behavior\" button displays the buttons to observe the desired value and the real value, the error value and the control signal, as illustrated in Figure 4. Figure 5 exposes how the button of \"fuzzy logic\" allows the student to observe the membership functions for the input and output variables, as well as the rules implemented for the inference engine. Figure 6 shows the complete system and the connections required for the correct operation. Figure 5: GUI screen for fuzzy logic. Figure 6: Complete system required for the project. As shown in Figure 6, it is necessary to utilize a USB-Serial converter for which the model pl2303 of the Ranmex brand was selected. This model has in pins 5 and 4 the supply voltage and ground, respectively. Pin 3 is the transmission (Tx) and it is connected to the reception (Rx) of the DAQ. This converter is responsible for powering the DAQ.