Monitoring system based on W77E58 dual serial port communication

Publisher:脑洞飞扬Latest update time:2012-03-16 Source: 单片机与嵌入式系统应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

Reference address:Monitoring system based on W77E58 dual serial port communication

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

OK6410A Development Board (V) 1 OK6410A u-boot-2021.01 LCD RGB interface
The LCD driver in u-boot is the LCD driver under the u-boot LCD driver framework, including LCD frame LCD driver The code is https://github.com/lisider/u-boot/tree/ok6410a Submit id: 54c4f9e1ec8017d51234e5909ca39662a257632d General Overview When initializing drv_lcd_init      1. Call the interface function p
[Microcontroller]
Design of LCD Display Voltage Oscilloscope System Based on ARM7 Processor LPC2138
This design uses the ARM7 microprocessor as the core and uses the high-speed A/D in ARM7 as the pressure measurement unit to improve the reliability of data transmission; the data results are displayed in real time through the LCD, and the display method is friendly and intuitive; RAM and UART are used to store and
[Microcontroller]
Design of LCD Display Voltage Oscilloscope System Based on ARM7 Processor LPC2138
Compal sells Kunshan LCD TV factory and has moved part of the production line back to Taiwan
According to Jiwei.com, Taiwan's Compal Group issued an announcement on May 7 on behalf of its subsidiary Compal Video Electronics (Kunshan) Co., Ltd., stating that it will sell real estate to Kunshan New Town Construction Development Co., Ltd. The total transaction amount reached RMB 950 million, and the estimated di
[Mobile phone portable]
LCD1602 usage program in PIC microcontroller
#include pic.h __CONFIG(0x1832);         //Chip configuration word, watchdog off, power-on delay on, power-off detection off, low voltage programming off, encryption, 4M crystal HS oscillation #define rs RA1 #define rw RA2 #define e RA3 const char web ={' ','W','W','W','.','P','I','C','1','6','.','C','O','M',' ',' '}
[Microcontroller]
Design of LCD Image Display System Based on Embedded ARM
0 Introduction With the rapid development of embedded technology and the widespread application of Linux in the information industry, it is possible to use embedded Linux systems to realize image acquisition and processing. Real-time acquisition of image data is an important part of realizing these ap
[Microcontroller]
Design of LCD Image Display System Based on Embedded ARM
Summary of LCD1602 based on 51 single chip microcomputer to realize minute and second timing
Completion requirements 1. Realize the timing of minutes and seconds. 2. Use buttons to control the adjustment of minutes and seconds (two buttons control the increase of minutes and seconds respectively). 3. Realize the function of telling time in whole and minute (buzzer sounds). 4. Drawing and welding of PCB board
[Microcontroller]
Summary of LCD1602 based on 51 single chip microcomputer to realize minute and second timing
Proteus simulation DS1302+LCD1602 display test
Proteus simulation DS1302+LCD1602 display test The simulation effect diagram is as follows: The C language source program is as follows: /* 51 MCU: DS1302+LCD1602 Proteus simulation program. Function: LCD1602 clock and date display. Simulation result: LCD1602 displays the set time and date. */ #include reg52.
[Microcontroller]
Proteus simulation DS1302+LCD1602 display test
LCD TV backlight driver circuit design based on DS3984/DS3988
In LCD TV applications, a variety of architectures can be used to generate the AC waveform required to drive CCFL. The three key design challenges faced when driving multiple CCFLs are selecting the best drive architecture, multi-lamp driving, lamp frequency, and pulse dimming frequency control. This article compare
[Power Management]
LCD TV backlight driver circuit design based on DS3984/DS3988
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号