Motion control systems have been widely used in industrial control. In recent years, industrial control has placed increasingly higher demands on motion control systems. Traditional PC-based and low-end microcontrollers have increasingly revealed problems such as high cost, high power consumption, and low reliability, and can no longer meet the requirements of modern manufacturing. With the increasing maturity of embedded technology, embedded motion controllers have begun to show their potential. ARM-based microprocessors, with their small size, low cost, and low power consumption, determine their promising development prospects in the field of motion control.
The PCL6045BL is a new type of dedicated DSP motion control chip with powerful data processing capabilities and high operating speed, enabling high-precision multi-axis servo control. To address the urgent need in precision manufacturing for low-cost, highly portable, and general-purpose multi-axis CNC systems, this paper presents an embedded four-axis motion controller based on the ARM microprocessor S3C2440 and the PCL6045BL DSP motion control chip. This motion controller features high performance, low cost, small size, and independent operation, meeting the high-speed and high-precision requirements of motion control systems. It can be widely used in industrial control fields such as engraving machines, robots, embroidery machines, and CNC machining.
To address the urgent need for low-cost, highly portable, and general-purpose multi-axis CNC systems in precision manufacturing, an embedded four-axis motion controller based on the ARM microprocessor S3C2440 and the dedicated DSP motion control chip PCL65045BL is presented. In terms of hardware, the controller adopts a master-slave dual-CPU structure of ARM+DSP, combining the advantages of ARM in human-machine interface display and communication interface with the high control precision of the PCL6045BL. In terms of software, the μC/OS-II real-time operating system is ported to the S3C2440 to manage the motion control system. This control system has strong versatility and can be widely used in industrial control fields such as engraving machines, robots, embroidery machines, and CNC machining.
1 System Overall Design
An embedded four-axis motion controller mainly consists of hardware and software components.
The hardware mainly consists of two parts: the S3C2440 embedded main control board and the PCL6045BL motion control board . The S3C2440 embedded main control board and the PCL6045BL motion control board are connected via a common IDE communication interface.
On the software side, the S3C2440 real-time embedded operating system was ported to the hardware platform, and the BootLoader, peripheral drivers, and motion control system application were designed. Using the aforementioned hardware and software platform, the embedded motion controller can achieve the requirements of good openness and high precision. The structure of this embedded four-axis motion controller is shown in Figure 1.
Figure 1. Composition of the embedded four-axis motion controller
ARM processors offer a rich set of on-chip peripheral circuits, such as USB interfaces, IIS interfaces, and LCD controllers, providing greater capabilities in human-machine interface display, communication interfaces, and system porting. The PCL6045BL motion control chip boasts high speed, high reliability, and excellent performance, offering significant advantages in motion control.
The real-time operating system μC/OS-II includes a real-time kernel, task management, time management, inter-task communication and synchronization, and memory management. It allows each task to work independently without interference, easily achieving timely and error-free execution. This simplifies the design and expansion of real-time applications, greatly reducing the application design process. Applying the advantages of the S3C2440 processor, PCL6045BL, and μC/OS-II to this embedded four-axis motion controller enables it to possess powerful functionality while shortening development time.
This embedded four-axis motion controller uses the S3C2440 as the main control platform. The μC/OS-II real-time operating system is ported to the ARM architecture for human-machine interface display, I/O management, inter-task communication, and instruction compilation. The PCL6045BL motion control module is primarily responsible for position control, interpolation drive, and speed control. User commands are compiled using the S3C2440 instruction compiler and communicate with the PCL6045BL via a dedicated communication interface to control the DSP motion control chip to send pulses, thereby enabling the servo motor to run at high speed.
2 System Hardware Design
2.1 System Hardware Platform Design
In the control system, the S3C2440 processor is the main control core and the PCL6045BL motion control chip is the slave CPU. The embedded motion controller structure is shown in Figure 2.
Figure 2 System Hardware
The S3C2440 is a 16/32-bit ARM920TRISC processor that implements an MMU, AMBA bus, and independent 16KB instruction and 16KB data Harvard caches, each with an 8-word pipeline. The S3C2440 provides comprehensive, general-purpose on-chip peripherals, eliminating the need for additional configuration components.
The PCL6045BL motion control chip, manufactured by NPM, is a CMOS large-scale integrated chip that receives CPU commands via a bus and generates pulses to control stepper motors or pulse-driven servo motors. It provides various output motion control functions, including continuous, fixed-length, and homing output modes. The PCL6045BL can perform 2- to 4-axis linear interpolation and arbitrary two-axis circular interpolation.
Based on this master-slave architecture, the master CPU S3C2440 is primarily responsible for data storage, human-machine interface display, network communication, and other management tasks. Pulses output from the CPU PCL6045BL are sent to the servo drives of the four axes. The S3C2440 can achieve various control functions simply by sending simple commands to the PCL6045BL.
2.2 Connection between ARM and PCL6045BL
Communication between the PCL6045BL and the ARM is achieved by reading and writing several addresses on the I/O bus to transfer instructions and data. The internal register address of each axis of the PCL6045BL is determined by the address lines A0, A1, and A2, while its control address range is selected by input terminals A3 and A4. Therefore, in this master-slave architecture design, the connection between the ARM and the PCL6045BL is shown in Figure 3.
Figure 3 shows the interface circuit between PCL6045BL and S3C2440.
2.3 I/O Interface Circuit
The embedded four-axis motion controller is connected to the servo motor via an I/O interface circuit. The main tasks of the I/O interface circuit are to perform opto-isolation of the input signals and drive the output pulses. In this design, optocouplers are used to isolate the PCL6045BL chip from the subsequent servo motor driver and other control feedback circuits. Because the input and output of the optocoupler are mutually isolated, and the electrical signal transmission is unidirectional, it has good electrical insulation and anti-interference capabilities. Furthermore, since the input of the optocoupler is a current-driven low-impedance component, it has strong common-mode rejection capability. Isolating both the output signals (such as CP, CW, etc.) and input signals (such as alarms, limit switches, etc.) of the PCL6045BL from the PCL6045BL using optocouplers effectively prevents interference signals from entering the main chip and damaging the PCL6045BL.
3 Software Design
The system software consists of the μC/OS-II real-time embedded operating system and related application software. The μC/OS-II real-time embedded operating system only provides a real-time kernel for task scheduling. Therefore, a series of device drivers, API functions, and applications related to system operation need to be developed independently to extend μC/OS-II into a complete and practical real-time operating system.
3.1 BootLoader Design
In embedded systems, there is typically no firmware program like the BIOS. Therefore, the entire system loading and booting task is handled entirely by the BootLoader. The BootLoader is the first piece of code to run after the system is powered on. It is responsible for initializing the system and starting the operating system, much like a program on a PC. The BootLoader initializes hardware devices, establishes a memory space mapping, and prepares the correct environment for the final call to the operating system kernel.
The BootLoader is divided into two parts: Phase 1 and Phase 2. Processing tasks closely related to the CPU core and storage devices are usually placed in Phase 1 and can be implemented using assembly language; while Phase 2 is usually implemented using C language to implement general processes and some driver support for the board level.
Phase 1 primarily involves defining the entry point, setting interrupt vectors, configuring system registers, and initializing registers. Phase 2 mainly involves calling initialization functions, initializing flash memory devices, and initializing memory allocation functions. The BootLoader is the first step in embedded system software development, tightly integrating the real-time operating system and hardware platform, making it particularly important for embedded system software development.
3.2 μC/OS-II porting to S3132440
The embedded real-time operating system μC/OS-II is an open-source, multi-tasking real-time operating system kernel that simplifies application software design and ensures the real-time performance of control systems. Good multi-tasking design contributes to improved stability and reliability of the control system. Porting refers to modifying the source code of the operating system kernel and processor-related parts to enable a real-time kernel to run on a microprocessor or microcontroller. The μC/OS-II file system structure includes the core code, configuration code, and processor-related code, as shown in Figure 4. The processor-related code includes three files: OS_CPU.H, OS_CPU.A.ASM, and OS_CPU.C.C. Porting μC/OS-II to the S3C2440 only requires modifying the processor-related code.
Figure 4. File system structure of μC/OS-II
3.3 System Application Design
The design process for real-time applications involves dividing the problem into multiple subtasks, each part of the system, assigned a priority, and with its own set of CPU registers and stack space. A task, also called a thread, is a simple program that can consider the CPU to belong entirely to itself. In this design, tasks are divided into human-machine interface design, CNC instruction compilation and interpretation, servo unit data acquisition, and status monitoring. μC/OS-II can start each task according to priority and handle task scheduling through the kernel. The basic system flow is shown in Figure 5.
Figure 5 User Program Flow
The S3C2440 interprets the instructions based on the system's application program, calls the motion control function, and then the PCL6045BL sends pulses to control the servo motor to control the actuator's movement, thus achieving the motion control result.
3.4 NC Code Explanation
The motion controller receives machining files from the host computer, but the machining file instructions cannot be directly recognized in the program; they must be parsed and decoded before execution. The main function of the interpreter is to process the user program in program segments, converting the contour information, running speed, and auxiliary function information in the program into a format that the embedded motion controller can execute. The interpretation process mainly includes reading the CNC file, lexical analysis, syntax analysis, and the processing information storage data structure, as shown in Figure 6.
Figure 6 Program processing flow
4 Case Studies
The host computer connects to the S3C2440 via an RS485 bus, inputting NC instruction files into the ARM processor. After passing through the NC code interpreter, these instructions are converted into code recognizable by the PCL6045BL, thus completing the specified motion control functions. The following machining program is written using NC code:
N001COOX15Y25 // Starting point selected
N002G18//XY Plane Selection
N003G90G01X15Y5//Preparing for linear interpolation
N004X30Y5//(15,5) to (30,5)
N005X30Y15 // Proceed to point (30, 15)
N006X45Y15 // Proceed to point (45, 15)
N007X45Y5 // Proceed to point (45, 5)
N008X60Y5 // Proceed to point (60, 5)
N009X60Y25 // Proceed to point (60, 25)
N010X15Y25 // Return to the starting point (15, 25)
The code provided above can be used to perform linear interpolation between multiple points, as shown in Figure 7.
Figure 7. Motion trajectory of multi-segment linear interpolation
5 Conclusion
The hardware structure of this motion controller is based on the S3C2440 microprocessor and the PCL6045BL motion control chip. It effectively leverages the advantages of the ARM processor's high performance and low cost, as well as the motion control chip's high reliability and short development cycle. Porting the μC/OS-II real-time operating system to the controller hardware platform simplifies the overall software system structure and makes it clear, while also meeting the real-time requirements of motion control.