Thiết kế giao diện phần cứng Hệ thống điều khiển được mô tả trong bài báo này bao gồm máy tính công nghiệp và nhiều máy tính chip AT89C2051 đơn -. Truyền dữ liệu giữa chủ và tớ sử dụng giao tiếp nối tiếp không đồng bộ. Vì cổng giao tiếp nối tiếp của máy tính công nghiệp là giao diện RS - 232C, mức logic của nó đối xứng với mặt đất, khác với đầu ra mức TTL bằng cổng nối tiếp của máy tính vi mạch đơn chip AT89C2051. Do đó, cần đảm bảo truyền dữ liệu đáng tin cậy giữa hai bên. Một bộ chuyển đổi mức phải được kết nối với đường truyền thông. Các chip chuyển đổi mức thông dụng gồm chip ICL232 và MAX232. Văn bản này sử dụng chip chuyển đổi mức MAX232.
Multiple single{{0}}chip computer communication circuit 2 software design 2.1 AT89C2051 single-chip computer multi-computer communication function AT89C2051 single-chip microcomputer serial port has: serial send buffer/receive buffer (SBUF), serial port control register (SCON), special function register ( PCON). There are 4 working modes by setting SCON, among which working modes 2 and 3 are suitable for multi-computer communication. The serial communication mode 3 of the AT89C2051 single-chip microcomputer is a 9-bit data asynchronous communication mode with a variable baud rate, and is also the most widely used mode in multi-computer communication at present. Here, AT89C2051 transmits a frame of information with 11 bits in total: 1 start bit, 8 data bits, 1 bit can be programmed to be the 9th bit of "1" or "0" and 1 stop bit, among which The ninth bit of data can be used as a parity bit, and can also be used as an identification flag for "address frame" and "data frame".
Chức năng giao tiếp máy tính công nghiệp Máy tính công nghiệp được trang bị cổng giao tiếp không đồng bộ nối tiếp (địa chỉ cổng COM1 là 3f8H, địa chỉ cổng CM2 là 2f8H), và bộ thu / phát không đồng bộ đa năng (UART) trên bảng giao diện là một đoạn 8250 hoặc a mảnh cấu trúc, phương pháp lập trình Giống chip 8250 với 10 thanh ghi bên trong. Lập trình giao tiếp nối tiếp trên PC, người lập trình chỉ cần sử dụng lệnh nhập / xuất để nhập / xuất các thanh ghi trong UART, để thiết lập tốc độ truyền nối tiếp, định dạng truyền dữ liệu, cho phép ngắt, gửi hay nhận dữ liệu chờ.
Phương thức giao tiếp máy đa - mới Trong phương thức giao tiếp máy đa - thông thường, bit chẵn lẻ đã được sử dụng làm bit đặc trưng của mã địa chỉ gửi (số kênh) hoặc dữ liệu và kiểm tra giao tiếp dữ liệu thông qua phương pháp tích lũy và kiểm tra. Sử dụng phương pháp này không chỉ làm tăng chi phí phần mềm và số lượng dữ liệu để giao tiếp mà còn ảnh hưởng đến hiệu suất - thời gian thực. 2.3.1 Các nguyên tắc cơ bản của giao tiếp
The data is 5 2 - set to "0" directly, and make plus , clear, then no matter what the value of the ninth bit data ( plus 9 8) is, the lower computer can generate serial reception interrupt, so the ninth bit can be used as Error detection parity bit too. For example, when the upper computer communicates with a lower computer, the address code is sent first, and then the data command is sent after the handshake is successful. At this time, the FLAG of the lower computer is set to "1", which is equivalent to the "pocket" of the machine has been opened. The computer continuously fetches data from the lower-position computer, and issues a command to restore the FLAG in the lower-position computer to "0" after fetching without error to realize "closing the pocket".
Khi máy tính phía dưới gửi dữ liệu đến máy tính phía trên, trước tiên nó sẽ gửi độ dài của dữ liệu cần truyền, sau đó bắt đầu gửi dữ liệu hợp lệ.
It is agreed that {{0}}H is the fetch command, 0FFH is the reset command, the communication adopts even parity, and the baud rate is set to 2400b/s. The flow chart of the main function of the PC is given above, as shown. The PC communication program is written in VC plus plus 6.0 language. The communication module of the lower single-chip microcomputer includes the main program and the interrupt service program, and its program flow chart is shown in and respectively. How to realize the one-to-one communication between the upper computer and the lower computer with the corresponding sending address? Software method can be used. The specific method is as follows: a flag variable FLAG is set up in the lower computer program, and FLAG is set to "0" during initialization. When the upper computer sends data, each lower computer will generate a receiving interrupt, and the interrupt service routine first judges the value of the local FLAG. . If FLAG is "0", compare the received data with the local address, if it is consistent, set FLAG to 6", and send back the local address code as a response, otherwise jump out of the interrupt service routine immediately; if FLAG is "1" , indicating that the control command sent by the upper computer is transferred to the corresponding command processing program, and finally jumps out of the interrupt service routine and returns to the main program. After the communication between the upper computer and the lower computer is completed, the FLAG of the lower computer is set to "0" .If the handshake fails, the upper computer sends a reset command to the lower computer, and then starts the handshake again, if it fails three times, it will turn to error processing.
Implementation method and reliability measures of industrial computer software ①Number each lower computer and use it as the address code of the computer.
Kết luận Bài viết này chỉ nêu ra một phương thức giao tiếp nối tiếp của hệ thống điều khiển phân tán, nhưng giữa mỗi máy có rất nhiều phương thức giao tiếp giao tiếp như: kết nối trực tiếp cổng nối tiếp (khi khoảng cách ngắn), kết nối qua modem, v.v. về lập trình phần mềm, máy phụ được viết trực tiếp bằng hợp ngữ của máy vi tính chip - duy nhất; và mô-đun chương trình con giao tiếp của máy tính công nghiệp cũng có thể được thực hiện bằng nhiều ngôn ngữ khác nhau. Do đó, trong thiết kế hệ thống cụ thể, một trong các phương pháp có thể được lựa chọn tùy theo tình hình thực tế, và công nghệ phát hiện lỗi và sửa lỗi có thể được xem xét trong lập trình và có thể hoàn thành giao tiếp đáng tin cậy.

