1. Introduction A large area of imported equipment suffered severe damage. After repairs and replacement of a large number of electronic components, its original technical specifications were barely restored. However, its operation was no longer very reliable. Since the equipment was no longer in production and there was no suitable replacement, we invested in the research and development of this equipment to meet production needs. The original equipment was entirely composed of transistor circuits. Considering factors such as development cycle and reliability, we decided to redesign it using PLC (Fx2N-32T) and touch screen (MT506S) control technology. 2. Functional Overview This equipment is essentially a dedicated stepper motor measurement and control device. The stepper motor device consists of a stepper motor and its related circuits. The device's functions include: distance (working steps) setting, start-up, position display and zeroing, (automatic, manual) continuous or single-run operation, (automatic, manual) return to origin, stepper motor undercurrent detection alarm, and origin position display, etc. 3. Device Principle Introduction 3.1 System Working Principle The system working principle is shown in Figure 1. In the diagram, the touchscreen serves as the human-machine interface, used for display and operation; the PLC acts as the controller, receiving the set data from the touchscreen, performing logic processing, and then controlling the stepper motor. The stepper motor is a controlled object and cannot be modified. It includes various power supply forms: the stepper motor operates on a -24V three-phase dual three-beat DC rectangular wave power supply, and also includes signals with different voltages and polarities such as +12V, -12V, and +5V. To match the detection and driving of various signals with the stepper motor, a signal conversion circuit is added. Figure 1 shows the system working principle block diagram. 3.2 Conversion Circuit Principle Part of the signal conversion circuit is shown in Figures 2 and 3. In Figure 2, when a 5V or 0V signal reaches resistor R1, it connects the PLC input signal 1 through the optocoupler. At this time, the motor starts counting and recording the number of steps during its return-to-origin process. When the +12V signal reaches the ±12V signal, LED D6 is lit first, and then PLC input 3 is turned on through optocoupler U1-3, indicating that the origin has been reached, and the motor stops running. When the -12V signal reaches the ±12V signal, PLC input 2 is turned on through optocoupler U1-2, exceeding the set limit. When the -12V signal reaches the -12V signal 2, PLC input is turned on through optocoupler U1-3, indicating that the origin has been reached, and the motor stops running. [align=center] Figure 2 Signal Conversion Circuit[/align] [align=center] Figure 3 Stepper Motor Drive Circuit[/align] 3.3 Current Detection Principle The stepper motor driver has a built-in current detection circuit. When the motor experiences a power outage or undercurrent operation, an alarm signal is issued, causing the system to stop running. The detection principle utilizes the working characteristics of a three-phase double three-step stepper motor, where two phases are energized at any given time. As long as the current flowing through the common ground wire at any time is greater than 2/3 of the corresponding rated current, it is considered to be working normally. If it is less than 2/3 of the corresponding rated current, it is considered to be undercurrent operation. The circuit principle and timing diagram are shown in Figures 3 and 4. In Figure 3, R is the current detection resistor, and C is used to eliminate competition. In Figure 4, IN represents the rated operating current of the three-phase double three-beat motor flowing through the common point current detection resistor; In represents the threshold of the detection current, In=2/3IN; I represents the actual operating current of the motor. ALM represents the undercurrent alarm. After the system is running, when I≥In, ALM alarms until the fault is cleared and the system is reset and the alarm is cleared. The thin solid line in Figure 4 represents the timing diagram when ALM does not alarm. [align=center] Figure 4 Current waveform diagram[/align] 3.4 Software design of touch screen (1) Home: After turning on the power switch, it prompts to enter the login password. After entering the password correctly, it automatically enters the home page. The device enters the preparation state. (2) Input window: The input window is mainly used for setting and operation. Including the keyboard and main operation controls, the operator can directly operate the equipment. (3) Recipe data window: For frequently used operation data, it can be stored in the recipe card memory according to the provided format. When needed, it can be retrieved without temporary data input, which can greatly improve the operation efficiency. (4) Control window: The control window is mainly used for the operation and display of the basic functions of the equipment. It includes a hidden small keyboard window that can pop up when data needs to be set. (5) Component inspection window: Used to monitor the key components inside the PLC so that faults can be found when errors occur. (6) Ladder diagram inspection window: Used for real-time monitoring of the PLC ladder diagram (since the MT506S does not have the function of directly displaying the internal ladder diagram of the PLC, the method of separately creating and displaying each component of the PLC is used to combine the key parts of the ladder diagram). 3.5 PLC software design The PLC program flowchart is shown in Figure 5. After the system is initialized, the distance setting is completed, the running mode is selected, and then check whether the system has a fault or whether it has reached the origin. When fully prepared, automatic or manual operation is performed respectively. During the automatic reciprocating operation at a set distance, when the disconnection operation is performed in the middle, the system maintains the running direction, runs to the set distance, maintains the display, and then stops running; when the reset operation is performed, the system first runs the display to zero (count is cleared), and then stops running. During manual operation, when the set distance is reached, the system maintains the display and stops running; when the disconnection operation is performed during operation, the direction remains unchanged, and after reaching the set distance, the system maintains the display and stops running; when the reset operation is performed, the running display is cleared (count is cleared), and then stops running. [align=center] Figure 5 PLC program flowchart[/align] 4 Conclusion The controller is implemented using a touch screen and PLC, which shortens the development cycle and improves the reliability of operation, especially suitable for the development of equipment that requires short engineering cycle, high reliability, and small batch. In addition, the flexibility of the software is also conducive to the modification and upgrading of the equipment. References [1] "FX2N Series Micro Programmable Controller User Manual" [2] "Easy Builder 500 User Manual" [3] "FX1S FX1N FX2N FX2NC Programming Manual"