串行通信设计外文翻译--基于rs-232的串行通信设计(编辑修改稿)内容摘要:
R1IN, R2IN to access RS 232C level 1 so the pin TTL / CMOS level T1IN, T2IN MCS51 pin should be connected to the serial transmit pin TXD。 R1OUT, R2OUT should take MCS 51 in the serial receive pins RXD1 corresponding RS232C level T1OUT, T2OUT should be connected to PCreceiver RD。 R1IN, R2IN should be connected PCsender 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 munication inter face, 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 munication module is shown in Figure 2. Figure 2. The hardware circuit of serial munication module IV. THE SOFTWARE DESIGN OF SERIAL PORT COMMUNICATION The munication program of the single chip microputer municates with PC puter by interrupt and PC puter is called as main controller. When the single chip puter receives the data signals sent by PC puter, 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 puter to minimize CPU „time occupied by munication, the control program will be we will promptly respond to and control 6 objects. The munication program will be optimized. The subprogram of serial port interrupt for receiving data, the subprogram for sending stepbystep impulse, the subprogram for judging instruction and the subprogram foe sending data. A. The subprogram of serial port interrupts for receiving data The subprogram of serial port interrupts for receiving data is mainly responsible for receiving data sent by PC microputer 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 microputer includes little information, such as speed, steps and on/off instructions, and the buffer is large enough to send the puter, 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 stepbystep impulse Using countertimer of the single chip microcontroller timer 0, as the fixed times plete, the 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 subprogram of timer 0 is called, in which the port is negated to generate a driving pulse. Meanwhile, the single chip microputer loads again the initial value which is sent by the PC microputer by serial munication. 7 Figure 3. The flowchart of the interrupt 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 microputer sends data to the single chip microputer. After the single chip microputer receives data, it sets the RI higher and called the serial port interrupt subprogram, in which the first data is processed. If the first data is a digital symble”48”, the serial port interrupt subprogram sets higher, then the next five bytes data is used to ensure the stepbystep motor‟ speed and steps. If the first data is a digital symble”49”, it means that the stepbystep motor reverses, then the single chip microputer receives the speed and steps information. Otherwise the single chip microputer judges that the 8 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 interrupts The processing subprogram of send interrupts is responsible to send data to the puter, sending interrupt state is off in the general. When the munication program pletely deals with data sent by PC microputer, the symbol “1” can be written to send buffer. As the puter receives the symbol “1”, it is said that single chip puter executes pletely the introduction sent by PC microputer. 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 microputer 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 program of upper puter is designed using the Boland C++ Builder as a programming tool in the control system s the Boland C++ Builder as a programming tool for PC programming. The serial port munication can be utilized in two ways: First, register ponents, C++ Builder does not in itself provide a separate serial munication ponent, but it can be obtained through registered Microsoft MSComm32 ponents, in which it is relatively simple for VB, VC in this way. The second method is called Windows API (Applic。串行通信设计外文翻译--基于rs-232的串行通信设计(编辑修改稿)
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。