Using VB 6.0 to realize the communication between network remote PC and single chip computer

Source: Internet
Author: User
Tags socket valid

In the design of all kinds of SCM application system, often encountered SCM and PC communication problems, in the speed is not high, the transmission distance is not far from the general use of RS 232 standard serial interface to achieve, in the transmission distance from the occasion, there are scholars to study the network to achieve communication between the PC. However, it is an urgent problem to meet both high speed and long-distance PC communication with MCU. With the development of information technology, computers and networks are becoming more and more popular, and the requirements of remote control and measurement of SCM are more and more. In this paper, based on the existing research, the related design of some improvement and innovation, design a remote communication system, he is composed of 3 parts: remote PC, local PC and Single-chip computer system. Through the VB visualization programming, the remote PC uses the LAN to issue the command to the local PC, the local side PC receives the command, the automatic and the monolithic computer through the printer interface uses the EPP1.9 protocol to communicate (the serial interface as the standby communication port), and will receive the monolithic computer data real-time transmission to the remote PC In order to realize the requirement of communication between PC and MCU in high-speed and remote situation.

1 system structure and design

System composition as shown in Figure 1, the remote PC through the LAN and the local PC communication, the use of Winsock Control and TCP/1P protocol in communication, the local PC through the parallel communication interface or serial communication interface with the SCM communication, the simultaneous port communication using the Winio port communication driver, EPP protocol and LPT printer interface, the use of MSComm control, RS 232C protocol and COM port in serial communication. In this structure, the local PC side plays the role of relay, when the local PC received the command from the remote PC, after the choice of communication mode, with the SCM communication, so that the single-chip computer to transmit data to the remote PC.

2 remote PC and local PC communication design

TCP/IP is a set of complete network protocols widely used in network communication, the core of which is TCP,IP and UDP protocol. In the TCP/IP network environment, the application realizes the interaction with the kernel through the network System programming Interface sockets (socket). The purpose of this program is to use the socket communication programming interface to establish a communication connection between the different machines of the network formed by TCP/IP, and the developer can provide some basic connection information and the rest is completed by the operating system kernel. WinSock (Windows Sockets) is a network programming interface for common TCP/IP applications under the Windows operating system, calling WinSock interface functions to invoke the various functions of TCP/IP. In VB 6.0, the Winsock control encapsulates the Windows Sockets API, using programmers to not know the specifics of TCP/IP or invoking the underlying Winsock API, as long as the appropriate properties are set and handled appropriately during the event that triggers You can write a Web application.

The remote PC communicates with the local PC through the VB 6.0 call Winsock Control implementation, Figure 2 (a), (b) is its control interface respectively. The following points need to be explained: The remote PC chooses the IP address and the network transfer port of the local PC to be connected, then initiates the online request; the local PC network transfer port must be the same as the remote PC transfer port, the serial port is com1/com2, and the parallel port is entered at the same address (378H) When the PC enters the command in the command input area, it is valid to send the command button; The return data area stores the real-time data transmitted by the MCU and can be saved as a text file, the information area holds the network working state, the command of the remote PC, and the data transmission of the single-chip microcomputer. Its working process is shown in Figure 2 (c).

3 local PC and MCU communication design

3.1 Local PC and single chip computer communication design

3.1.1 Parallel communication Interface and protocol

In the case of higher rate requirements, you can use the PC printer interface (Centronics standard, DB-25 pin base, TTL level) to achieve. There are three working modes of the SPP, EPP and ECP in the same port communication. This paper adopts EPP protocol.

(1) EPP protocol

Enhanced Parallel Interface protocol EPP (enhanced Parallel Port) defines the standard for parallel two-way communication between PCs and peripherals, which can achieve a communication rate of kb/s~2 MB/s, which is suitable for a large number of data transmission peripherals. EPP is divided into EPP1.7 and EPP1.9, the difference between the two is: EPP1.9 need to judge timeout (avoid "dead loop") and nwait signal is valid, and EPP1.7 do not need to judge, transfer faster. The EPP protocol supports 4 kinds of operations, including data writing, address writing, data reading, and address reading.

(2) The Register address of EPP protocol and some key pin definitions, as shown in table 1, table 2.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.