The hardware and software design of an economical CNC system directly affects its machining and operational performance. This article introduces some common problems and solutions encountered in the hardware design of economical CNC systems. 1. Function Selection There are several different methods for system function selection. When using a CRT monitor as the display terminal, a function menu can be created, allowing users to select functions. However, to reduce costs, economical CNC systems generally do not use CRT monitors but instead use digital tubes to form the display terminal. In this case, a band switch can be used to form a function selection circuit through a parallel interface. Figure 1 is a schematic diagram of a function selection circuit composed of an 8255 interface circuit and a band switch. Program Editing—Inputting, checking, and modifying the machining program. Parameter Setting—Setting transmission clearance, G00 speed, tool parameters, etc. File Processing—Loading and transferring machining programs, etc. Tool Setting—Manually and automatically detecting tool position and radius parameters and automatically saving them to the system. Manual Processing—Manual feed. Continuous Machining—Continuously executing the machining program. Single-Segment Machining—Executing one segment of the machining program at a time. In the main program after system startup and in subsequent functional programs, the position of the band switch is cyclically detected by the 8255 and the corresponding functional module is entered. 2. Tool Setting Processing The tool setting method used in our designed economical CNC lathe system can achieve both manual and automatic tool setting. The tool setting bar is an insulated round bar of a certain size, with a metal head that is insulated from the machine tool. The tool is grounded through the machine tool. During tool setting, the tool post moves the tool closer to the tool setting bar, and the tool setting signal is sent to the system via PA7 of the 8255. The system receives a high level when the tool tip is not in contact with the tool setting bar, and a low level when the tool tip is in contact with the tool setting bar. After entering the tool setting function, there are three options: manual tool setting, automatic tool setting, and calculation of tool compensation value. In manual tool setting mode, the current tool position number is displayed, and the tool is manually changed using the tool change key on the keyboard. The tool is moved using the arrow keys (horizontal or vertical). When the tool contacts the tool setting bar, the tool movement automatically stops and its distance is saved, waiting for keyboard operation again. When you select to exit manual tool setting, the manual tool setting function will be exited and the main tool setting program will be returned. In automatic tool setting mode, the tool will first start from position 1, and the current tool position number will be displayed. Automatic tool setting is divided into longitudinal tool setting and transverse tool setting. In longitudinal automatic tool setting, the tool starts from the first tool and moves longitudinally until it contacts the tool setting bar, recording the distance traveled. The tool is then returned to its original position and automatically switched to the second tool, moving longitudinally until it contacts the tool setting bar again, recording the distance traveled, until all tools have completed tool setting and the tool travel distance is automatically saved. Transverse automatic tool setting is the same as longitudinal, except the direction of tool movement is different. When you select to exit automatic tool setting, the automatic tool setting function will be exited and the main tool setting program will be returned. Tool compensation calculation calculates the position difference of other tools relative to the first tool after tool setting and stores the calculation result in the system's tool compensation parameter area. 3. Display Processing Most economical CNC systems use digital tube displays. Digital tube displays can be dynamic or static. Dynamic displays use fewer components and have simpler circuitry. The principle is shown in Figure 2. A row of seven-segment tubes has one segment display address and one digit display address. Only one seven-segment tube is shown in the figure. The segment display is used to control the character (character code) to be displayed, and the digit display is used to control which seven-segment tube displays. To make a seven-segment tube display a certain character, first send the character code to be displayed to the segment display address, then set the corresponding bit in the digit display data to 1 (or 0), while the other bits are 0 (or 1), and then send the data to the digit display address. Static display uses more components and has a more complex circuit. Each seven-segment tube has one segment display address but no digit display address. Each seven-segment tube has a latch to latch the data to be displayed. As long as no new data is sent to the seven-segment tube, the displayed content will not disappear. If the displayed data remains unchanged, no display refresh is needed. Only when the data to be displayed changes is it necessary to inject the data to be displayed into the display. Since the system has EPROM (used to store system programs), RAM (used to store processing programs), and interface circuit 8255 (used for input and output), each memory chip must have a certain address range, while the seven-segment tube addresses can be continuous. To solve this problem, a two-stage decoder can be used, and the circuit principle is shown in Figure 3. In the figure, CS1 is the EPROM chip select signal, CS2 is the RAM chip select signal, and CS3, CS4, and CS5 are the 8255 chip select signals. The 3-to-8 decoder is used to handle the display. If the system has multiple rows of seven-segment LED displays, multiple 3-to-8 decoders can be used, with different address lines connected to terminals A, B, and C of the different 3-to-8 decoders.