Programmable Logic Control in Economic CNC Systems
2026-04-06 05:11:49··#1
Abstract: This paper introduces a method for programmable logic control in an economical numerical control system. By adopting a master-slave dual single-chip microprocessor control system, not only scanning control to switching variables is achieved, but also accurate numerical control for machine tool coordinates is ensured. The operating principle, hardware composition, and software design ideas of the system are described . Keywords:programmable logic control; numerical control system; scanning control 1 Introduction Machine tool numerical control systems are generally used to complete motion trajectory control and switching logic control. Currently, most domestic economical numerical control systems focus on motion trajectory control. For machines with a large number of switching points, especially those requiring logic and sequential control (such as dedicated CNC machine tools and combination machine tools), a two-level control structure is typically adopted. This involves using a microcomputer control system to control the motion trajectory and simultaneously serving as the operating platform. The logic control of the machine tool's switching I/O is implemented using a separate programmable logic controller (PLC). In this control method, users often find it inconvenient to use because a significant amount of software and hardware development work is required between the CNC system and the PLC, and both systems need to be programmed separately. Based on the above, this paper introduces a method for implementing logic and sequential control of switching quantities in an economical CNC system, explaining the system's working principle and hardware and software design concepts. 2 Working Principle To implement hybrid control of programmable logic and coordinate position, the system design mainly considers the following aspects: 1) It should possess the characteristics of a PLC system for sequential control of various switching quantities and the characteristics of an NC system for digital control of actuators. 2) How to coordinate the synchronous control of the two control modules. 3) Solving the problem of mixed programming of the two types of control instructions. In the CNC system of the machine tool introduced in this paper, motion trajectory control and programmable logic control are completed by two independent modules. The PLC module, as the main control module of the CNC system, is used to complete the system management and logic control of switching quantities. The motion control (MNC) module, as the auxiliary control module, is used to complete the two-axis linkage control of the stepper motor. The system is a master-slave control structure with two single-chip microcomputers working in parallel. The purpose of adopting the dual CPU structure is to give the MNC module sufficient time to complete the trajectory control and coordinate display management. The PLC main control module and the MNC auxiliary control module coordinate control through serial communication. The system works in continuous scanning mode and completes the control task according to the following steps: (1) Send the status of the machine tool switching input signal to the internal image register; (2) According to the storage order of the user program, interpret and execute the instructions one by one, generate corresponding control signals to control the relevant circuits, complete the data storage, transmission and processing, and update the contents of the relevant registers according to the calculation results. When the motion control conditions are met, call the sending subroutine to send the instructions to the MNC module and set the corresponding flags. After the MNc module completes the specified control task, it sends back the status flag through the serial port and changes the status of the internal register. (3) The contents of the output image register are sent to the interface circuit to control the external load. The software WDT implemented by the hardware WDT circuit and the microcontroller's internal timer T2 together form the program running monitoring system to ensure the normal operation of the scan control. 3 System Structure The system structure block diagram is shown in Figure 1. It consists of an 8032 microcontroller, memory, keyboard and interface circuit, power-down protection circuit, switch I/O interface circuit, WDT circuit and MNC control circuit. The system clocks of the 8032 microcontroller and the 8031 microcontroller in the MNC control module are both provided by an external common crystal oscillator, so that the two work in a consistent manner, providing a reliable physical guarantee for high-speed data transmission between the two machines. The system software is stored in a 27512, and the user program and data are stored in two 6264 static RAMs (one of which has a power-down protection circuit and a backup battery). 52 editing keys and 7 working mode selection keys are managed by one 8279, and P1 port is used to detect the status of 4 direction keys, start key and pause key. Considering that the control object of the economical CNC system is mainly a single device, the basic configuration of switch I/O is 32 inputs and 32 outputs, and the interface circuit is composed of 3 8255 chips. The hardware WDT circuit is composed of 555 oscillator and 74LS393. The MNC control module can complete the stepper motor motion control of two coordinates according to the given control instructions. It uses a photoelectric sensor as the detection element, the actual displacement of the worktable as the feedback signal, and uses a digital regulator for closed-loop control [1]. The module has an 8-bit star-shaped LED display for displaying data during program compilation and processing. [b]4 Software Design 4.1 Arrangement of Internal Relays[/b] The status of input/output relays, intermediate relays and flags and pointers in PLC control instructions are arranged in the internal RAM of the 8032 microcontroller to maximize the use of its bit addressing area. The relay status is stored using a bit-by-bit correspondence method, with one byte corresponding to the status of 8 points. For timers, counters, and shift registers, in addition to their corresponding internal relays, they also occupy a byte working unit and a flag status register. 1) Timers/Counters: Timers/counters are all 16 bits, occupying two working units. Each timer/counter has a signal status bit and three flag bits: timer/counter flag, timer start flag, and timeout flag, all arranged in the timer/counter flag register. The 1ms internal timing pulse required by the timer/counter is generated by the 8032 internal timer T0. 2) Shift Registers: Shift registers are grouped into 8 groups of 8 points each, for a total of 8 groups. Each group of shift registers corresponds to a CP status flag bit, used to retain the input clock status of the previous scan cycle. When two or more groups of shift registers are used together, the storage location of the CP status is determined by the starting relay number of the shift register. 3) Differentiator: In order to distinguish the input status of two adjacent scan cycles, each differentiating relay has an output status bit and an input status flag bit, used to store the status of the input signal in the previous scan cycle. 4.2 Input State Discrimination Distinguishing changes in the state of switching signals is crucial for PLC control. During counting, signal edge differentiation, and shifting operations, the program execution method needs to be determined based on the timing changes of the switching signals. Except for falling-edge differentiation instructions, the other cases require operation on the rising edge of the input signal (Figure 1: Control System Structure Block Diagram). Therefore, for counting, differentiation, and shifting operations, the clock state of the previous scan cycle is stored in a dedicated register, corresponding to the relay number. The change in the CP state between two scan cycles determines whether to execute the function specified by the instruction. 4.3 Numerical Control Instruction Conversion Hybrid programming is an important feature of this design. PLCs have their own programming language, often using ladder diagram programming and statement list input. Numerical control (NC) systems also have their own programming languages, widely using ISO standard codes. Considering the usage habits of both systems, when processing stroke instructions, the NC language is treated as a subset of the PLC instruction system. Each NC instruction can be represented by a dedicated graphic symbol, and the instruction mnemonic of the ISO standard code is embedded in the PLC instruction mnemonic and input together [sup][2][/sup]. 4.4 Data Communication Method Data communication method is key to coordinating logic control and trajectory control. Bidirectional data communication is completed through the serial ports of the microcontrollers in the two hardware modules. The serial port operates in mode 3, using a polling-based sending and interrupt-based receiving mode. In software design, the PLC module treats the communication port as a switch input/output port, with corresponding communication flags in the communication flag register. When a NC instruction needs to be executed, the sending subroutine is called to complete the transmission of control data. The communication data format of the NC instruction is: The operating mode control word determines the mode in which the instruction is executed, such as edit, automatic, dry run, return to zero, manual mode, etc. The instruction feature word is the code of the instruction, which determines the form of the stepper motor's movement. The control parameters are the motion coordinate values and speed of the instruction. For different control instructions, the parameters can be omitted. For example, the linear interpolation instruction requires the absolute (or relative) coordinate values and speed in the XZ direction; while the fast return to origin instruction does not require any parameters. The accumulation and check code are provided to the receiver for verification, based on which to determine whether a reception error has occurred. 4.5 Software Structure The PLC main control module system software consists of a monitoring program, an editing and compiling program, a switch logic control program, an instruction module program, an interrupt program, and a data transmission program. 1) Monitoring Program The monitoring program implements the operation management of the system, including system initialization and receiving operation commands from the keyboard and executing them; detecting some switches and buttons on the system panel and setting corresponding flags; scheduling the various application modules of the system. 2) Editing and Compiling Program The editing program allows users to input, edit, and modify the processing program. The compiling program converts the user program input in the form of text symbols into machine code, and judges the correctness of the input statements and provides prompts during the assembly process. 3) After the switch logic control program enters the automatic running state, the CPU repeatedly checks whether there is an input signal for the start button. When there is a start input signal, the system executes the switch logic control function. The execution of the user program is carried out in a scanning manner. Each scanning cycle is divided into three stages: input sampling (or processing), logic relationship processing, and output refresh (or processing). The final result of logic processing is sent to the output latch only when the end flag END appears. As long as there is no signal input to stop working, the program turns to input scanning and repeats. The flowchart of the switch logic control program is shown in Figure 2. 5 Conclusion The hybrid control mode is adopted. Through the dual single-chip microcomputer control system with master-slave structure, the scanning control of logic variables is realized while ensuring the precise digital control of machine tool coordinates. This method has been successfully applied to the PCNC-1 economic CNC system and has been applied in production practice. It has achieved good results in the machining of diesel engine block process positioning holes and piston oil ring groove bottom surface oil holes, improving machining accuracy and work efficiency compared with the original production process. [References] [1] Wang Wenxi, Wang Yulin, et al. Economic Distributed Control Technology for Machine Tools. Machine Tools. 1993(9):34-36 [2] Wang Wenxi. Programmable Logic Control in Distributed Control of Single-Chip Microcomputer. Mechanical and Electrical Engineering, 2000(1):27-29 Author's Profile: Xi Qin (1962-), male. From Jiamusi, Heilongjiang Province, Professor of Taihe Institute of Technology, doctoral student. Programmable Logic Control in Economic CNC Systems: PDF