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.
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.
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.
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.
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.
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.
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.
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.
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
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
- Get a gift when you grab a building | Infineon Tmall store gives you a surprise!
- These two sources contradict each other.
- 【ST NUCLEO-G071RB Review】_03_Breathing light experiment
- I found out that GigaDevice has become a RISC-V MCU tool chain partner. Will it finally take action after GD32V103?
- [GD32E503 Review] 07 Review of SDIO Bus Driver SD Card (Part 2)
- Recommend a data acquisition card based on Ethernet bus NET-2411
- Why is it sufficient to represent a scalar field with F(X,Y,Z), while a vector field requires three functions: P(X,Y,Z) Q(X,Y,Z) R(X,Y,Z)
- CC2640R2F Bluetooth debugging - change device name
- Selection of external memory for DSP
- How can I simulate the signal receiving process of the 125KHZ card reader/writer circuit?