Abstract: This article introduces the characteristics and usage of the RS-485 communication card method, as well as the practical method of using VB5 programming to realize communication between a microcomputer and a microcontroller and the issues that should be paid attention to.
Keywords: RS-485 communication, microcomputer serial communication, VB communication programming
In the field of industrial control, data collection and transmission are regular tasks. RS-485 protocol communication is widely used in the field of industrial control because it adopts differential reception and has strong ability to suppress common mode interference.
Two methods to implement RS-485 communication
The microcomputer standard communication adapter meets the RS-232C protocol standard. Under the condition that the waveform distortion is less than 10%, the maximum transmission distance is 50 feet (about 15.24 meters), and the maximum transmission rate is less than 20kbps. It cannot meet the requirements of industrial field data over long distances and high speeds. rate transmission requirements. Two methods can be used to implement RS-485 protocol communication in a microcomputer: the first is to use an RS-232C and RS-485 conversion interface device; the second is to use an RS-485 communication card, which is inserted into the expansion slot of the microcomputer motherboard. The advantage of using the first method is that the hardware device is simple to install and the software programming is relatively simple; the disadvantage is that the communication rate is still limited to 20kbps (limitation of the RS-232C protocol). The advantage of the second method is that the communication rate is relatively high, up to 921.6kbps; the disadvantage is that the communication card needs to be installed on the microcomputer expansion slot, and the software needs to install the communication card driver and make necessary settings.
Characteristics and connection methods of RS-485 communication card
The communication baud rate of the RS-485 communication card is optional from 50bps to 921.6kbps; usually each card has two communication ports, each supporting 32 nodes, a total of 64 nodes; the software environment supports DOS, WINDOWS95, and WINDOWS NT. The communication connection mode can adopt point-to-point half-duplex mode, point-to-point full-duplex mode, multi-point half-duplex mode and multi-point full-duplex mode.
Application of RS-485 communication card
Install driver
The RS-485 communication card comes with a driver. When using the communication card for the first time, you must first install the driver and set the I/O address, interrupt number, communication port number, etc. of the communication card. There is no need to set it again when the system is running in the future.
Features of VB communication software
The communication software in this example is implemented under the WINDOWS95 platform using VB5.0, and the data is stored in the form of random files. Since WINDOWS does not support direct access to system I/O ports, a simple way to implement serial communication under WINDOWS is to use the communication software MSComm provided by VB. Several of the most important and commonly used attributes in MSComm software are: CommPort sets or returns the number of the communication port; its format is: MSComm.Comm Port=n, where no is any integer value from 1 to 99. If the port does not exist, an error will occur when opening the port using the PortOpen property.
Settings sets or returns parameters such as baud rate, data bits, stop bits, etc. For example: MSComm1.Settings="9600,N,8,1"
Among the parameters on the right side of the equal sign, each part represents the communication baud rate. The second part is the check mode, N means no check; E means even check; O means odd check; S means space check; M means sign check. The third part is the number of data bits. Finally, there are the number of stop bits.
PortOpen sets or returns the status of the communication port. If it is TRUE, the communication port is opened; if it is FALSE, the communication port is closed.
Input takes out the receive buffer and returns a string.
Output writes characters to the send buffer.
InBuffSize sets or returns the receive buffer byte value.
InputLen sets or returns the number of strings read each time when reading a string from the buffer; if InputLen is set to 0, when reading the buffer, the entire buffer content is read at one time.
letter of agreement
The physical layer communication protocol adopts the RS-485 standard; the link layer adopts character-oriented protocols; this example adopts the character-based communication protocols actually used by the author on site. The specific data (hexadecimal) format is shown in Table 1.
Table 1
prefix | command code | Data 1 | Data 2 | check | suffix |
FCH | 00H~FEH | 00H~FEH | 00H~FEH | Check word | FFH |
8 bits | 8 bits | 8 bits | 8 bits | 8 bits | 8 bits |
The command code contains the "data resend" command (when verification errors occur). If verification errors occur three times in a row, the system will alarm.
What is particularly mentioned is that this example program is to complete the serial communication between the microcomputer and the microcontroller system. The microcomputer uses the VB software platform and is programmed in the WINDOWS95 environment. Since VB communicates in character (ANSI code) under the WINDOWS environment, while the microcontroller system uses hexadecimal codes, during the communication process, VB must perform special conversion on the data in order to communicate with the microcontroller system.
The data output in the program can only be converted by the CHR() function so that VB can output hexadecimal data and the microcontroller system can receive it normally. See the program list for specific procedures.
Conclusion
With its high communication rate (921kbps), strong anti-interference ability and low price, RS-485 communication card has strong competitiveness in the field of industrial control and is of great practical value. The author successfully applied the RS-485 communication card to the serial communication between the microcomputer and the microcontroller data acquisition system. The microcomputer side used VB to compile the communication and data processing software, and the microcontroller side used assembly language programming. The use of CHR() function in VB for data conversion is the key to realizing hexadecimal data communication between microcomputer and microcontroller.
Previous article:PC and laser range radar dual-channel high-speed data communication interface card
Next article:Application of keyboard interface in communication between microcontroller system and PC
- Popular Resources
- Popular amplifiers
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- R5F1056A Device file not found
- AVR's experience in dog training
- Short circuit protection circuit!!!
- FPGA Verilog Problems
- Help! How to view the pin definition in the Keil file for the STM32F103C8T6 chip?
- Popular Science丨Six Elements of Brushless DC Motor Control
- 555 Classic: 1-100 Minute Timer Circuit
- [RVB2601 Creative Application Development] A Universal (Sensor) Alarm
- How to Design Nearly 100% Duty Cycle for Ultra-Low Power Applications Using WEBENCH
- Features of Storage Products for Embedded and Industrial Applications