This paper describes the design of the controller based on RS232 interface. It uses a single-chip microcomputer to control the interface chip nat914, and uses SCPI statements in the Super Terminal of the serial communication tool that comes with the winelows operating system, the communication and program-controlled operation between the computer and the Kaplan instrument is realized.
More and more measuring instruments provide the general purpose intefface bus interface, through which you can easily and quickly connect the instruments and computers with the GUI interface to form a gplb network. You need to use the GUI board when connecting the GUI device to a computer. However, these interfaces are expensive and inconvenient for connecting the instrument to the computer. In most cases, the computer only connects to one GUI and does not need these functions.
In the face of the functional requirements of connecting a single instrument to a computer, this paper designs a cost-effective RS232-1 GUI controller, which uses the most commonly used RS232 interface of the computer to control the instrument with the GUI interface, establishes a data transmission channel between a computer and an instrument. In addition, SCPI (Standard Commands for prognmnnable Instrumentation) instruction sets are supported. You only need to enter SCPI commands in the tool software Super Terminal that comes with the Windows operating system, you can easily set parameters for the instrument and read the test results.
The RS232-GPIB controller is designed to connect a computer and a measuring instrument with a GUI interface, and uses the keyboard and display of the computer to control the instrument for program-controlled measurement. In this design, the computer interface is RS232 interface. Using this serial port as a communication tool, programming is convenient and the connection is simple and reliable. The software uses the Super Terminal that comes with the Windows operating system. Therefore, it is easy to receive and send data from the computer serial port, without the need to develop computer software, saving the development time of the controller.
The core of the controller is a single-chip microcomputer. One end is connected to the RS232 serial port of the computer, and the other end is connected to the GUI interface of the instrument. The single-chip microcomputer receives the SCPI command from the computer Super Terminal and forwards the command to the instrument with the GUI interface for execution. After the instrument executes the instruction, it sends the execution result to the Controller. Then, the Controller transmits the received data to the computer through the RS232 serial port and displays the data in the Super Terminal.
1. Hardware Design
Single Chip Microcomputer is the core of the RS232-GPIB controller, this design selects ateml company AT89C51 single chip microcomputer. As 89C51 is widely used in many fields, it has abundant on-chip resources and total online I/O Ports. It supports advanced language programming and is integrated with asynchronous serial control units that comply with RS232 data specifications. Therefore, to transmit data using Tx and Rx serial interfaces and external serial interfaces, you only need to use the maxcompute chip outside the microcontroller for level conversion, you can directly connect to the computer's serial port (COM ). The hardware structure 1 of the controller is shown in. the control circuit of the GUI interface is the focus of the hardware design of the controller.
It should be pointed out that the use of intelligent GUI interface chip can greatly simplify the design of the GUI circuit. Currently, there are two most common types of chips. One is represented by the tnt4882 chip produced by the National Instrument company in the United States. All the interface functions are integrated into the chip, and the interface functions are completely completed by the hardware, other auxiliary chips are not required and can be directly connected to the bus. The other one is represented by the tms9914 chip produced by Texas Instruments, which relies on software programming to complete the interface function, the interface chips sn75160 and sn75161 are used to perform level conversion and connect to the bus.
The comparison between the two chips is shown in table L. Considering the cost and other factors, this design selects the nat9914 chip that is fully compatible with the tms9914 chip as the interface chip of the bus. Nat9914 is a standard HbA control chip that can execute all the functions of the GUI, has direct memory access (DMA) function, programmable clock and baud rate, uses a CMOS drive, and is compatible with TTL level, therefore, it is extremely convenient to use. At the same time, sn75160 is used as the data converter, sn75162 is used as the handshake line and control line converter, and is used together with nat9914 to connect to the gplb interface.
In Figure L, the PO port of 89C51 is used to connect the data interface of nat9914 for bidirectional data exchange between the data bus and the bus; the I/O port of PL is used as the address bus, addressing nat9914 internal registers. The interrupt output of nat9914 is connected to the External Interrupt Interface of 89C51, and the communication between the interfaces is managed by the interrupt trigger method. The clock signal of nat9914 generally uses an independent clock source. In this design, considering that the function of the controller only communicates with a single GUI instrument, the effect of clock frequency on the data transmission speed of the GUI interface is negligible, therefore, the 89C51 ale signal is directly used as the nat9914 clock signal, which can make full use of the 89C51 on-chip resources, simplify the circuit, and reduce hardware costs.
2 Software Design
The computer software uses a Super Terminal. In the Super Terminal, you can enter command statements to control the instrument with the GUI interface. Because the SCPI Instruction Set provides a seamless control interface, you do not need to reset the control program when you replace the same type of GUI equipment in different companies, it can be easily programmed with the scheme of the same type of GUI Device of different manufacturers. Therefore, this design selects the SCPI instruction set that is common to the industry as the control instruction set, so that the RS232-1 GUI controller can be used with the vast majority of interfaces.
In this design, the Controller Software is written in the C51 language. After compilation, it is installed and runs in the 89C51 Microcontroller. The software framework uses the main program and interrupt call method to improve the cohesion of functional modules. The software functions are divided into two parts: RS232 serial communication program and GUI interface communication program, which are related to two interruptions: (1) Serial Communication interruption. This interrupt is responsible for RS232 serial data transmission. (2) External interruptions that receive the nat9914 interrupt signal. This interrupt processes various events from the data communication of the GUI interface. The main program enters the endless loop after completing initialization, waiting for the occurrence of these two interruptions. Among them, the RS232 serial port data is sent in the main program, and the serial port data is received by the serial port interrupt processing program. The serial communication program is relatively simple. The structure of the program is mainly presented here.
Before the nat9914 Chip starts to work, it needs to be initialized. This part of code runs as part of the initialization program in the main program, this includes setting the incoming message register, selecting the clock signal frequency, asking T1 when setting the time delay for the export, defining the communication end character EOS, and setting the IP address of the export device (the specified IP address must be in the O ~ Between 30, if a larger address is written. The device is still considered as 30 ). After the initialization is complete, connect nat9914 to the GUI. The initialization process 2 is shown in.
The code of the control part of the process is interrupted. When nat9914 triggers an External Interrupt of the 89c51 Chip, the microcontroller terminates normal operation, pushes the field data into the stack protection, and calls the external interrupt processing function, respond to the interrupt request for the nat9914 chip, as shown in process 3. There are four types of events that cause the interruption signal sent from nat9914 to the microcontroller: sending data events, receiving data events, receiving GET command events, and receiving DCAS command events. Frequent interruptions may affect the efficiency of the main program. However, considering the single function of the designed converter, the main program is basically in the idling state, and the processing of the four events is completed in the interrupt program. Therefore, it has little impact on the main program running. The process for receiving and sending data by using the GUI is shown in Figure 4 and figure 5.
During each receipt of the data on the GUI interface, nat9914 receives the first byte of data, that is, the Bi bit in the isr0 register. Trigger the MCU external interrupt. After the MCU enters the External Interrupt Processing Program, it reads the isr0 register and determines that the cause of the nat9914 trigger interrupt is to call the execution of the received data subroutine after receiving the data event, start to receive data from the GUI.
In the main program, after nat9914 sends the first byte of data, it sets the bo Bit in the isr0 of the bit register to trigger the MCU external interruption. After the microcontroller enters the External Interrupt Processing Program and determines that the event type is a data sending event based on the bo Bit, it calls the GPIB data sending program and sends the remaining data in the buffer zone to the GPIB bus in sequence.
3. Running status and Result
The design of the RS232-1 GUI controller in this article has been successfully used in the connection between the computer and the tds210 oscilloscope. Figure 6 shows the display interface of the Computer Super Terminal, where command:> is the input prompt for the SCPI command on the computer keyboard, while Gui:> is the output prompt for the feedback information of the device connected to the GUI, indicates that the following information comes from the GUI device (that is, the tds210 oscilloscope ).
The first input is the query command. The command of this class is '? '. When the oscilloscope receives the query command, it immediately returns the query information. ID? Command to query the brand and model information of the oscilloscope. The oscilloscope reply information is displayed on the Super Terminal. Why? Command to query the configuration information of channel l of the oscilloscope; Data? Command to query information about the current channel used by the oscilloscope and the number of sampling points.
Then enter the control command. After receiving the command, the oscilloscope executes the corresponding operation, but does not return the execution result. For example, the Lang Engl command indicates that the oscilloscope language interface is changed to an English interface, and the langjapa command indicates that the interface is changed to a Japanese interface.