# Low-Cost Implementation of an Adaptive Neural Network Controller for a Drive with an Elastic Shaft
## 4 Low-Cost Implementation of the Control Algorithm
In order to allow operation in the torque mode, some changes in the default configuration were essential. Then, the signal from Discovery's analog output can be sent to the MENTOR drive. Safety features are built-in; tripping occurs when overspeed/overcurrent, overheating of the motor, or incorrect configuration (for instance, a wrong number of pulses per revolution of the installed encoder) is detected. The final configuration can be sent to the drive and saved in its memory for later use. The STMStudio software was used for data acquisition. Variables from the generated code can be imported to the project as read-only to show the desired variables (e.g., speed of the load) or as a read/write--to change the value of the reference speed or to drive the corresponding relay. Data are then plotted in real-time. In the end, a *.txt file is generated. The file can later be imported to Matlab to plot the acquired transient. Figure 16 presents the transient of the rotational speed of the load machine obtained from the experimental verification of the proposed control structure. The speed follows the reference trajectory with high precision. The response is dynamic and there is no overshoot. \begin{table}
\begin{tabular}{l l l} \hline \hline
**Parameter** & **Discovery Board** & **dSpace DS1103** \\ \hline Microprocessor & Single-core CortexM4F @ 168 MHz & Single-core PowerPC 750 GX @ 1 GHz \\ RAM size & 192 kB & 32 MB \\ Analog-to-Digital converter & 3 \(\times\) 12 bit & 16 \(\times\) 16 bit \\ Digital-to-Analog converter & 2 \(\times\) 12 bit & 8 \(\times\) 16 bit \\ Serial port & 4 \(\times\) UART & 1 \(\times\) UART \\ GPIO ports & 75 & 32 \\ Timers & 12 \(\times\) 16 bit + 2 \(\times\) 32 bit & 2 \(\times\) 32 bit + 1 \(\times\) 64 bit \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison of the chosen parameters of the laboratory hardware and the low-cost board. Figure 16: Rotational speed of the load machine achieved with the proposed control structure—experimental results. Figure 15: CTSoft application for Apator MENTOR. The trapezoidal reference signal is often used in industrial applications to ensure the safety of operation. Because of that, it is the default setting for the MENTOR power electronics controller. Therefore, it was decided that the test would be conducted under these conditions. The verification of the control structure with a more demanding reference signal, such as a square wave, will be considered to be a relevant point for future research. The adaptation process can be observed through the transients of weights of the neural network. The changes are presented in Figure 17. The weights started with values randomly selected from a range of \((0,0.1]\) and managed to significantly increase their value over the period of the experiment. Greater growth (compared to the numerical tests) is expected because of the speed being expressed in rpms (unlike the numerical tests, where the angular speed is expressed in per-unit notation). The drive was also tested for different values of the speed set point. The results are shown in Figure 18. In all the cases, the proposed control scheme manages to follow the reference signal. A great finding is that the structure operates correctly even for lower speed values. Usually, because of less frequent rotations, the fan placed on the shaft of the motor does not manage to cool the machine efficiently enough. The increase in armature winding temperature causes an increase in its resistance, thus changing the parameters of the plant. The control structure manages to withstand those changes and continues to precisely follow the reference signal. Figure 17: Transients of the RBFNN weights—experimental results.