The Design Scheme of Realizing the Communication Between the Upper and Lower Computers of the Machine Using USB

The UROBOT-680-II teaching robot is a five-degree-of-freedom multi-joint robot developed by the Robotics Institute of Shanghai Jiaotong University with the loan from the World Bank. It has the basic functions of industrial machines, good openness and comfortable user interface, and major universities and research institutions provide teaching and research tools. Students can understand and learn industrial robots through hands-on operation. It has the basic functions of industrial robots, good openness and comfortable user interface. It mainly provides teaching and scientific research tools for universities and scientific research institutions.Students can understand and learn industrial robots through hands-on operation, and researchers can also

The UROBOT-680-II teaching robot is a five-degree-of-freedom multi-joint robot developed by the Robotics Institute of Shanghai Jiaotong University with the loan from the World Bank. It has the basic functions of industrial machines, good openness and comfortable user interface, and major universities and research institutions provide teaching and research tools. Students can understand and learn industrial robots through hands-on operation. It has the basic functions of industrial robots, good openness and comfortable user interface. It mainly provides teaching and scientific research tools for universities and scientific research institutions. Students can understand and learn industrial robots through hands-on operation, and researchers can also carry out secondary development of it.

The upper computer (main control computer) and the lower computer (motion controller) of the teaching robot originally used the SPP mode of the parallel port (LPT1) to communicate. Utilize the read ability of LPT1’s status register (Status Port) and transmit nibble (Nibble) each time to realize the bidirectional transmission function of data. The sequence (order) of each transmission is established by the software, and data is received and sent according to the communication protocol of the teaching robot under the coordination of the control word.

At present, USB is becoming more and more popular and is gradually replacing the status of serial port and parallel port in computer interface. In order to study the performance of USB in real-time communication, the communication between the upper and lower computers of the teaching robot has been changed to the USB port.

1. USB features and their applications

Universal Serial Bus USB (Universal Serial Bus) is a kind of computer that was jointly proposed by Compaq, IBM, Microsoft and other companies at the end of 1994. It has now developed to USB2.0. Because USB has the following characteristics, it is rapidly popularized and has gradually established its dominant position in computer interfaces.

(1) Ease of use. USB supports hot-plugging and plug-and-play.

(2) Scalability. Users can increase the number of USB ports by connecting a USB hub to an existing port, and more hubs can be connected to the hub. Theoretically 127 peripherals can be connected to the USB bus.

(3) Rapidity. USB version 1.1 specifies two transfer rates: low-speed transfer and full-speed transfer. The low speed transmission rate is 1.5Mbps, and the full speed is 12Mbps. This is not only much higher than the traditional serial port transmission rate, but also many times faster than the parallel port transmission. The recently introduced USB2.0 allows maximum transfer rates of up to 480Mbps.

(4) Reliability. The reliability of USB comes from the guarantee of hardware design and USB data transfer protocol. The hardware specifications of USB drives, receivers, and cables eliminate most of the noise that can cause data errors; the USB protocol uses error checking and data retransmission mechanisms to maximize data transmission accuracy.

(5) Built-in power supply. The USB bus has a built-in power line, which can provide 5V and up to 500mA power supply to peripherals, meeting the power requirements of most low-power peripherals.

Because USB has these outstanding advantages, not only some traditional peripherals begin to provide USB interface, but also a large number of new peripherals also take USB interface as the first or even the only interface, such as MP3 players, mobile hard disks and so on. Due to the high reliability and fast enough communication rate of USB, USB has begun to be used in industrial-level real-time communication and control, such as the communication between the teaching box and the controller in the robot system. The realization of the communication between the robot upper computer and the lower computer by using the USB port discussed in this paper also belongs to the application of these aspects.

2. Use USB to realize dual computer communication

Since the USB model is a Host-Slave (host-peripheral) master-slave structure, there is no way for two hosts to communicate directly over the USB bus without going through peripherals. However, two hosts can communicate using their USB ports by adding peripheral controllers. Each peripheral controller is connected to a different main and uses shared buffers to exchange data. Cypress’s EZ-Link and Prolific’s PL-2301 integrate two peripheral controllers and shared buffers into a single chip, as a bridge between two hosts through the USB bus. Other companies also offer similar control chips. In the teaching robot, PL-2301 is used.

PL-2301 is a full-speed USB control chip produced by Taiwan Prolific Company. The structural block diagram of PL-2301 is shown in Figure 1.

The PL-2301 includes two independent USB control units. Coordinated by handshake signals, they exchange data non-blockingly through the two FIFO buffers. PL-2301 includes four terminals: default control terminal (address 00H), interrupt terminal (address 81H), block output terminal (address 02H), block input terminal (address 83H). The control transfer is used to complete the configuration of the PL-2301 during the host enumeration phase and to control the handshake signal of the PL-2301 when the two hosts communicate; the interrupt transfer is used for the PL-2301 to periodically (once every millisecond) report the status of the handshake signal to the host. ; Chunk transfers are used to exchange data between two hosts in real time. Block transfers support error detection, which is important for real-time communication and control. Control transfers are guaranteed to have 10% of the USB bus bandwidth, interrupt transfers and isochronous transfers can use up to 90% of the bandwidth, and block transfers use the remaining maximum available bandwidth (up to 95%). When the bus is not too busy, the block transfer is the fastest of all transfer types due to only a small header (13 bytes). In order to ensure that the upper and lower computers of the teaching robot communicate at the fastest speed and meet the real-time requirements, it is best not to connect too many USB peripherals on the USB bus.

In addition to responding to USB standard requests, the PL-2301 can also respond to several vendor-defined requests. The custom requests ClearQuickLinkFeature and SetQuickLinkFeature are used to control the handshake signal of the PL-2301 when the two hosts communicate. These handshake signals are:

(1) TX_RDY indicates whether the local USB port is ready to transmit data.

(2) S_EN Suspend enable signal. When asserted, the PL-2301 supports the standard USB suspend feature.

(3) RESET_O The reset signal of the block output pipeline is used to reset the block output channel when an error occurs.

(4) RESET_IN The reset signal of the block input pipeline is used to reset the block input pipeline when an error occurs.

(5) TX_REQ block transmission request signal.

(6) Indication signal of completion of TX_C block transmission.

(7) PEER_E tells the other party whether the local port is connected or not.

Under the coordination of these handshake signals, the upper computer and the lower computer can communicate in two directions. Figure 2 is a flow chart of host PC A transferring data to PC B. These low-level details do not need to be controlled and are done by the PL-2301 driver.

3. Software structure

3.1 Software structure of teaching robot

The control software of the EDUROBOT-680-II teaching robot control system includes the bottom control software of the lower computer and the upper control software of the upper computer, which communicate through the USB port. Its software structure is shown in Figure 3.

The upper control software runs on the Windows98 platform, which provides the user with the man-machine interface interface for interacting with the robot, and completes the data processing and interpolation calculation of complex motion control. It consists of four major modules: man-machine interface, arithmetic interpolation, main control and communication. The communication module can send control commands to the lower computer in real time and obtain feedback information from the lower computer, while ensuring the accuracy of data transmission.

In order to provide support for USB (in order to make the underlying control system more real-time and more compact, the next step is to switch the underlying control system to Windows CE, VxWorks or embedded Linux that supports USB), the underlying control system currently uses Windows98 platform. The bottom layer control software interface receives the control commands of the upper layer control software, and interprets and executes the control commands at the same time. This is achieved through multithreading. The task scheduling and management module is the main thread of the underlying control software, which is responsible for fetching instructions from the instruction queue and interpreting them for execution. The main thread execution process will generate an auxiliary thread – the communication thread. The communication thread calls the output function of the communication module, which is responsible for monitoring the USB port. If a control command is sent from the upper computer, it will be received and stored in the command queue according to the teaching robot communication protocol.

3.2 Implementation of Communication Module

The upper computer and the lower computer control software share the same PL-2301 client driver, transmission module (provided by Prolific) and communication module.

The PL-2301 client driver is a typical WDM driver. The driver shields the underlying hardware details and USB protocol, so that the upper-layer software can access the PL-2301 only through the driver interface function. The main several driver interface functions are CreateFile (), WriteFile (), ReadFile (), DeviceIOControl ().

The transfer module (Transfer.dll) is the upper-level module of the driver. It realizes the basic communication capability of two hosts through the PL-2301 by calling the interface function of the driver. Transfer.dll spawns a list of three threads:

(1) Sending thread. This thread queues requests to send and processes them in order. If something goes wrong, try to recover.

(2) Receive thread. This thread waits for a message from the state thread, and if it finds that the other host is about to transmit data, it receives the data according to the transmission protocol. The receiving thread puts the received data in the receiving FIFO buffer and waits for the upper layer software (Comm.dll) to take it away. If an error occurs, it will also try to recover.

(3) State thread. This thread monitors the PL-2301 for status signals. If it finds any state change, it will send a message to the relevant thread or call a callback function to notify the upper-level software.

Transfer.dll provides several output functions for upper-layer software (Comm.dll) to call:

・USB_InitService() must call this function before calling other output functions in Transfer.dll.

・USB_OpenConnect() calls this function to get the handle of PL-2301. This handle is used when sending and receiving data.

・USB_WriteConnect() calls this function to send the specified data to the other host.

・USB_ReadConnect() calls this function to read data from the receive FIFO buffer.

The communication module (Comm.dll) completes the sending and receiving of teaching robot control commands by calling the output function provided by Transfer.dll. In order to coordinate the sending and receiving of commands, a set of control words is defined as the handshake signal when the upper computer communicates with the lower computer (it has no connection with the handshake signal of PL-2301). When the host computer sends data (control command or control word), it can directly call USB-WriteConnect(). The lower computer reads data in polling mode, and calls USB-Read Connect() cyclically to scan the USB port, and if there is data, it will be received. If an instruction is received, it is put into the instruction queue and waiting for the task management and scheduling threads to take it away. Figure 4 is a schematic diagram of the host computer sending a command. Some commands require the lower computer to send the return value to the upper computer. For example, the command to read the robot status requires the lower computer to send the return value to the upper computer. For example, the command to read the robot status requires the lower computer to return the robot status to the upper computer. The process of sending the return value from the lower computer is similar to the process of sending the command from the upper computer.

As an emerging computer peripheral interface standard, USB can not only be used as an interface between computers and general peripherals, but also be used for real-time communication and control. This paper introduces the use of USB to realize the communication between the teaching machine and the upper and lower computers, and provides a novel, convenient and reliable solution for the communication between the upper and lower computers of the robot. With the introduction of USB2.0, its transmission rate of up to 480Mbps can meet high real-time requirements of industrial equipment control, real-time transmission of dynamic images, etc., laying a solid foundation for the application of USB in a wider field.

The Links:   LM64K101 MG400V1US51A IGBT-SOURCE