## 3 PLC Production Line Signal and IoT Connection
### Smart Robot Control and Visual Recognition
#### 3.4.1 Robot Motor Control with FOPID  
This study aimed to establish camera vision with a neural algorithm for image recognition, combined with the joint module of the robotic arm, to control the motor with a power feedback method. This method included two sequential processes. First, the CNN was used for image recognition to apply the output control of the signal. Second, it estimated the external torque of each joint \(\tau\) and used the feedback signal for the identification and detection processes. In addition, an AI method was constructed to control the motor. The position and speed control method was based on the detection results after deep learning. To evaluate the performance of self-detection, each joint of the motor was regulated by an external force. Two performance indicators were introduced to represent safety and efficiency. The control signal was sent to the cloud system for valuable collection and observation. The design and structure of the neural network used for motor control are shown in Figure 5. Momentum-based observers were therefore widely used to estimate the torque of the external joints (the joint refers to the motor signal being measured) using the kinetic energy method. For an n degrees-of-freedom rigid-body, the dynamic equations are as follows:  
\[\mathrm{M(q)}\ddot{q}+C\big{(}q,\dot{q}\big{)}\dot{q}+g(q)=\tau_{m}+\tau_{external} \tag{7}\]  
where \(\mathrm{M(q)}\in R^{n\times n}\) is the inertia matrix, \(C\big{(}q,\dot{q}\big{)}\dot{q}\in R^{n}\) is the vector of Coriolis and centripetal torque, and \(g(q)\in R\) is the gravitational vector, \(\tau_{m}\) is the control torque, \(\tau_{external}\) is the external torque. The position control applied to the model is expressed as follows:  
\[\tau_{m}=\hat{M}(\mathrm{q})\ddot{q_{r}}+\hat{C}\big{(}q,\dot{q}\big{)}\dot{q_ {r}}+\hat{g}(q)+\tau_{reference} \tag{8}\]  
The parameters of the \(\hat{M}\), \(\hat{C}\) and \(\hat{g}\) are marked as nominal model, \(\dot{q_{r}}=\dot{q}+K_{p}+K_{l}\int edt\) represents the reference trajectory, \(e=q_{d}-q\) is the position error, and \(q_{d}\) represents the required trajectory, and \(\tau_{reference}\) is the control input, which is defined as follows:  
\[\tau_{reference}=-\bigg{(}K+\frac{1}{r^{2}}\bigg{)}\bigg{(}\dot{e}+K_{pe}+K_{ l}\int edt\bigg{)} \tag{9}\]  
where \(r>0\), and \(K,K_{p}\) and \(K_{i}>0\) in the PID controller are symmetric gain matrices and satisfy \(K_{p}^{2}>2K_{i}\). The following observers are designed to evaluate the external torque as follows:  
\[\dot{\tau}_{external}=L\bigg{(}-p_{e}(t)+p_{e}(0)+\int_{0}^{t}\Big{(}s_{e}(t) -\tau_{ref.}\Big{)}ds\bigg{)} \tag{10}\]  
Figure 5: The neural network’s design and structure for motor control. where \(p_{e}=\tilde{M}(\text{q})\dot{e}_{r}\), \(s_{e}=-\tau_{reference}+\hat{C}(q,\dot{q})\dot{e}_{r}\) and \(\dot{e}_{r}=\dot{q}_{r}-\dot{q}\), so the dynamic equation of the observer is rewritten as  
\[\dot{\tau}_{external}=L\Big{(}-\dot{\tau}_{external}+\tau_{external}\Big{)}-L (\widetilde{Mq}+\widetilde{C}\dot{q}+\widetilde{g}\Big{)} \tag{11}\]  
Among them, \(\widetilde{M}=M-\tilde{M}_{r},\widetilde{C}=C-\hat{C},\dot{g}=g-\dot{g}\) and \(\dot{\tau}_{external}\) refers to the sum of \(\tau_{external}\) and \(\tau_{\text{d}}\). This is the recognition program constructed by the XML model, as shown in Table 2. Then, the neural network as image recognition results can be applied to the motor control of the robotic manipulator. This follows the design of a basic proportional-integral-derivative (PID) controller that is used to perform the work piece clamping work of the motor on the production line. This part can replace a manual configuration. At the same time, the visual monitoring of a lights-out smart factory can greatly improve the efficiency and reduce the total cost of the factory in terms of the workforce, and meet faster production delivery requirements. Therefore, to load the image for face detection, it must be performed as before. First, the image must be converted into a grey image.