1、 外文文献翻译: The Designing of Serial Communication Based on RS232 The Designing of Serial Communication Based on RS232 Abstract This paper discussed the principle of serial communication mainly, proposed the design method based on RS232, designed the hard circuit of serial communication
2、 and realized the programming to PC Microcomputer and single chip microcomputer by using assembly language and C++ Builder separately. Keywords: serial communication; single chip microcomputer; program design. I. INTRODUCTION During working in the control system, the PC microcomputer sends i
3、nstructions for step-by-step motor to collect the image information. Therefore the communication between the PC microcomputer and the driving system is needed for the communication system. In general, a complete communication system consists of transmitter, receiver, converting the data interface an
4、d transmitting data channel. The control of the step-by-step motor is realized through the pulse distribution by single chip microcomputer. On the motor control system, the PC microcomputer is called as upper computer, and the single chip microcomputer for driving step-by-step motor is called as low
5、er computer. The communication between the upper computer and the lower computer has two methods, that is to say the parallel communication and serial communication. Parallel interface can transmit much data at the same time and has the fast speed, but when the transmission distance is far and the n
6、umber of data is much, it needs more the number of transmission lines. In addition, the voltage level may be changed by the transmission line factor and electromagnetic interference. Serial communication is a one way that the data is transmitted by a bit in order, in which two transition lines is ne
7、eded to realize bidirectional communication. It is taken into consideration that the data is much and the transmutation number is little, the serial communication is utilized in the control system so as to simplify the hardware and save the cost. Serial communication is one of the oldest mechanisms
8、 for devices to communicate with each other. Starting with the IBM PC and compatible computers, almost all computers are equipped with one or more serial ports and one parallel port. As the name implies, a serial port sends and receives data serially, one bit at a time. In contrast, a parallel port
9、sends and receives data eight bits at a time, using eight separate wires. For serial communication to work, you just need a minimum of three wires—one to send, one to receive, and one signal ground. For parallel communication, you need eight wires. Despite the comparatively slower transfer speed o
10、f serial ports over parallel ports, serial communication remains a popular connectivity option for devices because of its simplicity and cost-effectiveness. It shows some of the devices that use a serial port to connect to the computer. Using a serial port, you can connect to a modem, a mouse, or a
11、device such as a bridge/router for configuration purposes. II. THE BRIEF DESCRIPTION OF SERIAL PORT COMMUNITION Serial communication is the communication between sender and receiver data transfer is in the single data line, to move each time a bit. The advantage is that only a pair of transmission
12、 lines to send information, so its low cost, suitable for long-distance communications; its disadvantage is that transmission speed is low. As mentioned, a serial device sends and receives data one bit at a time. Some devices can send and receive data at the same time and are known as full-duplex d
13、evices. Others that can either send or receive at any one time are known as single-duplex. To initiate transmission, a device first transmits a start bit, followed by the data bits. The data bits can be five, six, seven, or eight bits, depending on what has been agreed upon. Both the sender and the
14、 receiver must be set to the same data bits for communication to take place correctly. Once the data bits are sent, a stop bit is sent. A stop bit can be one, one and a half, and two bits. The baud rate is the speed of transmission of data from one device to another. Baud rate is usually measured in
15、 bits per second (bps).Most serial devices transmit in seven or eight bits. To detect that the data has been sent correctly, an optional parity bit can be included together with the data bits. A parity bit can be one of the following: odd, even, mark, space, or none (mark and space parity are almos
16、t always used). Using a parity bit provides a basic mechanism to detect corruption of data that was sent and does not guarantee that the data received is free from error. Nevertheless, a parity bit is useful for improving the integrity of the data sent. Most serial ports adhere to the RS232C standa
17、rd, which specifies a connector either with 25 pins or with 9 pins. Most serial devices use the nine-pin connector. Serial communication with asynchronous communication and synchronous communication are two basic means of communication. Synchronous communication for the case of high transmission sp
18、eed, the hardware complexity. The asynchronous communication used in transmission speed between 50 and 19200 baud. Transmission is relatively common. In asynchronous communication, data is transmitted frame by frame, each frame of serial data format by a start bit, 5 to 8 data bits, a parity bit (op
19、tional) and a Stop bit of four parts. Before the serial communication, the sender and receiver to agree the specific data format and baud rate (communication protocol). PC-programmable serial asynchronous communication controller 8250 to implement asynchronous serial communication. By 8250 the initi
20、al programming, you can control serial data transmission format and speed. In the PC, in general there are two standard RS-232C serial interface COM1 and COM21MCS - 51 series microcontroller chip includes a full-duplex serial interface, can also be realized by programming the serial communications.
21、 CMOS smart sensor IC has received wide application for low cost, miniaturization, intelligence and standardization. In smart sensor IC designs, the communication interface circuits also play an important role other than sensors and signal processing circuits. There are more serial communication sta
22、ndard interfaces, such as RS-232, RS-485, USB Interface, IEEE-1394, which has itself good features and also has focused on areas of application. RS-485 has a anti-noise capacity transmitting data, so it is commonly used in industrial production. USB interface and IEEE-1394 have fast speed, but some
23、computers and operating systems do not support such interfaces. RS-232 is most widely used as a serial interface in a PC computer and communications industries. RS232C standard is a protocol of asynchronous serial communication and has been widely used in PC and communication industries. Many short
24、distance communicational peripherals of PC such as printers, disks and terminals all communicate with PC via RS232 serial interface. RS-232C standard RS-232C is the American Electronics Industry Association (EIA) formally announced, in the asynchronous serial communication, the most widely us
25、ed standard bus. The standard for DCE and DTE serial binary communication between the maximum data transfer rate of up to 19. 2kbps, the longest transmission cables up to 15 meters 1RS - 232C standard defines the 25-lead, two-way communication in general, just Serial input RXD, serial output TXD and
26、 ground GND1RS - 232C standard levels using negative logic, the provisions of + 3V ~ + 15V at any level between a logic "0"level, - 3V ~ - 15V of Any level between a logic "1" level, with TTL and CMOS levels are different. In the interface circuit and computer interface chip in the mostly level TTL
27、or CMOS, so the communication, the need for level conversion, so with the RS - 232C standard level matching 1MAX232 chip level conversion can be done in this work. RS-232 is defined as the single-ended standards, which has much characteristic, such as more communication distance in a low-speed seri
28、al communications, moderate price and good practicality of the system, so it is most appropriate to be a communication port. RS-232 is an essential modern computer interface, it includes ports COM1 and COM2, the port COM1 has 9-pin connector. The new generation computer has a 9-pin connector (DB9) s
29、o as to connect with the RS-232 communication port. In order to achieve reliable and real time transmission, the system adopt a three-wire connection method, that is to say that the GND pin, RXD pin and TXD pin of RS-232 port is connected with the external port, it is shown in Figure 1. Figure 1
30、 The RS-232 port III. THE HARDWARE DESIGN OF SERIAL PORT COMMUNICATION The in-out level of single chip computer is TTL level, while the RS-232 serial interface of a PC computer is standard serial interface, so both the electrical specifications are inconsistent. In order to communicate with the u
31、pper and lower computer, it is needed that the out level of single chip computer is changed to the TTL level. The common level converter chip between TTL and RS-232 level is MCI1488 and MCI1489. The MCI1488 converts TTL level to RS-232 level, it needs the supply voltage of ± 12V, and that the MCI148
32、9 converts the RS-232 standard level TTL level, it needs power supply voltage of +5V. Due to three power supply voltage, the circuit will be complicated, so this circuit adopts the standard RS-232 chip MAX232. MAX232 is the product of the MAXIM Company; it is the road receiver and driver IC chip.
33、 About MAX232 chip MAXIM MAX232 chip is produced by low-power, single-supply dual RS232 transmit / receiver 1 for all EIA-232E and V. 28 / V. 24 communication interfaces 1MAX232 a chip supply voltage converter, can+ 5V input power converted into RS - 232C ± 10V output voltage level required, so
34、 using this chip serial communications interface system as long as a single +5 V power supply can. MAX232 requires four external electrolytic capacitors C1, C2, C3, and C4, is the internal capacitance of a power conversion requirements are 1μF/25V1 should choose its value and should be as close
35、 as possible tantalum chip capacitor 1C5 is 0. 1μF decoupling capacitor. MAX232 pin T1IN, T2IN, R1OUT, R2OUT to pick TTL / CMOS level pin 1 pin T1OUT, T2OUT, R1IN, R2IN to access RS - 232C level 1 so the pin TTL / CMOS level T1IN, T2IN MCS-51 pin should be connected to the serial transmit pin T
36、XD; R1OUT, R2OUT should take MCS - 51 in the serial receive pins RXD1 corresponding RS-232C level T1OUT, T2OUT should be connected to PC-receiver RD; R1IN, R2IN should be connected PC-sender TD. MAX232 chip has a voltage converter which can transform the voltage of +5 V to the required voltage. The
37、refore, it adapts to the serial communication interface, moreover it has much characteristic, such as moderate price, the hardware simple, so it is used to be a voltage converter. The hardware circuit of serial communication module is shown in Figure 2. Figure 2. The hardware circuit of serial c
38、ommunication module IV. THE SOFTWARE DESIGN OF SERIAL PORT COMMUNICATION The communication program of the single chip microcomputer communicates with PC computer by interrupt and PC computer is called as main controller. When the single chip computer receives the data signals sent by PC computer,
39、then it calls interrupt service program. The flowchart of the interrupt service main subprogram is shown in Figure 3. In order to fully exploit the efficiency of single chip computer to minimize CPU ‘time occupied by communication, the control program will be we will promptly respond to and control
40、objects. The communication program will be optimized. The subprogram of serial port interrupt for receiving data, the subprogram for sending step-by-step impulse, the subprogram for judging instruction and the subprogram foe sending data. A. The subprogram of serial port interrupts for receiving da
41、ta The subprogram of serial port interrupts for receiving data is mainly responsible for receiving data sent by PC microcomputer and storing the data into allocated memory (it does not deal with data so as to reduce the time taken up by interruptions). The data received by the single chip microcomp
42、uter includes little information, such as speed, steps and on/off instructions, and the buffer is large enough to send the computer, so the software shake hands protocol is omit so as to raises the CPU utilization. When the program of serial port interrupt receives the specified data, it exits the s
43、erial port interrupt. B. The subprogram of sending the step-by-step impulse Using counter-timer of the single chip microcontroller timer 0, as the fixed times complete, the p1.5 port is negated so as to periodically generate the driving pulses. The timer 0 begins to count from initial value to 65
44、535, then the interrupt sub-program of timer 0 is called, in which the p1.5 port is negated to generate a driving pulse. Meanwhile, the single chip microcomputer loads again the initial value which is sent by the PC microcomputer by serial communication. Figure 3. The flowchart of the interrupt
45、service main subprogram C. The subprograms of judging instruction The program of judging instruction is set on the serial port interrupt program to be called. The PC microcomputer sends data to the single chip microcomputer. After the single chip microcomputer receives data, it sets the RI higher
46、and called the serial port interrupt sub-program, in which the first data is processed. If the first data is a digital symble”48”, the serial port interrupt sub-program sets P1.4 higher, then the next five bytes data is used to ensure the step-by-step motor’ speed and steps. If the first data is a d
47、igital symble”49”, it means that the step-by-step motor reverses, then the single chip microcomputer receives the speed and steps information. Otherwise the single chip microcomputer judges that the received data is not "STOP" instruction, if so, it sends “stop” instruction to the drive system; if n
48、ot, it quits the interrupt. D. The processing subprogram of send interrupts The processing subprogram of send interrupts is responsible to send data to the computer, sending interrupt state is off in the general. When the communication program completely deals with data sent by PC microcomputer, t
49、he symbol “1” can be written to send buffer. As the computer receives the symbol “1”, it is said that single chip computer executes completely the introduction sent by PC microcomputer. Therefore the serial port interrupt is set as “off” state by the single chip microcontroller and it is set “on” st
50、ate again after the data are sent. So the single chip microcomputer returns to main program and waits for receiving instructions. V. THE DESIGN OF COMMUNICATION PROGRAM OF PC MICROCOMPUTER AND SINGLE CHIP MICROCOMPUTER In order to realize the system software easily grafted and uniformity, the prog






