版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上专心-专注-专业外文文献翻译:The Designing of Serial Communication Based on RS232The Designing of Serial Communication Based on RS232AbstractThis 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. INTRODUCTIONDuring working in the control system, the PC microcomputer sends instructions
3、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 and transmitti
4、ng 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 lower computer.
5、 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 number of dat
6、a 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 needed to real
7、ize 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 for devices t
8、o 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 sends and rece
9、ives data eight bits at a time, using eight separate wires.For serial communication to work, you just need a minimum of three wiresone to send, one to receive, and one signal ground. For parallel communication, you need eight wires.Despite the comparatively slower transfer speed of serial ports over
10、 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 device such as a br
11、idge/router for configuration purposes.II. THE BRIEF DESCRIPTION OF SERIAL PORT COMMUNITIONSerial 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 lines to send informat
12、ion, 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 devices. Others that can e
13、ither 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 receiver must be set to th
14、e 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 bits per second (bps).Most
15、 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 almost always used). Using a parit
16、y 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 standard, which specifies a connector
17、 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 speed, the hardware complexity. The
18、 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 (optional) and a Stop bit of four pa
19、rts. 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 initial programming, you can control s
20、erial 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.CMOS smart sensor IC has received
21、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 standard interfaces, such as RS-232, R
22、S-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 computers and operating systems do
23、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 distance communicational peripheral
24、s 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 used standard bus. The standard for DCE and
25、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 ground GND1RS - 232C standard levels usin
26、g 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 or CMOS, so the communicat
27、ion, 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 serial communications, moderate
28、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) so as to connect with the RS-
29、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. The RS-232 portIII. THE HARDWAR
30、E DESIGN OF SERIAL PORT COMMUNICATIONThe 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 upper and lower computer, it is needed
31、 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 MCI1489 converts the RS-232 standard l
32、evel 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.About MAX232 chip MAXIM MAX232 chip
33、 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 using this chip serial communicatio
34、ns 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 1F/25V1 should choose its value and should be as close as possible tantalum chip capacitor 1C5 i
35、s 0. 1F 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 TXD; R1OUT, R2OUT should take MCS - 51 in the ser
36、ial 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. Therefore, it adapts to the serial communication inte
37、rface, 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 communication moduleIV. THE SOFTWARE DESIGN OF SERIAL PO
38、RT COMMUNICATIONThe 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, then it calls interrupt service program. The flowchart of t
39、he 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 objects. The communication program will be optimized. The su
40、bprogram 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 dataThe subprogram of serial port interrupts for receiving data
41、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 microcomputer includes little information, such as speed, steps and on/of
42、f 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 serial port interrupt.B. The subprogram of sending the step-by-st
43、ep impulseUsing 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 65535, then the interrupt sub-program of timer 0 is called, in which the
44、 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 service main subprogramC. The subprograms of judging instructionThe program
45、 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 and called the serial port interrupt sub-program, in which the first data is pr
46、ocessed. 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 digital symble”49”, it means that the step-by-step motor reverses, then the singl
47、e 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 not, it quits the interrupt.D. The processing subprogram of send interr
48、uptsThe 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, the symbol “1” can be written to send buffer. As the computer receives the
49、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” state again after the data are sent. So the single chip microcomputer return
50、s to main program and waits for receiving instructions.V. THE DESIGN OF COMMUNICATION PROGRAM OF PC MICROCOMPUTER AND SINGLE CHIP MICROCOMPUTERIn order to realize the system software easily grafted and uniformity, the program of upper computer is designed using the Boland C+ Builder 5.0 as a program
51、ming tool in the control system s the Boland C+ Builder 5.0 as a programming tool for PC programming. The serial port communication can be utilized in two ways: First, register components, C+ Builder does not in itself provide a separate serial communication component, but it can be obtained through
52、 registered Microsoft MSComm32 components, in which it is relatively simple for VB, VC in this way. The second method is called Windows API (Application Program Interface) function, in which this function is provided by the operating system in order to provide a lot of executive function. The progra
53、m steps are followed:(1) Setting by communication protocol and opening the serial port, which is called initialization, then blocking the other programs to use the serial port.(2) Configuring the serial port.(3) Transmitting data by the serial port to and fro, verifying data during transmission.(4)
54、Closing the serial port as no needing it so that other program uses.The sub-interface is simple, in which the setting on sub-interface parameters are defaults, such as baud rate that single chip communication module has been set to 2400Bps and that the baud rate is set to 2400Bps in the computer set
55、tings on the ports. The PC microcomputer has two ports called as serial port COM1 and COM2 generally, so the program can automatically identify serial port so that it can send and receive data and instructions successfully.Serial communication program includes two aspects, one is MCS-51 microcontrol
56、ler communication program, on the other hand for the PC, the communication process. In the preparation processes, the development of the two protocols is very important, otherwise it will not guarantee the reliability of data communications, and thus lose the meaning of communication. The communicat
57、ion protocol is agreed as follows:1) The serial communication baud rate is 1200bps.2) The frame format is: a start bit, eight data bits, a programmable ninth bit (this bit is sent and received address / data flag), and one stop bit.3) Set the address of the microcontroller code F1H. Contact before s
58、ending the data in the address code, such as the address code is the correct transmission of data, or to contact the address code.4) no parity. The communication of data accumulation and verification of the method, that is, each carrying one set of data (number of custom, is set to 100), a cumulativ
59、e and whether the correct checksum, the right to send you back to the 00H, or loopback FFH.5) communication can interrupt transmission and query. Here are ways to search for in the communication.6) PC-contact for the initiative to contact MCS - 51 microcontroller.7) PC machine using COM2 communications.VI. CONCLUSIONThe hardware of serial port communication is designed based on RS232, and the software of communication module be
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- YC/Z 623-2024烟草商业企业卷烟物流应急作业指南
- 2025版卷帘门销售与安装及售后服务合同3篇
- 城市排水系统改造招标意见
- 2024年停车场新能源汽车充电设施建设合同3篇
- 电视媒体收费规范:发票管理办法
- 城市供水项目钻井工程施工合同
- 水厂石材施工合同
- 办事处员工福利与关怀措施
- 医疗文创企业人才引进协议书
- 污水处理承台施工合同
- 北京市西城区2023-2024学年六年级上学期语文期末试卷(含答案)
- 期末综合测试卷(试题)-2024-2025学年五年级上册数学人教版
- 【MOOC】模拟电子技术-中南大学 中国大学慕课MOOC答案
- 建筑施工安全知识培训
- 污水泵站运营维护管理方案
- 2024下半年软考信息安全工程师考试真题-及答案-打印
- 项目经理或管理招聘面试题与参考回答
- 中华人民共和国能源法
- 常见急救知识培训
- 义务教育信息科技课程标准(2024年版)
- 《义务教育数学课程标准(2022年版)》初中内容解读
评论
0/150
提交评论