Abstract: The development of a high-performance portable PIC microcontroller humidity detector is introduced, and the relevant working principles and key technologies are explained in detail. This tester makes full use of the PIC microcontroller's own software and hardware resources. It has the advantages of intelligence, small portability, and programmability. It is widely used in many fields such as agriculture, hydrological systems, environmental monitoring, and meteorology.
Keywords: PIC microcontroller humidity tester soil moisture content
Timely and accurate measurement of the humidity and soil moisture content of the surrounding environment is widely used in many fields of national economic development. For example, in agriculture, in order to manage soil scientifically, soil moisture content needs to be tested frequently; in water conservancy projects, such as Hydrological stations and dams also need to frequently test soil moisture content. In addition, soil moisture measurement is an indispensable measurement item in environmental protection, meteorology, and national defense construction. How to automate this tedious measurement and related data processing has become an important issue that needs to be solved urgently.
This article introduces a high-performance, portable, programmable humidity tester mainly composed of PIC16C74 microcontroller, and explains in detail the working principle, basic functional block diagram, key technology and corresponding working software process of the instrument.
1 Basic principle and functional block diagram of the instrument
The system hardware structure block diagram of this instrument is shown in Figure 1. The chip uses the PIC16C74 microcontroller with low price and excellent performance. It makes full use of the software and hardware resources it provides and completes soil moisture detection with corresponding peripheral circuits. The main components include: humidity sensor, PIC microcontroller, external memory (E2PROM), touch keyboard, liquid crystal display (LCD), battery power on and off control circuit, and communication interface circuit for transmitting data to the computer.
The sensor uses a patented product. Its function is to directly insert the detection head into the soil to be measured and convert the soil moisture into a corresponding analog voltage. The voltage range is 0~1.2V. The analog voltage is amplified to 0~5V by an operational amplifier. After the voltage is within the range, it is sent to the I/O port of PIC16C74. There are 8 channels of A/D converters in the microcontroller. Select one port as the analog voltage input channel, and then convert it into a digital voltage value according to the voltage-moisture content formula. , after the microcontroller calculation, the actual soil moisture content value is obtained, which is sent to the external extended memory for storage for transmission and processing, and at the same time, it is sent to the LCD screen for real-time display.
This instrument sets each batch of data to consist of 16 bytes, and the external memory capacity is 64K bytes, so the maximum storage capacity of the external memory can reach 512 batches. In order to further process the measurement data, a large amount of data from each test point needs to be sent to the computer. To complete the data transmission, we choose the RS232 standard interface method, and the device uses MAX202 as the interface device. The data is sent to the computer through the I/O interface, and then It is further processed to draw test curves and charts, which are then analyzed, printed and archived.
Due to the small size of the instrument, touch switches are used as buttons, which can complete functions such as power control (ON), measurement (MEASURE), page forward (UP), page back (DN), clear (CLEAR), and approval (ACK). Allow users to operate flexibly. The power supply is powered by a 9V standard battery, and a special power control circuit controls the power on and off. The PIC16C7 microcontroller monitors the battery power supply. When the voltage is within the normal working range, the LCD screen displays "H". When it is lower than the set standard voltage, it displays " L", indicating that the battery needs to be replaced.
Because the tester we developed uses a high-performance microcontroller chip, it has abundant available software and hardware resources, requires fewer peripheral devices, has strong functions, has low power consumption, and has a wide range of applications.
2 Key components and key technologies
2.1 PIC16C74 microcontroller
This instrument chip uses the PIC16C7 microcontroller produced by the American Microchip Company. This chip is a low-power, high-performance, affordable CMOS fully static 8-bit E2PROM single-chip microprocessor. It is 400IP and has an I/O port of 33 pins, suitable for installing more peripheral devices and equipment.
The PIC16C7 chip contains 192 bytes of data memory (RAM) and 4K bytes of program memory (ROM) capacity, 33 output/input ports, three timers/counters, three capture/compare/PWM modulus and two serial ports , the synchronous serial port can be configured as three-wire SPI or two-wire 120 working mode, the serial port can be set as synchronous or asynchronous, and the eight-channel high-speed A/D converter part. In terms of software structure, it adopts RISC instruction structure, with an 8-level stack, multiple internal and external interrupt bits, and 35 instructions, making it easy to program.
Compared with other microcontrollers (such as 8031 chips), PIC16C7 has the following characteristics that other chips cannot match:
·It has 8 internal A/D conversion channels. This alone eliminates the need for additional A/D conversion peripheral chips when A/D conversion is required;
·There are only 35 software instructions, implemented through programming;
·Low power consumption, high-speed CMOS EPROM technology, only consumes 2mA at 5V 4MHz, and only 15mA at 3V 32KHz;
·More importantly, the chip has a sleep function, that is, it performs Sleep working mode. In this mode, the chip consumes very little (less than 1mA). When the chip needs to work again, the chip can be woken up through internal or peripheral interrupts. into normal working mode;
·With confidentiality function.
2.2A/D conversion
The PIC16C7 microcontroller has 8 analog input ports, sharing a sample/hold. The sample/hold is compared successively, and finally the analog quantity is converted into a digital quantity. For this tester, the input is the analog voltage sent by the sensor, and its value is Changes in the range of 0~1.2V, and the amplified voltage enters the microcontroller for A/D conversion and calculation processing. The A/D conversion circuit is shown in Figure 2.
In addition, the analog reference voltage of the A/D converter is RA3/ref, and the pin voltage is +5v. When designing this circuit, the following work needs to be done:
·Accuracy calculation and error of A/D conversion
Convert analog voltage 0~1.25vV into 8-bit binary digital, whose 1LSB=1.25/256=4.9mV≈5mV, when VDD=5V±10%, and Vref=5v, the full range of A/D conversion The accuracy is less than 1LSB, which includes offset error, full-scale error, and integer error, and the A/D conversion is monotonic.
Since VDD is less than 5V or Vref is less than VDD, the resolution and accuracy will be reduced, so we adopt the following two measures in the design. One is to use VDD=5V, and Vref==SV; the other is to amplify the input through an operational amplifier to make the input analog The voltage changes within the range of 0~5V.
· Requirements for input analog signals
The analog input needs ESD protection, so a reverse bias diode is added between VDD and VCS to protect the device from damage. At the same time, it is required that the external device connected to the analog input pin should have extremely low leakage current.
·A/D sampling requirements
For A/D conversion to achieve a specific accuracy, the input channel voltage needs to fully charge the holding capacitor. The formula is: sampling time = amplifier stabilization time + holding capacitor charging time + temperature coefficient, which can be obtained.
·A/D conversion clock selection
The clock is selected as 4MHz.
2.3 Keyboard control
PIC16C74 has five I/O ports PORTA ~ PORTE. PORTE is a bidirectional port. The four pins RB (4 ~ 7) of port B. When the pins are set to input mode, the status of these four pins changes. will cause an interruption. Utilizing the characteristics of the B port, it is easy to interface with an external control keyboard. This instrument is designed with a 2×4 keyboard with a total of 8 control keys. The keyboard control circuit is shown in Figure 3. In order to sample the keyboard, first prohibit the digital current sink, and then use software to set port B so that RB4~RB7 are input terminals and RB2~RB3 are output terminals to high level. Allow the pull-up of RB4~RB7, make RB2~RB3 low level in sequence, and detect RB4 to RB7 at the same time to see if there is a keystroke (low level). Each scan will find multiple keystrokes. Once a keystroke is detected key, before restarting keyboard sampling, after a 40ms debounce time, no other keystrokes will be detected until the current key is released.
2.4 LCD display
The tester displays the LCD display EDM-1601A, which can display 16 ASCII characters at the same time. Each character consists of a 5×7 dot matrix. The internal control circuit of this device mainly consists of an instruction register, a data register, an address register, and a display It is composed of data register, character generator and timing generator. The display screen of this instrument is shown in Figure 4.
Position 0 displays the battery voltage status. When the battery voltage is >7.5V, "H" is displayed to indicate that the battery voltage is normal. When the battery voltage is <=7.5V, "L" is displayed, indicating that the voltage is too low and the battery needs to be replaced. Digits 1 to 3 show the number of test batches. This tester can test up to 512 batches of data. Position 4 is a space. Digits 5 to 10 display the voltage value of the measured point, in millivolts (mV). The numbers from 11 to 15 show the moisture content percentage of this test point.
Each time the measurement key is pressed, the relevant voltage value of the test point and the converted water content value are displayed, and these values are simultaneously sent to the external memory for storage.
2.5 Serial communication
In order to conduct in-depth analysis of the collected data, the data needs to be transferred from the external memory of the tester to the computer. PIC16C74 has a serial communication interface (SCI). SCI is a full-double interface that can communicate with peripherals such as CRT terminals and computers. Industrial asynchronous system, this instrument adopts RS-232-C interface mode, and the transmission baud rate is 9600 bits. The data transmission format is shown in Figure 5. In this way, SCI uses the standard non-return to zero (NRZ) format, starting with a start bit, represented by a logic "0", followed by 8 data bits, and finally It is a stop bit, represented by logic "1". This instrument does not have a parity bit, so the length of data transmitted at one time is 10 bits. The interface chip is MAX232, and the receiving end (computer) uses receiving software edited in C language to display the received data and perform further processing, such as summarizing it into a data table, drawing analysis curves, and printing results, etc. for the staff. refer to.
2.6 Power control
This instrument is powered by a standard 9V dry battery. In order to ensure normal power supply, the power supply needs to be controlled in the following three aspects.
·To control the power on and off, press the ON key on the keyboard, and the 9V voltage will be output through the MAX667 (MAX company) to provide the 5V voltage required by the instrument;
·Battery voltage test circuit, assuming that the standard 9V dry battery is lower than a specified voltage under loading, the instrument cannot work normally and the battery needs to be replaced. To achieve this purpose, the battery voltage needs to be continuously monitored;
·Automatic shutdown function: After the test is completed, if the instrument is not operated, the power circuit will automatically disconnect after one minute to realize the automatic shutdown function.
The above three types of control are all completed by the MAX667 device, and the specific circuit is shown in Figure 6.
3. Control software design of detector
This detector is programmed in PIC16CXX assembly language. The control software consists of main control program, key function detection, measurement and moisture content calculation, display, clearing, forward and backward page display, communication and other subroutines. Figure 7 is the control software block diagram.
4 Characteristics and development prospects
The basic features of this testing instrument are:
·Small size, 150×80×60mm3, can be carried in your pocket to various test points for data sampling;
·Large amount of data collected: due to the addition of external E2PROM memory, 512 batches or 1024 batches of data can be sampled, calculated and stored;
·Through the communication interface, the collected data can be sent to the computer for further processing, such as drawing test curves, analyzing, printing results and storing data;
·It is powered by a 9V dry battery. In order to reduce power consumption and extend the use time, the instrument is controlled by a special control circuit. It will automatically shut down after a certain time. During the measurement interval, it enters the sleep state to save energy. Other devices try to use CMOS low-power and low-current devices;
·The instrument is intelligent and programmable. Due to the use of advanced microcontroller, A/D conversion and various mathematical calculations can be performed inside the microcontroller. Through software programming, data can be viewed (pages forward and backward), data in external memory can be cleared, and data can be transferred to the instrument. The computer sends data, and these functions can be selected through the corresponding buttons on the instrument panel.
To sum up, this tester makes full use of the software and hardware resources of the PIC16C74 microcontroller, and has the advantages of intelligence, small portability, and programmability. In addition, this tester only needs to replace the sensor and modify the control software to expand to other environmental parameters. Testing applications make this tester widely used in agriculture, hydrological systems, environmental protection, meteorology and many other fields.
references
1PIC16C6X/7X/8X microcontroller application manual. Wuhan Liyuan Electronics Co., Ltd.1996
2 "Principle of PICC16CXX series microcontroller". Wuhan Liyuan Electronics Co., Ltd.1997
3 Compiled by Wang Shiyuan and Wu Zhifang. 1BM PC/XT (Great Wall 0520) interface technology and application. Tianjin: Nankai University Press, 1991
(Date of receipt: 1999-06-23)
Previous article:Automobile fault self-diagnosis system and fault diagnosis instrument V. A. G1551 Research
Next article:Measurement of the flatness of piano key arrangement
- Popular Resources
- Popular amplifiers
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- 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
- What do these two options mean?
- Multisim square wave phase shift circuit diagram
- [Digi-Key Contest] 100 electronic design kits worth up to 600 yuan will be given away for free, and DIY can also win a cash prize of 10,000 yuan!
- Introduction to the theoretical knowledge of four-axis
- An essential handbook for engineers: a practical design guide for switching power supplies
- What happened to Microsoft's underwater data center that sank to the bottom of the sea for 2 years?
- [GD32L233C-START Review] OLED screen display driver
- Questions about op amp TIA circuit
- Deping Technology Shenzhen Co., Ltd.
- I have never understood several parameters of MOS tubes. Please help me explain them.