1 System Hardware Design
1.1 Overall system structure
The system design adopts I2C bus, single host and multiple slaves working mode to realize multi-point temperature collection, reading and display. The host is composed of main controller, digital tube display, power supply, alarm, keyboard and other modules, and completes the following functions: 1) The host determines the node entering the temperature measurement state and the node to read the temperature by pressing the key: 2) The host reads the node temperature value from the bus and displays it; 3) When idle, it enters the time display state by pressing the key. The clock uses the real-time clock RTC inside the microcontroller and the external 6 MHz crystal oscillator. The CPU runs when powered off and wakes up every 0.5 s; the slave is composed of digital temperature sensors, etc., to complete the following functions: 1) Collect the real-time temperature value of the node; 2) Respond to the request of the host and send temperature data.
The multi-point temperature acquisition system based on I2C bus uses P89LPC922 single-chip computer with hardware I2C bus function as the main controller, and uses digital temperature sensor LM75A and digital tube display driver and keyboard scan management device ZLG7290 with I2C function devices. LM75A collects the real-time temperature value of the node and sends the temperature data through I2c bus. ZLG7290 drives the LED digital tube to display the temperature value and time. SPXll17 is used to design the power module to provide 3.3V voltage. The hardware block diagram of the system is shown in Figure 1.
1.2 Circuit design of each module
1.2.1 Controller Module
The main controller uses the P89LPC922 MCU. This MCU is a single-chip packaged microcontroller, suitable for those occasions that require high integration and low cost, and meets various performance requirements. It integrates keyboard interrupt, serial interface (UART/I2C), watchdog timer, and uses advanced 2-clock technology. The instruction execution speed is 6 times that of the traditional 80C51. It supports multiple power-saving modes such as idle, power-down, clock pre-division, etc. In addition, its 4 interrupt priority structure provides great flexibility for the processing of multiple interrupt sources.
According to the keyboard interrupt characteristics of the main controller P89LPC922 microcontroller, the keyboard module can directly control three I/O ports to realize three buttons, and its schematic diagram is shown in Figure 2.
This design uses a buzzer to implement the alarm process, and uses the open-drain method of the I/O port to control the buzzer. The indicator light circuit is composed of 2 LEDs, and the push-pull output method of the I/O port is used to drive the LED.
1.2.2 Temperature acquisition module
LM75A is a temperature-to-digital converter that uses a built-in bandgap temperature sensor and ∑-△ analog-to-digital conversion technology. This design uses two LM75A chips to collect temperature values at two points. The schematic diagram is shown in Figure 3.
1.2.3 Display Module
ZLG7290B is a digital tube display driver and keyboard scan management device, which can directly drive 8-bit common cathode digital tubes (or 64 independent LEDs). Here, only the digital tube display driver function of ZLG7290B is used, and its keyboard function is not used, so the circuit is greatly simplified, and its schematic diagram is shown in Figure 4.
2 Software Programming
I2C is a multi-master bus that can be controlled by multiple devices. General I2C devices have a unique address to ensure the accuracy of control. The normal I2C bus transmission rate is 100 Kbit/s. In the newly added high-speed mode, it can reach a rate of 3.4 Mbit/s to support some high-speed transmission applications, such as large-capacity Flash memory.
The LPC900 series MCU integrates the I2C bus internally, and can be used as both a master device and a slave device on the I2C bus. It has four I2C bus transceiver modes: master transmitter mode, master receiver mode, slave transmitter mode, and slave receiver mode.
The I2C software package of this design adopts the hardware I2C bus interrupt mode. The bus competition and synchronization logic of the hardware I2C cannot be simulated by software. This software package works in the master mode of the hardware I2C. It includes applying for the bus, sending byte data, receiving byte data, etc., and facing other module programs are several normalized subroutines, which can be called by setting a few entry parameters.
Figure 5 and Figure 6 are the real-time clock and keyboard interrupt service processes, respectively. The real-time clock generates an interrupt every 0.5s, and the keyboard uses three keys, each of which can generate an interrupt when pressed. The main function of this design completes the CPU power-off operation to minimize system power consumption. The CPU will only be woken up when there is a key interrupt and a real-time clock interrupt.
3 System Testing
3.1 Hardware Testing
Use a multimeter to test the soldered circuit board. First, test the circuit part. Each circuit is connected normally without short circuit or open circuit. Secondly, after power on, the power light is on, proving that the power connection is normal. The power supply voltage input is 5 V, the output is 3.3 V, and the power supply circuit works normally. The remaining modules pass the software test.
3.2 Software Testing
The transmission of the I2C bus is verified by the ZLG7290 test program, and its timing is observed using a logic analyzer, as shown in Figure 7.
As can be seen from Figure 7, the timing part completes the process of making the first digital tube display "0", a complete process from starting the bus to ending the bus. In this process, a total of 4 bytes of data are sent. After the bus is started, the slave address of ZLG7290 is sent, followed by a read-write bit 0, which represents the first address of the command buffer. After each byte is sent, a response bit 0 will be received, indicating that the data has been received. The following 2 bytes are compound instructions, which are bit-by-bit data download and decoding instructions, even if the first digital tube displays 0. After sending the instruction, the end bus condition follows, indicating that the sending process is over.
The LM75A test program sends data to the slave. After receiving the response bit 0, the slave sub-address is sent immediately. Here, it is the first address of the ZLG7290 command buffer. After each byte is sent, an response bit 0 is received, indicating that the data is received. The following two bytes are compound instructions, which are bit-by-bit data download and decoding instructions, even if the first digital tube displays 0. After sending the instruction, the end bus condition is followed, indicating that the sending process is over. Verify the process of receiving data on the I2C bus, and use a logic analyzer to observe its timing, as shown in Figure 8.
As can be seen from Figure 8, this timing part completes the process of reading the temperature value, and is also a process of receiving data with a repeated start condition on an I2C bus. This process is divided into two parts: sending and receiving. The sending part includes sending the slave address and the slave sub-address, that is, the address 90H of the LM75A and the first address 00H of the LM75A temperature register. Then restart the bus to prepare for receiving data. In this part, the host first sends the slave address, followed by the read-write bit 1, indicating that the host will receive the data sent by the slave. Then the host receives 2 bytes of data. After the host sends the response bit, it sends a stop condition to end the bus, indicating that the host has received the data once.
3.3 System comprehensive test
Burn the program into P89LPC922. After power on, the digital tube displays "0000". Use buttons 2 and 3 to set the initial value of the clock. When the temperature value read exceeds the set temperature range, the buzzer will sound an alarm. At this time, you can cancel the sound by pressing button l and switch to clock display.
4 Conclusion
This system is a measurement system that comprehensively processes multi-point temperature information. The design system has a simple structure, convenient operation, high measurement accuracy, fast speed, and can realize alarm. The temperature measurement range of this system is -55~+125℃, and the measurement accuracy can reach 0.125℃. Due to the use of the I2C bus structure, the entire system occupies fewer I/O ports of the main controller, and the remaining I/O ports can be reserved for system expansion. This system can be used for temperature detection in the plant growth environment, and an alarm will be issued when the temperature exceeds the suitable growth range of the plant.
Previous article:Summary of using MSP430 timer interrupt!
Next article:Freescale 9S12 Series MCU Application Notes (SCI) 3
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
- The "Soul" of the Microcontroller - The Use of Data Memory
- Detailed Explanation of I2C Bus Protocol
- What is the difference between package 0603 and R0603 (or 0603R)?
- [Sipeed LicheeRV 86 Panel Review] 2. Data Links
- [Yatli AT32F421 Review] Doubts from EXTI disconnection
- TI DSP CAN online program upgrade question
- List of instruments, equipment and main components for the 2019 National Undergraduate Electronic Design Competition
- Has this condition reached the level of shock (moderate)?
- TE wireless connectivity unleashes the unlimited potential of the Internet of Things. Join the challenge and win great prizes!
- Please tell me about the stop mode of RL78