Design of Chloride Ion and PH Detector Based on Color Sensor TCS230

Publisher:创新火箭Latest update time:2014-01-24 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    Water quality has always been one of the issues that people are more concerned about. The quality of water will seriously affect health and industrial production. Drinking water mainly considers the impact on human health. In addition to physical and chemical indicators, its water quality standards also include microbial indicators; for industrial water, whether it affects product quality or is easy to damage containers and pipes is considered. However, whether it is the testing standard for drinking water or industrial water, pH value and chloride ion concentration are relatively important parameters. If the chloride ion content of drinking water reaches 250 mg/L, when the corresponding cation is sodium, it will feel salty: when the chloride content in water is high, it will damage metal pipes and buildings and hinder plant growth. In addition, chlorination is widely used for tap water disinfection in my country. Studies have shown that in water disinfected by chlorination, there are more than 300 carcinogenic harmful substances such as trichloroethane and tetrachloromethane. Therefore, the control of pH value and chloride ion concentration in water has received more and more attention. To achieve accurate control of pH value and chloride ion concentration in water, it is necessary to first test the water quality and accurately understand the pH value and chloride ion concentration in the water sample. Therefore, the detection of pH value and chloride ion is widely used in environmental protection, water supply, food and other industries. Today, the pH test of water in households is mainly carried out by semi-quantitative manual test paper method. However, this method is too affected by human factors, and different analysts may get different test results for the same sample. There is also a comparative electrochemical determination method. The more common pH portable meter on the market consists of a host and an electrode, and buffers and other chemicals need to be added during operation. However, this method requires the addition of buffers and other chemicals to the water sample, which is cumbersome to operate; and the surface of the pH meter probe is extremely sensitive and easily contaminated by impurities such as oil in the water sample, thus affecting the detection accuracy and analysis quality. For this reason, the high-precision color sensor is combined with the single-chip microcomputer. In the test paper method, the computer is used instead of the human eye to judge the color, thereby improving the accuracy and reducing the error, and realizing the rapid, pollution-free, drug-free and quantitative detection of the pH value of the water sample with reduced human factors.

1 TCS230 color sensor
   
TCS230 is a programmable color light to frequency converter launched by TAOS. It integrates configurable silicon photodiodes and current-frequency converters on a single CMOS circuit. At the same time, three filters, red, green, and blue (RGB for short), are integrated on a single chip. Its output is a square wave with a duty cycle of 50%. The input light intensity is linearly related to the frequency of the square wave. Different filters only allow certain primary colors to pass through and prevent other primary colors from passing through. For example, when the red filter is selected, only red light can pass through the incident light, and blue and green are blocked, so the light intensity of red light can be obtained; similarly, by selecting blue and green filters, the light intensity of blue and green light can be obtained. The color of the light projected onto the TCS230 sensor can be analyzed by the three values ​​of the detected color components. This instrument uses the detected color components to compare with the standard color card, and then outputs the corresponding pH value or chloride ion concentration. The output signal of TCS 230 is a digital quantity that can drive standard TTL or CMOS logic inputs, so it can be directly connected to a microprocessor or other logic circuits. Since the output is digital and can achieve a conversion accuracy of more than 10 bits for each color channel, there is no need for an A/D conversion circuit, making the circuit simpler. Figure 1 is the pin package and functional block diagram of TCS230. S2 and S3 are used to select the type of filter; OE output enable pin can control the output state. When multiple chip pins share the input pin of the microprocessor, it can also be used as a chip select signal; OUT is the frequency output pin, GND is the ground pin of the chip, and VCC provides the operating voltage for the chip.

a.jpg


    Figure 2 shows the effective combination of S0, S1 and S2, S3. L and H represent low level and high level respectively. S0 and S1 are used to select the proportional factor of the frequency output or the power off mode; S2 and S3 are used to select the type of pass filter.

b.jpg



2 Hardware Design
   
The hardware design of the system mainly includes 4 parts: 1) Data acquisition system, which mainly includes the selection of light source, arrangement of sensors and setting of external conditions when TCS230 is used; 2) Control part with 89S52 single chip microcomputer as the core, which realizes the reading of the output frequency of the test paper color signal and the comparison with the standard colorimetric card, and converts the RGB value into chloride ion concentration or pH value; 3) Control panel module, which mainly includes digital tube, LED display and buttons; 4) Power supply module. [page]
2.1 Data acquisition system design
   
In the natural environment, seasonal changes, weather conditions, air agitation and external cover will affect the lighting conditions. For this purpose, a white high-brightness LED lamp with model ZX-35288W42-1 is used, with a forward voltage of 3.0-3.4 V; luminous intensity of 1 500-2 000MCD; forward current of 20 mA; luminous angle of 120 degrees; color temperature of 2700-25 000 K. Under different lighting conditions, the same test paper will also show different colors. In order to eliminate the interference of the external environment and fix the light source, the test paper and the RGB color sensor, a light-proof acquisition probe is designed for this instrument. The light source and the sensor are placed in a confined space as shown in Figure 4. In order to facilitate the fixed installation of the test paper, a test paper slot is designed. The light source and the sensor are fixed on two independent PCB boards respectively, which is convenient for installation and debugging in a confined space. The acquisition probe is based on 5 TES230 chips, equipped with 5 corresponding white light-emitting diodes, and a pure white light source is selected to ensure the stability of the light source. Figure 3 is the principle of our detection. In a closed and completely dark environment, the LED lamp emits white light and shines on the test paper. The test paper reflects its own color light to TCS230. Different colors of light have different wavelengths and frequencies. The sensor converts the light signal into a pulse number and then outputs it to the microcontroller.

c.jpg


    When the light source illuminates the color display area of ​​the test paper, the filter is controlled to select pins S2 and S3, so that the TCS230 chip collects the reflected light of different frequencies, so that the color components RGB can be accurately collected and the data can be output after being processed by the single chip microcomputer. As shown in Figure 4, it is a schematic diagram of the test paper color collection probe structure.

d.jpg


2.2 The control part with the microcontroller as the core
   
AT89S52 has 8k bytes of Flash, 256 bytes of RAM, 32-bit I/O lines, a watchdog timer, 2 data pointers, 3 16-bit timers/counters, full-duplex serial ports, on-chip crystal oscillators and clock circuits. In addition, the AT89S52 can work in 0 Hz static logic and supports 2 software-selectable power-saving modes. In idle mode, the CPU stops working, allowing RAM, timers/counters, serial ports, and interrupts to continue working. In power-off protection mode, the contents of RAM are saved, the oscillator is frozen, and the microcontroller stops all work until the next hardware reset or interrupt, which is conducive to the long-term use of the instrument in the field with battery power. The control circuit with AT89S52 microcontroller as the core mainly includes color recognition circuit and digital tube display circuit. In the color recognition circuit, the P0 port of AT89S52 microcontroller is used to control the five TCS230 logic pins OE through the latch 74H573, so that the five sensors work in sequence, and the control pins S0 and S1 of the output frequency division coefficient ratio are connected to the P1.1 and P1.3 ports respectively, and the RGB color component selection control pins S2 and S3 are connected to the P1.5 and P1.4 ports respectively. By programming the high and low level values ​​of these ports, the automatic control of the selection of several logic pins of TCS230 is realized. The sensor circuit connection is shown in Figure 5.

e.jpg


2.3 Control panel module
   
The control panel module mainly includes digital tube, LED display and key. The digital tube display part controls the bit selection and segment selection of the digital tube display through two latches 74H573 respectively to realize the dynamic display of the digital tube, which is used to display the final output chloride ion concentration or pH value. The LED consists of three colors of red, green and yellow. Green represents that the chloride ion concentration or pH value is within the healthy range; yellow represents that the chloride ion concentration or pH value meets the requirements; red represents that the chloride ion concentration or pH value exceeds the drinking water standard. The key part realizes three functions: chloride ion detection, pH value detection, and white balance. [page]
2.4 Design of power supply circuit
   
The color sampling system must use a stable DC power supply, and the power supply must have good stability. Because the fluctuation of the power supply voltage can cause the instability of the LED light brightness; although the TCS230 color sensor has a strong ability to resist power supply disturbances, its internal chip has high requirements for power supply stability, and voltage fluctuations can cause instability in A/D conversion.
    In order to meet the needs of various workplaces, this instrument provides three power supply methods:
    1) Use the 220 V to 5 V regulated power supply of Xinying Company model XY-965K;
    2) Rechargeable lithium batteries can be used for field power supply after voltage regulation by MAX667. MAX667 is a low-instability linear positive regulator with a maximum output current of 250 mA, a quiescent current of 20 μA when no-load, and a typical instability voltage of 150 mV when outputting 200 mA. The circuit contains an undervoltage detector to detect power failure, and the shutdown control prohibits the output. The quiescent current in the shutdown state is reduced to 0.2 μA. MAX667 has two working modes to select the output voltage. The output can be set to +5 V internally, or the output can be set to +1.3~16 V adjustable by external resistors. This instrument is set to +5 V output.
    3) A stable 5 V power supply is obtained through the following circuit through a 24 V switching power supply as shown in Figure 6, which is mainly used for the establishment experiment of the color card database.

f.jpg



3 Software Design
   
The color detection system includes a white balance correction subroutine, a color sampling subroutine and a color comparison subroutine as shown in Figure 7. The white balance correction subroutine is used for color calibration, and the color comparison subroutine is divided into chloride ion and pH detection subroutines. White balance tells the system what white is. In theory, white light is a mixture of equal amounts of red, green and blue, but in fact, the color component outputs of the RGB color sensor under white light are not equal, because the sensor has different sensitivities to the three basic colors. Therefore, white balance correction is very necessary. The three adjustment parameters of R, G and B are obtained through white balance. When TCS230 is used to identify colors, these three parameters are used to adjust the sampled three color components RGB. Then, the corresponding chloride ion concentration or pH value is obtained by looking up the table through the color comparison subroutine using the adjusted value through the single chip. The program flow chart is shown in Figure 7.

g.jpg



4 Conclusion
   
This paper proposes a new method of test paper detection based on color sensor. In view of the shortcomings of the existing test paper detection method, which mainly relies on human eye observation, the color sensor is creatively introduced into the test paper detection method, which greatly improves the test paper detection accuracy. In addition to detecting pH and chloride ions, it can also be applied to all test paper detection methods. The whole instrument has a beautiful appearance, low cost and easy operation. After testing, the performance of this instrument is reliable and can well realize household water detection.

Reference address:Design of Chloride Ion and PH Detector Based on Color Sensor TCS230

Previous article:Design of Traffic Signal Indicator Light Based on STC Single Chip Microcomputer
Next article:Design of SMT plant temperature and humidity monitoring system based on ZigBee wireless sensor network

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号