Development of a motion control card based on PCI 9052
2026-04-06 05:13:33··#1
Abstract: This article briefly introduces the main features, structure, and special functions of the PCI9052 slave mode interface chip, and illustrates its typical application in a motion control card through an example. Specifically, it covers the implementation principle of the motion control card, the design of the hardware circuit, driver, function library, and user interface, and its anti-interference measures . Keywords: PCI bus; PCI interface chip 9052; motion control card I: Introduction Currently, foreign technologies related to motion control are relatively mature, and their research mainly focuses on improving the flexibility, integrability, and standardization of motion controllers. Compared with foreign countries, China's research and development in the field of motion control started later, and domestic products in this area still have many problems in terms of stability, reliability, and practicality. Therefore, developing a low-cost, powerful, and stable motion control card has good application prospects. II: PCI Bus Interface Chip PCI9052 The PCI bus is an advanced, high-performance 32/64-bit address and data multiplexing local bus that can simultaneously support multiple peripheral devices. It features high data transfer rate, plug-and-play functionality, low power consumption, and strong adaptability. Generally, there are two main methods to implement the PCI bus interface: one is to use CPLD or FPGA to design the PCI interface. This method is more flexible, but it is more difficult and the design cycle is longer. The other is to use a dedicated PCI interface chip, which can greatly reduce the workload of the designer, thereby shortening the development cycle and reducing the development cost. This motion control card is designed using the PCI9052 chip. 1: The main features of PCI9052 are: (1) Support for burst operation: PCI9052 provides read and write FIFO, supports burst memory mapping and I/O mapping to access data on the PCI bus and local bus. (2) Programmable local bus configuration: PCI9052 supports multiplexed and non-multiplexed 8/16/32-bit local buses. (3) Read-first mode: that is, pre-latched data can be read from the PCI9052 internal FIFO register before the local bus. (4) Four local chip select signals (five local address spaces): its base address and the range of each chip select (local address space) can be programmed by serial EEPROM or master device. (5) PCI Locking Mechanism: PCI master devices can exclusively access PCI9052 through the locking signal. 2: Composition structure is shown in Figure 1. PCI9052 is composed of PCI bus interface logic, local bus interface logic, serial EEPROM interface logic and internal logic. 3: Some functions and operations of PCI9052 (1) Initialization When powered on, the PCI bus sets the internal registers of PCI9052 to the default value. At the same time, PCI9052 outputs a local reset signal and checks whether EEPROM exists. If it exists and the first 16 bytes are not empty, PCI9052 sets the internal registers according to the contents of EEPROM. Otherwise, it is set to the default value. (2) Reset PCI9052 supports hardware reset and software reset. I. Hardware Reset: When the RST# signal input is valid, it will cause the entire PCI9052 to reset and output the LREST# local reset signal. II. Software Reset: Reset by setting the software reset byte in CNTRL and output the LRESET# signal. The PCI9052 remains in this state until the host on the PCI bus clears the software reset byte. (3) Access to the serial EEPROM interface After the reset, the PCI9052 starts reading the serial EEPROM. If the first word read is not FFFFH, the read operation continues; otherwise, it is considered invalid. Before the master device on the PCI bus performs read and write operations on the EEPROM, it needs to set the register bit CNTRL[25] to "1" and control the CNTRL[24] bit to generate the clock of the serial EEPROM, and then send the instruction code from EEDI. When the operation ends, CNTRL[25] is set to "0". (4) Access to internal registers The PCI9052 provides two types of on-chip registers, namely the PCI configuration register and the local configuration register. Both can be accessed by the PCI bus and the serial EEPROM. Access to the serial EEPROM can also be disabled by setting CNTRL[13:12]. These registers mainly include: (where “*” represents a value, and the value range is 0 to 3) <1> Device and Manufacturer Register: used to identify the device category and manufacturer. <2> Status Register: contains event information related to the PCI bus. <3> Command Register: controls the device's response to PCI access. <4> Address Range Register (LAS*RR): used to define the size of the address space occupied by the resources on the board. <5> Base Address Register (LAS*BA): used to define the base address occupied by the resources on the board and remap it to the PCI address space so that the PC can access the board. <6> Bus Area Description Register (LAS*BRD): used to define the specific working characteristics of the address space. <7> Chip Select Signal Control Register (CS*BASE): used to determine the effective address range of the chip select signal, thereby providing the chip select signal CS* to the hardware. (5) Generation of PCI Interrupt (INTA#) To generate interrupt INTA#, first set INTCSR[6] to “1”. If an interrupt is generated in software, simply set INTCSR[7] to "1"; if an interrupt signal INTi1 and INTi2 are generated by a device on the local bus, and then an interrupt INTA# is generated, simply set the relevant bits of INTCSR as required. Three: Application example of PCI9052 1: Implementation principle of motion control card Figure 2 is a system structure diagram of a motion control card based on PCI bus. The system uses PCI9052 dedicated interface chip to realize high-speed communication between motion control chip PCL5023 and PCI bus; CPLD (Complex Programmable Logic Device, its advantages are: high degree of system integration, convenient change of logic function, no need to change hardware design when modifying) is used to realize the logic circuit function on the card. As shown in the figure: the system uses two PCL5023 chips to realize the motion control of the motor. One PCL5023 controls axis 1 and axis 2, and the other PCL5023 controls axis 3 and axis 4. When using it, the parameters of the PCI9052 EEPROM must be set correctly so that the internal registers of the PCI9052 can be correctly initialized when the system is powered on (such as the PCI configuration register and the PCI local configuration register are set correctly so that the memory space address on the computer and the local memory space address on the card can form a one-to-one mapping relationship). After the correct power-on configuration, the stepper motor or servo motor is driven by high frequency pulse to complete the expected speed output requirements. Moreover, multiple motion control cards of this model can be used in the same system at the same time to achieve multi-axis motion control and meet the motion control requirements in various situations. 2: The design of the whole system includes two aspects, namely hardware circuit design and software design. (1): The hardware circuit design specifically includes the design of the circuit schematic diagram. The overall component distribution is fully considered during the design to meet the thermal effect principle, anti-interference principle, nearest neighbor principle, and at the same time ensure the correctness, reliability, rationality, economy of the board design, as well as thermal design, electromagnetic anti-interference, etc. (grounding, configuration of decoupling capacitors, etc.). The external signals and internal signals on the card are effectively isolated by optical couplers. (2): Software design specifically includes the design of drivers, function libraries, and human-computer interfaces. a: Driver design: Because the hardware resources on computer devices cannot be directly accessed under the WINDOWS operating system, it is necessary to write a device driver that runs in kernel mode to access the hardware resources of the motion control card. WinDriver has the advantages of good support for PCI interface chips and does not require expertise in operating systems and drivers, so this design uses WinDriver to develop the device driver. The specific steps are roughly as follows: When creating the driver project, add the program file P9052lib.c to the project, include the header file P9052lib.h in the driver source code, call P9052_Open() at the beginning of the source code to obtain a handle "HANDLE" of the board, and then call functions such as P9052_ReadBlock(), P9052_WriteBlock(), P9052_ReadByte(), P9052_ReadWord(), P9052_ReadDWord(), P9052_WriteByte(), P9052_WriteWord(), P9052_WriteDWord(), P9052_IntEnable(), P9052_IntDisable(), and P9052_IntWait() in the program to complete operations such as reading the board's memory and enabling/disabling interrupts. At the same time, modify and add necessary code, and use P9052_Close() at the end of the driver to close the call to the board. b: The design of the motion control card's function library aims to provide users with a good software and hardware development platform. Under certain circumstances, users can obtain the required motion control modes by calling the provided interface functions. These motion control modes mainly include: single-axis constant speed motion mode, single-axis trapezoidal motion mode, single-axis S-curve motion mode (as shown in Figure 3), single-axis return mode, dual-axis linear and circular interpolation motion modes, and multi-axis point-to-point motion modes. Therefore, a rich set of function library functions is needed to complete system initialization, pulse input/output configuration, interrupt control, position control, interpolation parameter configuration, I/O port control and monitoring, and various motion modes. All these function library functions are written in C language. As shown in Figure 3, the motor speed smoothly transitions between the acceleration/deceleration zone and the maximum speed, effectively reducing impact and wear, thus improving the lifespan of the motor and mechanical system. The design principle of the library functions is to use API functions to implement read and write operations on the registers of the PCL5023 chip. These read and write operations write certain specific values to the corresponding registers, thereby controlling the motor to operate in a certain operating mode. Corresponding to different operating modes and different operation contents, the read and write operations of the registers are also different, and there are specific requirements for the steps of the operation. As shown in Figure 4, the internal registers of the PCL5023 are read and written through data signals and control signals issued by the CPU, thereby realizing the control of the motor. c: Programming of the operation interface In order to achieve real-time and accurate control of the motor, this software system designs a relatively user-friendly human-machine operation interface to complete the required operations, including the selection of the axis and its parameter configuration, the selection of motion parameters and interpolation parameters, and the selection of the operation mode. The programming language used is VC++6.0. IV: Anti-interference measures The following measures are adopted in the hardware circuit: noise filter is used on the input power supply of the AC servo system; isolation transformer is used on the power supply of the AC servo system; power supply is grouped for different functional modules in the system to prevent mutual interference between devices; and optocouplers are used to isolate the internal circuit of the motion control card from the input and output circuits of the servo driver to prevent interference from entering the motion control card or host from the outside. In addition, some anti-interference measures were adopted in the software system. For example, the averaging method was used to avoid the influence of random errors in the system on the sampling results, and the comparison and rejection method was used to eliminate individual abnormal data. V: Conclusion This paper mainly introduces the main features, structural composition, related functions, and corresponding operations of the PCI9052 interface chip. It also introduces the application of PCI9052 in motion control card design, specifically including the implementation principle of the motion control card, the design of the hardware circuit, and the design of the driver program, function library, and human-machine interface. Practice has proven that using this professional interface chip for motion control card development not only greatly shortens the design cycle and reduces product costs, but also that the motion control card developed using PCI9052 is highly practical, reliable, and has good scalability. References: 1. PLX PCI9052 Data Book [M], 2000 2. WinDriver User's Guide [M], Jungo Ltd, Version 6.02, 2003 3. Li Guishan: PCI Local Bus Developer's Guide [M], Xi'an University of Electronic Science and Technology Press, 1997 4. Yin Yong: PCI Design and Development Handbook [M], Beijing University of Aeronautics and Astronautics Press, 2005