Introduction:
Winbond's new single-chip microcomputer W77E58 contains two enhanced serial ports and a 32KB large-capacity Flash memory. The instruction set is fully compatible with the 51 series single-chip microcomputer, and is very suitable for use in intelligent monitoring systems. This system connects three single-phase inverters into a token network, and uses a standard RS485 interface to communicate with the inverter system and the host computer at the same time. It can display the operating status of the inverter system in real time on the LCD screen or the host computer, and can easily modify the system parameters.
1 System Hardware Design
Figure 1 shows the hardware block diagram of the single-machine dual serial port communication of the W77E58 monitoring system. This circuit complies with the simplest RS485 bus interface standard. The inverter system uses Motorola's motor control dedicated chip 68HC908MR16 (hereinafter referred to as MR16) as the main control chip. The chip contains a standard programmable serial communication interface SCI module, which communicates with the serial port 0 of the W77E58 through the RS485 interface chip MAX3082. At the same time, the data transmitted by the serial port 1 of the W77E58 through the MAX3082 communicates with the host computer through an RS485 to RS232 level converter. The communication circuits all use optical coupling isolation.
In Figure 1, Maxim's MAX3082 is used as the RS485 interface chip, which is suitable for half-duplex communication. It uses balanced drive and differential reception, has the ability to suppress common-mode interference, can be used in harsh environments, and has a maximum communication distance of 1200m. It has send enable and receive enable control. When the enable is invalid, the output ends of the send and receive are in a high-impedance state. When MAX3082 is used to form a communication system, the maximum communication rate is 0.125Mb/s, and a maximum of 128 transceivers can be connected to the transmission line.
This system uses a non-encoded keyboard and intends to use four keys: OK, CANCEL, UP, and DOWN. One-key multiplexing technology is used to enable these four keys to complete system settings, parameter modification, and operating status display.
The LCD used here is a CAG1264-4 dot matrix LCD. The LCD has an adjustable brightness backlight, is lightweight and ultra-thin, and has flexible programming. The entire screen can display 8×4 national standard Chinese characters or 16×4 ASCII codes. The hardware interface uses an 8-bit parallel data format, and the handshake protocol is simple and reliable.
Since three-phase AC power is commonly used in industry, this system also has the function of networking three single-phase inverters and self-synchronizing to achieve three-phase AC output. As shown in Figure 2, the serial port outputs of the three single-phase inverters are connected to form a simple token network, and then the upper computer manages and controls them uniformly through the RS485 to RS232 level converter.
2 Introduction to the serial port and initialization settings
In this communication system, we stipulate that each frame of data is 10 bits: 1 start bit, 8 data bits, and 1 stop bit. The baud rate is set to 9600bps. [page]
2.1 W77E58 serial port
The enhanced serial port feature of the W77E58 microcontroller is the unique address automatic recognition and frame error diagnosis function. It should be noted that serial port 0 can use timer T1 or timer T2 as the baud rate generator; while serial port 1 can only use timer T1 as its baud rate generator. The following takes serial port 0 as an example to briefly introduce the working process of the W77E58 serial port. Serial port 0
communicates serially through pins RXD (serial data receiving end) and TXD (serial data transmitting end). It can send and receive data at the same time and has two physically independent receiving and transmitting buffers SBUF, which occupy the same address. The sending and receiving of the serial port are read or written in the name of the special function register SBUF. When the sending of data is completed or the data is received, the hardware will set the sending interrupt flag TI or the receiving interrupt flag RI. It is worth noting that the interrupt flags TI and RI need to be cleared by software. The working process of serial port 1 is similar to that of serial port 0. It only needs to perform similar operations on its corresponding registers and flags. The W77E58 serial port is a programmable interface. To initialize and program it, it only needs to write the corresponding control word to the special function register SCON or SCON1 and the power control register PCON. Here, timer T2 is used as the baud rate transmitter of serial port 0, and timer T1 is used as the baud rate generator of serial port 1. The baud rate is set to 9600bps.
2.2 MR16 serial port
MR16 has a programmable serial communication interface SCI module, which supports full-duplex, asynchronous, NRZ (non-return-to-zero) format serial communication between MCU and peripherals. It has two I/O pins RXD and TXD; there are two physically independent SCI data registers SCDR that occupy the same address. The SCI module provides independent interrupt requests and interrupt vectors for the receiver and transmitter. If the SCRIE bit is set, when the SCI receives a complete data frame and transfers the data to the SCDR, the SCRF flag will be set and a receive interrupt will be started; if the SCTIE bit is set and the data is transferred from the SCDR to the transmit shift register, the SCTE flag will be set to generate a transmit interrupt. After reading the data in the SCDR or writing new data to the SCDR, SCRF and SCTE will be automatically cleared without software operation. The SCI module has a programmable baud rate generator that can generate 32 different baud rates. You only need to set the baud rate register SCBR.
2.3 Host computer serial port
Since the host computer serial port uses the RS232 standard interface, a RS485 and RS232 level converter is required to achieve communication with the lower computer. Here, the level conversion device used is Newton-7520, with an input voltage range of 10 ~ 30V and an allowable frequency range of 300Hz ~ 115kHz.
3 Communication protocol
In this system, MR16, W77E58 and the host computer are both senders and receivers, and all work in half-duplex mode. The sending and receiving of MR16 and the host computer are both in query mode, and the serial port 0 and serial port 1 of W77E58 are both in query mode, and the receiving is in interrupt mode. In order to ensure accurate and reliable communication, in addition to specifying the character format and baud rate, the communication parties must also define the communication protocol. Through analysis and experiments, it was finally determined that the communication between MR16 and W77E58 is mainly based on 77E58. The communication between W77E58 and the host computer is based on the "master-slave communication method" communication protocol with the host computer as the main body. The following takes the serial port 0 of W77E58 and the host computer as an example to introduce this communication protocol.
◆ W77E58 serial port 0 communication protocol (with W77E58 as the host)
Send (query mode):
fe+fe+fe+code......Request to send back the corresponding code data packet
fe+fe+ef+code+high byte+low byte+checksum厖......Send the data packet to be modified
Receive (interrupt mode):
fe+fe+aa+fault code......Receive the fault code
fe+fe+fe+code+high byte+low byte+checksum厖
......Receive the data packet to be displayed
◆ Host computer communication protocol (with the host computer as the host)
Send (query mode):
fe+fe+station number......Query the corresponding station
fe+fe+fe......Request to send back the data packet to be displayed
Receive (query mode):
fe+fe+station number......Receive the check station number sent back
fe+fe+high byte+low byte+checksum
......Receive the data packet to be displayed
The italic in the protocol is the header code, the bold and underlined is the command code, and the station number is the token used to select the single-phase inverter when communicating with multiple machines. The station number of each single-phase inverter is different. The header of the data packet is 0xfe, 0xfe. Take W77E58 serial port 0 as an example. When W77E58 uses command 0xfe to request MR16 to send back the corresponding code data packet, if command 0xaa is received, it indicates that there is a fault, and then the corresponding fault display is performed according to the received fault code; if command 0xfe is received, the received parameter value is sent to the LCD for display.
From the data packet format, it can be seen that the communication between MR16 and W77E58 is mainly based on W77E58, and the communication between W77E58 and the host computer is mainly based on the host computer. The sending and receiving of MR16 are controlled by W77E58 serial port 0, and the sending and receiving of W77E58 serial port 1 are controlled by the host computer. This master-slave mode is a common mode in the RS485 standard. Here, data synchronization is achieved by sending the packet header. The sender must send the packet header first and then send the data each time; the receiver starts to receive data only after receiving the packet header correctly. When the received data is wrong or the sent data is lost, the current reception is abandoned and communication is restarted in the next main cycle. In this way, it can automatically recover after a communication error and avoid the occurrence of "freeze".
4 Software Implementation
Considering the versatility of the monitoring communication system, we adopted a modular design method and treated the communication program as a module of the main program. Because the BCD code starts with the numbers "0" to "9", and the control command starts with the letters "A" to "F", the data is converted into BCD code and sent at the sending end. In this way, the two types of signals can be distinguished and decoded and processed separately at the receiving end.
The MR16 communication module includes a query receiving program and a query sending program, and the program flow is similar to Figure 3; the W77E58 serial port 1 communication module includes an interrupt receiving program and a query sending program. The program flow is similar to that of serial port 0 and is not given here.
Reference
1 WINBOND electronics corp. 8-Bit Microcontroller——W77E58. 2001.7
2 Fail-Safe, High-Speed (10Mbps), Slew-Rate-Limited RS-485/RS-422 Transceivers,MAXIM Document, 1997
3 Advance Information. MC68HC908MR16/MC68HC908MR32?Rev. 4.0. MOTOROLA Document, 2000
4 Li Chaoqing. PC and MCU Data Communication Technology. Beijing: Beijing University of Aeronautics and Astronautics Press, 2000
Previous article:Fast charging system based on ST72 microcontroller
Next article:Design of intelligent monitoring node for anti-corrosion power supply
Recommended ReadingLatest update time:2024-11-16 19:26
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- Recently, there have been frequent incidents of electric vehicle explosions and fires. What do you think about this? ?
- Explanation of several clock frequencies in LPC2478
- (Transfer) Detailed explanation of the CC2640R2F BLE5.0 BLE connection parameter update process
- Real-time Zooming Module of Digital X-ray Image Based on FPGA
- 【LAUNCHXL-CC1350-4】- 5: A method to install XDCTools on Windows 10 has also been found. . .
- There are several packaging issues in PCB components
- Basic questions about capacitors
- Learn Python the Hard Way (Third Edition)
- Robot project looking for partners, reception robot, food delivery robot
- Exposed business---Beijing Aitai United Technology Co., Ltd.