1 Overview
With the development of the Internet, in order to facilitate people to receive emails in real time, this article introduces an "e-mailman" system based on a single-chip microcomputer and Labview. The PC program is written using Labview, and the network communication function is realized by connecting the single-chip microcomputer with the Ethernet controller ENC28J60, and the received emails are displayed through the LED . In order to simplify the system design, this system adopts the method of directly sending 16×16LED dot matrix data. This method can remove the design of the single-chip Chinese character dot matrix library, greatly simplifying the design and reducing costs.
2. Hardware structure
The hardware structure of the e-mailer is shown in the figure above. The single-chip microcomputer uses the AT89C51ED2 launched by ATMEL, which has 64K bytes of FLASH, 2K bytes of RAM, 2K bytes of EEPROM, supports online programming, 6 8-bit general-purpose I/O ports, hardware watchdog timer, serial peripheral interface (SPI) that can work in host and slave mode, 9 interrupt sources, 4 levels of interrupt priority, and 3 16-bit timer counters.
ENC28J60 is a new stand-alone Ethernet controller with only 28 pins launched by MICroChip, which is conducive to creating small, low-cost and streamlined embedded network systems. The ENC28J60 Ethernet controller uses the industry-standard SPI serial interface and only needs 4 lines to connect to the main control microcontroller. It has a built-in 10Mbps Ethernet physical layer device (PHY) and media access controller (MAC), which can reliably send and receive information packet data according to the industry-standard Ethernet protocol. ENC28J60 has programmable filtering functions, special filters, including Microchip's programmable pattern matching filters; it can automatically evaluate, receive or reject MagiCPACket, unicast (Unicast), multicast (Multicast) or broadcast (Broadcast) information packets, reducing the processing load of the main control microcontroller: built-in programmable 8KB dual-port SRAM buffer, can realize flexible and reliable data management mechanism.
2.1 Connection between AT89C51ED2 and ENC2&J60
The ENC28J60 operates at 3.3V and is easily integrated into a 5V system. The SPI's CS, SCK, and SI inputs, as well as the RESET pin, can all withstand 5V: On the other hand, if the host controller runs at 5V, when the SPI and interrupt inputs are driven by the 3.3VCMOS outputs on the ENC28J60, it is likely that they will not meet the specification requirements, and a unidirectional level converter is required. This system uses an inexpensive 74HCT08 (quad AND gate) to provide the necessary level conversion. The conversion circuit is shown in the figure below, with the microcontroller working in host mode and the ENC28J60 working in slave mode.
2.2LED display module
The LED display circuit is shown in the figure above, which adopts row scanning. Among them, the P4 port controls the number of scan rows, the P2 port controls the column register selection, and the PO port sends the LED dot matrix data. The dot matrix data of each word occupies 32 bytes. The single-chip microcomputer first selects the first row, and then selects the first 74LS244; then writes the first byte of the dot matrix data of the first word through the PO port, and then selects the second 74LS244; then writes the 17th byte of the dot matrix data of the first word through the PO port, and then selects the third 74LS244; then writes the first byte of the second word through the PO port, and then writes in sequence until the 17th byte of the dot matrix data of the 16th word; then selects the second row and scans in sequence.
3. Software Design
The MCU first initializes SPI, and then initializes the Ethernet controller ENC28J60 through SPI, and waits for interrupts after initialization. When ENC28J60 receives the email, it sends an interrupt request to the MCU. After the MCU responds to the interrupt, it receives data through SPI. After successfully receiving the data, it sends the feedback information "OK" character, and then displays the email through the LED display, first displaying the first 16 words, and then displaying the last 16 words. In addition, this system can also complete ARP response and PIN g command response.
3.1 Main program design
①MCU SPI control register
The definitions of each bit of SPCONSPCON are shown in the following table. Set SPCON=010101108, that is, the synchronous clock selects FLCKPERIPH/8, enables the serial port, enables, selects the master mode, the idle state is low level, and the rising edge shifts in data.
②ENC28J60 Ethernet control register 1 (ECON1)
The ECON1 register is used to control the main functions of the ENC28J60. The definitions of each bit are shown in the table above. ECON1 contains receive enable, transmit request, DMA control and storage area selection bits. Set ECON1 = OOOO0110B to write the data packet through the current filter into the receive buffer and access the register in Bank2.
It is also necessary to set the Ethernet interrupt enable register EIE, MAC control register MACONi, MAC control register MACONI and MAC address. For detailed setting methods, please refer to the system microcontroller source program and ENC28J60 data sheet.
③ Main program flow chart The main program flow chart is shown in the figure below.
3.2 Interrupt service program design The interrupt service program flow chart is shown in the figure below.
3.3 PC Program Design The PC program is written in Labview. When using Labview (LaboratoryVirtu-), program code is basically not written, but a flow chart is used instead. Labview has built-in library functions of TCP/IP, ActiveX and other software standards that are easy to apply. This system uses Labview's UDP control to implement the UDP protocol, which is convenient and fast.
①PC program interface
The PC program interface is shown in the figure above. Enter the destination address of the email, such as "202.96.170.165" in the destination address box, select the destination port number 8001 and the receiving feedback information port number 8002, then enter the email content and click the Run button to send the email. When the microcontroller receives the email, it will feedback the "OK" message, indicating that the email has been successfully received by the microcontroller.
②PC flow chart
The PC flow chart is shown below.
The upper part of Figure 7 is the sending program, and the lower part is the receiving program. The DLL technology is used to convert Chinese characters into 16x16 dot matrix data in the sending program. The conversion program is made into DLL and can be called in Labview.
4. Conclusion
This system uses the Ethernet controller ENC28J60 to configure the single-chip network system, which has a simple structure and convenient design. It also uses the LED display to display emails, which has a simple solution, low price and strong practical value.
Previous article:Design of airborne operation control system based on AT89S52 UAV aviation remote sensing platform
Next article:Design of CAN bus distributed measurement and control system based on single chip microcomputer AT89C52
Recommended ReadingLatest update time:2024-11-15 16:43
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- The MSP430 I2C bus problem was solved today
- 【NUCLEO-WL55JC2 Review】+ Learn about WL55JC2 and development board hardware
- Are there any good EDA design tool manufacturers in China?
- TI JTAG error message troubleshooting
- Selected CMOS Digital Integrated Circuits
- How do I delete a post?
- MSP430G2553 IO external interrupt description
- DIY low power Bluetooth, USB dual-mode mechanical keyboard—by jj1989
- Infrared remote control
- Let’s discuss the relationship between transformers and inductors again.