# Design of a Four-Axis Robot Arm System Based on Machine Vision
## 3 Vision-Guided Design of the Four-Axis Robotic Arm System
### Robotic Arm Control System Design
#### 3.1.2 Lower Computer Design  
The main functions of the lower computer in the system are:  
1. Communicating with the upper computer through the serial port;
2. Carrying out the inverse operation of the robotic arm to decode the coordinate information sent back from the upper computer into the level signal of the motor control pins to control the movement of the robotic arm to the specified position;
3. Controlling the servo pins to achieve the opening and closing movement of the hand claw, to collect the limit switch signal, and to control the robotic arm to zero. Based on the above functional requirements, the lower computer circuit we designed is mainly composed of Arduino MEGA2560+RAMPS1.4+A4988+stepper. Arduino Mega 2560 is an upgraded version of the Arduino MEGA series. The control board is equipped with an ATmega2560 chip and a 16 M Hz crystal oscillator. There are 54 digital IN/OUT ports, and among these pin ports, 15 can be pulse width modulated (PWM) and output; there are 16 analog signal ports; 4 serial input and output ports; a USB port; and a reset button, etc. Its power supply mode can be a USB power supply or DC port direct input. Its programming method uses the compilation environment that comes with Arduino to realize code writing. A Stepper motor is an electromagnetic actuator that can convert the input digital signal into the rotary motion of its central axis. It has the advantages of easy control, adjustable speed, high motion precision, small motion inertia, and less accumulated error. Widely used in electromechanical integration equipment, the rotation angle of the central axis depends on the number of input pulses, which is positively correlated. At the same time, the rotation speed of the stepper motor can be controlled by changing the input pulse frequency. When selecting and using a stepper motor, it is necessary to consider the speed, torque, and no-load starting frequency:  
1. When selecting a stepper motor, its speed is an important referenced factor because the speed of the motor determines the output torque of the motor. 2. The choice of the torque of the stepping motor. The torque of the stepping motor is mainly determined for the work tasks in different scenarios. Generally speaking, motors with smaller shaft diameters such as 20, 28, and 42 are usually used. In the torque scenario (below 0.8 N-m), 57 stepper motors are more suitable for a medium torque (about 1 N-m), and for larger torques, stepper motors with larger shaft diameters such as 86, 110 should be selected. Given the above stepper motor selection indicators, the project finally decided to use three 2-phase, 4-wire, 42-stepper motors as the power source of the system. The important indicators are in Table 2.  
In the case that the stepper motor has been confirmed to choose a 42-stepper motor, we select the driver based on the following points:  
1. Determine the torque required for the load carried by the motor, and the torque of the selected driver must meet the requirements of the motor. \begin{table}
\begin{tabular}{c c c c c c c} \hline
**Motor Model** & **Body Length (mm)** & **Step Angle (\({}^{\circ}\))** & **Number of Phases (NO.)** & **Rated Voltage (V)** & **Rated Current (A)** & **Moment of Inertia (g cm\({}^{3}\))** \\ \hline B0459 & 47 & 1.8 & 2 & 2.6 & 2.0 & 82 \\ \hline \end{tabular}
\end{table} 
Table 2: The main index parameters of the motor. Determine the rated current of the stepping motor used. Generally, the output current of the driver can be set within a certain range. If the current is too small, the output torque of the motor may be insufficient. The rated current used in this article is 2.0 A. 3. Determine the working voltage of the motor. The output voltage of the driver must be within the range of the motor. The voltage used in this article is 2.6 V.
4. The number of phases must be equal, the motor is two-phase, the step angle is 1.8\({}^{\circ}\), and the driver must be two-phase. The main function of the motor driver is to regulate the subdivision and control the motor.