CN109270016B - Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm - Google Patents

Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm Download PDF

Info

Publication number
CN109270016B
CN109270016B CN201811138395.6A CN201811138395A CN109270016B CN 109270016 B CN109270016 B CN 109270016B CN 201811138395 A CN201811138395 A CN 201811138395A CN 109270016 B CN109270016 B CN 109270016B
Authority
CN
China
Prior art keywords
water quality
module
water
box body
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201811138395.6A
Other languages
Chinese (zh)
Other versions
CN109270016A (en
Inventor
严如强
杨建勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Southeast University
Original Assignee
Southeast University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Southeast University filed Critical Southeast University
Priority to CN201811138395.6A priority Critical patent/CN109270016B/en
Publication of CN109270016A publication Critical patent/CN109270016A/en
Application granted granted Critical
Publication of CN109270016B publication Critical patent/CN109270016B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • G—PHYSICS
    • G01—MEASURING; TESTING
    • G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N21/00—Investigating or analysing materials by the use of optical means, i.e. using sub-millimetre waves, infrared, visible or ultraviolet light
    • G01N21/17—Systems in which incident light is modified in accordance with the properties of the material investigated
    • G01N21/25—Colour; Spectral properties, i.e. comparison of effect of material on the light at two or more different wavelengths or wavelength bands
    • G01N21/31—Investigating relative effect of material at wavelengths characteristic of specific elements or molecules, e.g. atomic absorption spectrometry
    • G01N21/33—Investigating relative effect of material at wavelengths characteristic of specific elements or molecules, e.g. atomic absorption spectrometry using ultraviolet light
    • G—PHYSICS
    • G01—MEASURING; TESTING
    • G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N33/00—Investigating or analysing materials by specific methods not covered by groups G01N1/00 - G01N31/00
    • G01N33/18—Water
    • G—PHYSICS
    • G01—MEASURING; TESTING
    • G01N—INVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N33/00—Investigating or analysing materials by specific methods not covered by groups G01N1/00 - G01N31/00
    • G01N33/18—Water
    • G01N33/1806—Biological oxygen demand [BOD] or chemical oxygen demand [COD]
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00—Pattern recognition
    • G06F18/20—Analysing
    • G06F18/23—Clustering techniques
    • G06F18/232—Non-hierarchical techniques
    • G06F18/2321—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions
    • G06F18/23213—Non-hierarchical techniques using statistics or function optimisation, e.g. modelling of probability density functions with fixed number of clusters, e.g. K-means clustering

Landscapes

  • Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Chemical & Material Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • Pathology (AREA)
  • Data Mining & Analysis (AREA)
  • Immunology (AREA)
  • General Health & Medical Sciences (AREA)
  • Biochemistry (AREA)
  • Analytical Chemistry (AREA)
  • Medicinal Chemistry (AREA)
  • Food Science & Technology (AREA)
  • Spectroscopy & Molecular Physics (AREA)
  • Theoretical Computer Science (AREA)
  • Evolutionary Biology (AREA)
  • Emergency Medicine (AREA)
  • Molecular Biology (AREA)
  • Evolutionary Computation (AREA)
  • Biomedical Technology (AREA)
  • Biodiversity & Conservation Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Artificial Intelligence (AREA)
  • Probability & Statistics with Applications (AREA)
  • General Engineering & Computer Science (AREA)
  • Sampling And Sample Adjustment (AREA)

Abstract

The invention discloses a multifunctional underwater water quality automatic monitoring system and a monitoring method based on a clustering algorithm. When the monitor works, different reagents are used for titrating the current water sample, and the ultraviolet light source is controlled to emit different lights to monitor different water quality parameters; and meanwhile, the lower computer controls the sliding module to enable the box body to move up and down in the vertical direction, so that a plurality of water quality parameters of different water depths are collected. The system can measure COD, nitrogen content and PH value in different water depths, and upload data to the upper computer through the data access module for data processing based on the clustering algorithm, thereby realizing multifunction and automation of water quality monitoring, avoiding secondary pollution, saving cost, improving water quality monitoring accuracy and data processing and analyzing comprehensiveness.

Description

基于聚类算法的多功能水下水质自动监测系统及监测方法Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm

技术领域technical field

本发明涉及水质监测装置和方法,尤其是涉及基于聚类算法的多功能水下水质自动监测系统及监测方法。The invention relates to a water quality monitoring device and method, in particular to a multifunctional underwater water quality automatic monitoring system and monitoring method based on a clustering algorithm.

背景技术Background technique

随着工业的发展,水质污染越来越严重,化学需氧量(COD)与含氮量、PH值均能反映水中受还原性物质污染的程度,是衡量环境质量的重要标准,目前,水质的测定传统方法一般采用化学方法,主要采用重铬酸钾标准法、库仑滴定法,根据水质氯离子浓度的不同其监测方法也不同,淡水一般使用重铬酸钾法、酸性高锰酸钾法,海水使用碱性高锰酸钾法。但这些传统方法都存在试剂用量大,二次污染严重、测试时间长、操作步骤繁杂、测量对象单一、自动化程度低的缺点,已不适应现代化的市场需求。With the development of industry, water pollution has become more and more serious. Chemical oxygen demand (COD), nitrogen content and PH value can reflect the degree of water pollution by reducing substances, which is an important standard for measuring environmental quality. At present, water quality The traditional method for the determination of water quality generally adopts chemical methods, mainly using potassium dichromate standard method and coulometric titration method. , seawater using alkaline potassium permanganate method. However, these traditional methods all have the disadvantages of large amount of reagents, serious secondary pollution, long test time, complicated operation steps, single measurement object, and low degree of automation, which are not suitable for the modern market demand.

水质测量的分光光度测量法是在滴定法的测量基础上进行的,使用吸收光谱原理,根据溶液内滴定完成后试剂内离子含量多少,分别采用不同波长的紫外光源测量不同浓度的水质待测溶液的吸光度,因此依据所得吸光度工作曲线,可以表示出水样中化学需氧量、含氮量、PH值。分光光度测量法是滴定法的一种改进,节省试剂,操作方便。但现存的仪器大多只能测量水质的一种参数,而不能完成多参数的统一测量,这也导致了水质测量结果的片面性及不准确性,因此如何研究一种新型的支持多参数同时测量的水质监测仪器迫在眉睫。The spectrophotometric method of water quality measurement is carried out on the basis of titration measurement, using the principle of absorption spectrum, according to the ion content of the reagent after the titration in the solution is completed, using ultraviolet light sources of different wavelengths to measure the water quality of the solution to be tested with different concentrations. Therefore, according to the obtained absorbance working curve, the chemical oxygen demand, nitrogen content and PH value in the water sample can be expressed. Spectrophotometry is an improvement of titration, which saves reagents and is easy to operate. However, most of the existing instruments can only measure one parameter of water quality, and cannot complete the unified measurement of multiple parameters, which also leads to one-sided and inaccurate water quality measurement results. Water quality monitoring equipment is imminent.

市场现存的基于分光光度法的水质监测仪一般需要配套相应生产公司的专用试剂,且必须要人为的滴定试剂,需要人工取样,人工操作完成各个水质监测步骤,因此浪费了大量的人力物力财力,且取得的水样单一,不能体现不同深度的水域环境下的水质情况,监测结果不理想,而且水质监测仪器在不同测量环境下的兼容能力很差,对于水域环境的实际测量片面,测量速度及精度有待提高,且仪器价格昂贵、体积巨大操作步骤复杂不便于实际应用。故如何实现集多功能、价格低廉、数据动态存取与离线处理、现场测量与远距离监测、人工测量与自动化测量、不同水深水质测量、测量简单精确、快速便携于一体是水质监测仪器所面临的迫切问题之一。The existing spectrophotometry-based water quality monitors generally need to be equipped with special reagents from the corresponding production companies, and must require artificial titration reagents, manual sampling, and manual operations to complete various water quality monitoring steps, so a lot of human, material and financial resources are wasted. Moreover, the obtained water samples are single and cannot reflect the water quality in different depths of water environment. The monitoring results are not ideal, and the compatibility of water quality monitoring instruments in different measurement environments is very poor. The actual measurement of the water environment is one-sided, and the measurement speed and The accuracy needs to be improved, and the instrument is expensive and bulky, and the operation steps are complicated and inconvenient for practical application. Therefore, how to realize the integration of multi-function, low price, dynamic data access and offline processing, on-site measurement and remote monitoring, manual measurement and automatic measurement, water quality measurement at different water depths, simple and accurate measurement, fast and portable is the face of water quality monitoring instruments. one of the pressing issues.

发明内容SUMMARY OF THE INVENTION

发明目的:一个目的是提供基于聚类算法的多功能水下水质自动监测系统及监测方法,以解决现有技术与应用存在的上述问题,扩展水质监测仪功能,改进水质监测仪对不同水深下的多个参数的自动化测量功能及野外测量功能。Purpose of the invention: One purpose is to provide a multifunctional underwater water quality automatic monitoring system and monitoring method based on a clustering algorithm, so as to solve the above-mentioned problems existing in the existing technology and application, expand the function of the water quality monitor, and improve the water quality monitor for different water depths. Automatic measurement function and field measurement function of multiple parameters.

技术方案:为实现上述发明目的,本发明采用以下技术方案:Technical scheme: In order to realize the above-mentioned purpose of the invention, the present invention adopts the following technical scheme:

一种基于聚类算法的多功能水下水质自动监测系统,包括上位机和监测仪,上位机包括Labview界面设计部分及Python数据处理部分,上位机通过Labview设计GUI界面,借助内部接口函数调用Python函数采用聚类算法完成样本数据处理,监测仪包括可伸缩固定支架、盒体、下位机、滑动模块和电源模块。其中:A multifunctional underwater water quality automatic monitoring system based on a clustering algorithm, including a host computer and a monitor, the host computer includes a Labview interface design part and a Python data processing part, the host computer designs a GUI interface through Labview, and calls Python with the help of internal interface functions The function uses the clustering algorithm to complete the sample data processing. The monitor includes a retractable fixed bracket, a box body, a lower computer, a sliding module and a power supply module. in:

可伸缩固定支架下端固定于水中,用于固定整个监测仪;The lower end of the retractable fixing bracket is fixed in the water to fix the entire monitor;

盒体密封,顶端开有一孔,盒体外部置有一个测量开关,盒体内壁设有防水层,且下位机和电源模块位于防水层里面;The box body is sealed, a hole is opened at the top, a measuring switch is placed outside the box body, a waterproof layer is arranged on the inner wall of the box body, and the lower computer and the power module are located in the waterproof layer;

下位机内置于盒体内,用于控制滑动模块和采集水质参数数据,并将采集的水质参数数据上传至上位机;The lower computer is built in the box and is used to control the sliding module and collect water quality parameter data, and upload the collected water quality parameter data to the upper computer;

滑动模块用于连接盒体与可伸缩固定支架;The sliding module is used to connect the box body and the retractable fixing bracket;

电源模块内置于盒体内,包括直流电源驱动模块和电压放大模块,直流电源驱动模块输出与电压放大模块输入连接,电压放大模块输出端分别与各模块电源输入端连接,为监测仪各模块供电;The power module is built in the box, including a DC power drive module and a voltage amplifier module. The output of the DC power drive module is connected to the input of the voltage amplifier module, and the output end of the voltage amplifier module is respectively connected to the power input end of each module to supply power to each module of the monitor;

下位机控制滑动模块,使盒体在垂直方向上上下移动,进而采集不同水深的多个水质参数。The lower computer controls the sliding module, so that the box body moves up and down in the vertical direction, and then collects multiple water quality parameters of different water depths.

可选的,可伸缩固定支架包括上下两节不锈钢铁管,上节为伸缩节,下节为固定节,伸缩节下端带有一个弹簧插销,固定节上分布有多个与弹簧插销配合的固定孔,当把弹簧插销插到不同的固定孔时,整个可伸缩固定支架具有不同的高度,伸缩节和固定节通过弹簧插销和固定孔固定连接。Optionally, the telescopic fixing bracket includes two upper and lower sections of stainless steel iron pipes, the upper section is a telescopic section, the lower section is a fixed section, the lower end of the telescopic section is provided with a spring latch, and the fixed section is distributed with a plurality of fixed sections that cooperate with the spring latches. When the spring bolts are inserted into different fixing holes, the entire telescopic fixing bracket has different heights, and the telescopic section and the fixing section are fixedly connected through the spring bolts and the fixing holes.

可选的,下位机包括单片机、多通道分光光度测量水质模块和数据存取模块,多通道分光光度测量水质模块测量水质信息转换为电信号,然后输出至单片机进行处理,单片机处理后将数据输出至数据存取模块,由上位机从数据存取模块读取数据。Optionally, the lower computer includes a single-chip microcomputer, a multi-channel spectrophotometric water quality measurement module, and a data access module. The multi-channel spectrophotometric water quality measurement module converts the measured water quality information into electrical signals, which are then output to the single-chip microcomputer for processing, and the single-chip computer outputs the data after processing. To the data access module, the host computer reads data from the data access module.

可选的,单片机包括控制单元、外部RTC、外部晶振、信号调理放大电路和多通道ADC转换模块,多通道分光光度测量水质模块包括固定底座、双通道分光光度器、试管固定装置、硅光电池传感器1、硅光电池传感器2、紫外光源1、紫外光源2、滴定槽和水阀,双通道分光光度器固定在固定底座上,在试管固定装置内壁设有光路通断开关,用于盛放待测试剂的试管放置在试管固定装置内,且试管开口正对盒体顶部开孔,水阀设置于试管固定装置上端,当待测水质灌满至液面在水阀以上时,控制单元控制水阀闭合,打开滴定槽滴定当前试管内的水质;外部RTC和外部晶振均与控制单元连接,控制单元通过输出PWM波控制两个紫外光源发出不同强度及频率的紫外光,紫外光分别经过分光光度器内部通道照射到对应的硅光电池传感器上,然后光信号经过硅光电池传感器转换为电信号,并输入信号调理放大电路对该电信号进行放大处理,最后经过多通道ADC转换模块输入控制单元处理。Optionally, the single-chip microcomputer includes a control unit, an external RTC, an external crystal oscillator, a signal conditioning and amplifying circuit, and a multi-channel ADC conversion module, and the multi-channel spectrophotometric water quality measurement module includes a fixed base, a dual-channel spectrophotometer, a test tube fixture, and a silicon photocell sensor. 1. Silicon photocell sensor 2, ultraviolet light source 1, ultraviolet light source 2, titration tank and water valve, the dual-channel spectrophotometer is fixed on the fixed base, and the inner wall of the test tube fixing device is provided with an optical path on-off switch, which is used to hold the test tube. The test tube of the reagent is placed in the test tube fixing device, and the opening of the test tube is facing the opening on the top of the box body, and the water valve is set at the upper end of the test tube fixing device. Close, open the titration tank to titrate the water quality in the current test tube; both the external RTC and the external crystal oscillator are connected to the control unit, and the control unit controls the two ultraviolet light sources to emit ultraviolet light of different intensities and frequencies by outputting PWM waves, and the ultraviolet light passes through the spectrophotometer respectively. The internal channel is irradiated on the corresponding silicon photocell sensor, and then the optical signal is converted into an electrical signal by the silicon photocell sensor, and the electrical signal is amplified by the input signal conditioning and amplifying circuit, and finally processed by the multi-channel ADC conversion module input control unit.

可选的,数据存取模块包括SD卡数据动态存取模块和EEPROM数据缓存模块,SD卡数据动态存取模块分别与控制单元和上位机双向连接,EEPROM数据缓存模块与控制单元连接。Optionally, the data access module includes an SD card data dynamic access module and an EEPROM data cache module, the SD card data dynamic access module is bidirectionally connected to the control unit and the host computer respectively, and the EEPROM data cache module is connected to the control unit.

可选的,滑动模块包括步进电机、定滑轮与动滑轮,定滑轮固定在可伸缩固定支架的上端,动滑轮固定于盒体靠近可伸缩固定支架一侧的外侧壁上,并与可伸缩固定支架相连接,步进电机固定在盒体上部,由定滑轮引出的牵引线套接在步进电机输出轴上,单片机控制步进电机顺时针或者逆时针转动,带动盒体在垂直方向上上下移动,且动滑轮随盒体上下移动。Optionally, the sliding module includes a stepping motor, a fixed pulley and a movable pulley, the fixed pulley is fixed on the upper end of the telescopic fixing bracket, and the movable pulley is fixed on the outer wall of the box body on the side close to the telescopic fixing bracket, and is connected with the telescopic fixing bracket. The stepper motor is fixed on the upper part of the box body, the traction wire drawn from the fixed pulley is sleeved on the output shaft of the stepper motor, and the single chip controls the stepper motor to rotate clockwise or counterclockwise, which drives the box body to move up and down in the vertical direction. , and the movable pulley moves up and down with the box body.

本发明另一实施例中,一种基于聚类算法的多功能水下水质自动监测系统的监测方法,包括以下步骤:In another embodiment of the present invention, a monitoring method for a multifunctional underwater water quality automatic monitoring system based on a clustering algorithm includes the following steps:

(1)开始测量前先调试监测仪:将可伸缩固定支架长度调整到适应当前水位的高度,将可伸缩固定支架插入水下,插稳固定;(1) Debug the monitor before starting the measurement: adjust the length of the retractable fixing bracket to the height suitable for the current water level, insert the retractable fixing bracket into the water, and insert it firmly;

(2)判断测量开关是否被打开,若测量开关已打开,则给控制单元输入当前水深及盒体每次下降单位高度值,并执行步骤(3);若否,则继续执行步骤(2);(2) Judging whether the measuring switch is turned on, if the measuring switch is turned on, input the current water depth and the unit height value of the box body each time to the control unit, and execute step (3); if not, continue to execute step (2) ;

(3)开始监测前,判断当前已下降高度是否大于等于输入的水深值,若在开始监测前就发现当前已下降高度大于等于输入的水深值,则说明步骤(2)输入有误,需要返回步骤(2)重新输入当前水深及盒体每次下降单位高度值;若否,则执行步骤(4);(3) Before starting monitoring, judge whether the current descended height is greater than or equal to the input water depth value. If it is found that the current descended height is greater than or equal to the input water depth value before starting monitoring, it means that the input in step (2) is wrong and needs to return Step (2) re-input the current water depth and the unit height value of the box body falling each time; if not, then execute step (4);

(4)控制单元控制步进电机正转,使盒体下降一个单位高度值,并监测当前水深位置的不同水质参数值;(4) The control unit controls the forward rotation of the stepper motor, so that the box body drops by a unit height value, and monitors different water quality parameter values at the current water depth position;

(5)一次测量结束,控制单元重新计算并判断当前已下降高度是否大于等于输入的水深值,若否,则表示仪器还没有到达水底,返回步骤(4)执行;若是,则执行步骤(6);(5) After one measurement is over, the control unit recalculates and judges whether the current descended height is greater than or equal to the input water depth value. If not, it means that the instrument has not reached the bottom, and returns to step (4) to execute; if so, execute step (6) );

(6)控制单元控制步进电机反转,使盒体上升一个单位高度值;(6) The control unit controls the stepper motor to reverse, so that the box body rises by a unit height value;

(7)控制单元计算并判断当前已上升高度是否大于等于输入的水深值,若否,则表示仪器还没有到达水面以上,返回步骤(6)执行;若是,则表示盒体已经到达水面以上,控制单元将测量结果存入数据存取模块,本次测量结束;(7) The control unit calculates and judges whether the current raised height is greater than or equal to the input water depth value. If not, it means that the instrument has not reached the water surface, and returns to step (6) to execute; if so, it means that the box body has reached the water surface. The control unit stores the measurement results in the data access module, and the measurement ends;

(8)待测量结束后,将数据存取模块连接到上位机上,Labview通过内部函数接口读取数据存取模块内部存储的数据作为待处理的样本数据集,Labview通过内部接口函数调用Python函数采用聚类算法完成样本数据处理,并通过Labview设计GUI界面进行显示。(8) After the measurement, connect the data access module to the host computer, Labview reads the data stored in the data access module through the internal function interface as the sample data set to be processed, and Labview calls the Python function through the internal interface function to use The clustering algorithm completes the sample data processing and displays it through the Labview design GUI interface.

进一步的,步骤(4)中监测当前水深位置的多个水质参数值的方法为:Further, in step (4), the method for monitoring the multiple water quality parameter values of the current water depth position is:

(1)当盒体到达既定位置后,控制单元控制打开水阀,让外界水质顺着盒体上方的进水口流入试管内,若灌入的水质水面到达水阀以上,控制单元控制水阀关闭,达到取水样的目的;(1) When the box body reaches the predetermined position, the control unit controls the opening of the water valve, so that the external water quality flows into the test tube along the water inlet above the box body. If the water level of the injected water reaches above the water valve, the control unit controls the water valve to close. , to achieve the purpose of taking water samples;

(2)控制单元根据当前需要测量的水质参数控制滴定槽用不同的试剂滴定当前水样,滴定完成后关闭滴定槽;(2) The control unit controls the titration tank to titrate the current water sample with different reagents according to the water quality parameters that currently need to be measured, and closes the titration tank after the titration is completed;

(3)控制单元输出频率为i的PWM波到紫外光源,使其发出相应频率及强度的紫外光,采用分光光度法测量当前水质参数α,用两个硅光电池传感器分别测N次,去掉最大值及最小值后取其平均值,并将当前水质参数结果分别存储在SD卡内;其中水质参数α为水质的COD浓度、含氮量或PH值,i表示获取到当前水质参数α所需要的PWM波的频率。(3) The control unit outputs a PWM wave with a frequency of i to the ultraviolet light source, so that it emits ultraviolet light of the corresponding frequency and intensity. The current water quality parameter α is measured by spectrophotometry, and the two silicon photocell sensors are used to measure N times respectively, and remove the maximum value. value and the minimum value, take the average value, and store the current water quality parameter results in the SD card respectively; where the water quality parameter α is the COD concentration, nitrogen content or PH value of the water quality, and i represents the current water quality parameter α required to obtain frequency of the PWM wave.

进一步的,步骤(8)中上位机采用聚类算法对样本数据进行处理,具体包括:Further, in step (8), the host computer adopts a clustering algorithm to process the sample data, which specifically includes:

系统借助Labview直接调用Python接口函数打开Python控制台,借助Python内置的scikit-learn包内KMeans函数编码聚类算法程序,当接口正常连接,打开Pyhon控制台后,需要先导入通过数据存取模块输入到上位机部分的不同位置、不同水深处的水质监测数据集作为样本数据集D,通过用户输入的k值,从D中随机选择k个样本作为初始均值向量,计算数据集中的每个样本数据与均值向量内的各个子向量之间的距离,距离度量函数采用高斯函数计算:dij=||xj-ui||2,1≤i≤k,1≤j≤m,其中,dij表示样本数据与均值向量之间的高斯距离,xj表示待划分地样本数据,ui表示经过聚类形成的样本簇,将样本xj划分到距离最近的簇中,然后重新计算新的均值向量,并判断与之前的均值向量是否一致,若一致则聚类完成,样本数据集被划分成k个簇,若不一致则重复上面的计算步骤,直到均值向量不再变化为止。The system uses Labview to directly call the Python interface function to open the Python console, and uses the KMeans function in the built-in scikit-learn package in Python to encode the clustering algorithm program. When the interface is connected normally, after opening the Python console, you need to import the input through the data access module first. The water quality monitoring data sets of different positions and water depths in the upper computer part are taken as the sample data set D. According to the k value input by the user, k samples are randomly selected from D as the initial mean vector, and each sample data in the data set is calculated. The distance from each sub-vector in the mean vector, the distance metric function is calculated by using a Gaussian function: d ij =||x j -u i || 2 , 1≤i≤k, 1≤j≤m, where d ij represents the Gaussian distance between the sample data and the mean vector, x j represents the sample data to be divided, ui represents the sample cluster formed by clustering, divide the sample x j into the nearest cluster, and then recalculate the new The mean vector is determined and whether it is consistent with the previous mean vector. If it is consistent, the clustering is completed, and the sample data set is divided into k clusters. If it is inconsistent, the above calculation steps are repeated until the mean vector no longer changes.

有益效果:与现有技术相比,本发明采用了多通路的分光光度法测量不同水深处的COD、含氮量、PH值,实现仪器自动化、避免二次污染、节约成本、提高水质监测准确度及全面性的同时,节省了大量人力物力财力,同时,仪器支持现场测量、远程监测,尤其适用于野外水质测量;仪器通过采用多通道测量不同水质参数,有效的减少了无关因素对于水质测量的干扰,使测量更加精确快速;引入SD卡数据动态存取功能,使操作更加简单方便。Beneficial effects: compared with the prior art, the present invention adopts multi-channel spectrophotometry to measure COD, nitrogen content and pH value at different water depths, realizes instrument automation, avoids secondary pollution, saves costs, and improves the accuracy of water quality monitoring. At the same time, it saves a lot of manpower, material and financial resources. At the same time, the instrument supports on-site measurement and remote monitoring, especially suitable for field water quality measurement; the instrument uses multiple channels to measure different water quality parameters, effectively reducing irrelevant factors for water quality measurement. interference, making the measurement more accurate and fast; the introduction of the SD card data dynamic access function makes the operation easier and more convenient.

同时,现存的水质监测仪器只完成了单一的数据采集功能,对于后期的数据处理并没有太多的涉及,且由于水质监测的参数众多,难以对样本数据添加合适的标签以评估水质的好坏,机器学习领域的聚类算法适用于无标签数据集的分类及数据处理工作,通过对无标记训练样本的学习来解释数据内在性质及规律,既可以用于寻找数据内在的分布结构,也可作为分类等其它学习任务的前驱。同时仪器体积小方便携带,且价格低廉,更加贴近于实际应用,一定程度上满足了工业与个人需求,有助于进一步改善环境污染问题,具有很高的社会实用价值与环保价值。At the same time, the existing water quality monitoring instruments only complete a single data collection function, and there is not much involvement in the later data processing, and due to the numerous parameters of water quality monitoring, it is difficult to add appropriate labels to the sample data to evaluate the quality of water quality. , the clustering algorithm in the field of machine learning is suitable for the classification and data processing of unlabeled data sets. By learning the unlabeled training samples to explain the inherent nature and laws of the data, it can be used to find the inherent distribution structure of the data, or As a precursor to other learning tasks such as classification. At the same time, the instrument is small in size, easy to carry, and low in price, which is closer to practical applications. It meets the needs of industry and individuals to a certain extent, and helps to further improve the problem of environmental pollution. It has high social practical value and environmental protection value.

附图说明Description of drawings

图1是本发明监测仪结构示意图;Fig. 1 is the structural representation of monitor of the present invention;

图2是本发明监测仪电路连接示意图;Fig. 2 is the circuit connection schematic diagram of the monitor of the present invention;

图3是本发明的测量流程图;Fig. 3 is the measurement flow chart of the present invention;

图4是本发明的测量不同水质参数的方法流程图;Fig. 4 is the method flow chart of measuring different water quality parameters of the present invention;

图5是本发明的聚类算法原理图。FIG. 5 is a schematic diagram of the clustering algorithm of the present invention.

具体实施方式Detailed ways

下面结合附图和具体实施例对本发明的技术方案进行详细的说明。The technical solutions of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

本发明实施基于聚类算法的多功能水下水质自动监测系统及监测方法,能够实现多通道分光光度法测量不同水深处水质COD浓度、含氮量、PH值,自动化完成不同水深处的水质取样、滴定、参数测量、SD卡数据动态存取、现场测量及离线监测与数据处理功能。其中STM32F103RBT6为主芯片(即控制单元,下同),协调各模块有序工作。The invention implements a multifunctional underwater water quality automatic monitoring system and monitoring method based on a clustering algorithm, which can realize multi-channel spectrophotometry to measure the COD concentration, nitrogen content and PH value of water quality at different water depths, and automatically complete water quality sampling at different water depths. , titration, parameter measurement, SD card data dynamic access, on-site measurement and offline monitoring and data processing functions. Among them, STM32F103RBT6 is the main chip (that is, the control unit, the same below), which coordinates the orderly work of each module.

一种基于聚类算法的多功能水下水质自动监测系统,包括上位机和监测仪,上位机包括Labview界面设计部分及Python数据处理部分,上位机通过Labview设计GUI界面,借助内部接口函数调用Python完成样本数据处理,所述样本数据是从数据存取模块读取到上位机的、由多个测量得到的水质参数组成的数据集,并随着新的水质参数的增加,此数据集是动态可变的。监测仪包括可伸缩固定支架、盒体、下位机、滑动模块和电源模块。仪器测量自动化,测量参数全面,测量结果简单精确,尤其适合于离线水质监测与野外不同水深处水质监测。其中,可伸缩固定支架下端固定于水中,用于固定整个监测仪;盒体密封,顶端开有一孔,盒体外部置有一个测量开关,盒体内壁设有防水层,且下位机和电源模块位于防水层里面;下位机内置于盒体内,用于控制滑动模块和采集水质参数数据,并将采集的水质参数数据上传至上位机;滑动模块用于连接盒体与可伸缩固定支架;电源模块内置于盒体内,包括直流电源驱动模块和电压放大模块,直流电源驱动模块输出与电压放大模块输入连接,电压放大模块输出端分别与各模块电源输入端连接,为监测仪各模块供电。A multifunctional underwater water quality automatic monitoring system based on a clustering algorithm, including a host computer and a monitor, the host computer includes a Labview interface design part and a Python data processing part, the host computer designs a GUI interface through Labview, and calls Python with the help of internal interface functions Complete sample data processing, the sample data is a data set composed of multiple measured water quality parameters read from the data access module to the host computer, and with the increase of new water quality parameters, this data set is dynamic Variable. The monitor includes a retractable fixed bracket, a box, a lower computer, a sliding module and a power module. The instrument measurement is automated, the measurement parameters are comprehensive, and the measurement results are simple and accurate, especially suitable for offline water quality monitoring and water quality monitoring at different water depths in the wild. Among them, the lower end of the retractable fixing bracket is fixed in the water to fix the entire monitor; the box body is sealed with a hole at the top, a measuring switch is placed outside the box body, the inner wall of the box is provided with a waterproof layer, and the lower computer and the power module It is located in the waterproof layer; the lower computer is built in the box, which is used to control the sliding module and collect water quality parameter data, and upload the collected water quality parameter data to the upper computer; the sliding module is used to connect the box body and the retractable fixing bracket; the power module It is built in the box and includes a DC power drive module and a voltage amplifier module. The output of the DC power drive module is connected to the input of the voltage amplifier module, and the output end of the voltage amplifier module is respectively connected to the power input end of each module to supply power to each module of the monitor.

如图1和图2所示,基于聚类算法的多功能水下水质自动监测仪,其中,可伸缩固定支架由两节高度可调节的不锈钢铁管组成,可根据水深调节其长度,所述可伸缩固定支架可调的长度足够长且保证最高点超过水面至少一个盒体高度的距离,从而保证盒体在初始位置时是在水面之上的;可伸缩固定支架分为上下两节,上节为伸缩节,下节为固定节,伸缩节下端带有一个弹簧插销,固定节上每隔相同距离分布有多个固定孔,把弹簧插销插到不同的固定孔时,整个可伸缩固定支架具有不同的高度,需要调节高度时只需要将弹簧插销摁到固定孔内则可以上下移动伸缩节,调节可伸缩固定支架高度。当盒体需要下降时,只需要控制步进电机转动,则盒体会通过定滑轮及动滑轮沿着可伸缩固定支架下降一段距离。As shown in Figures 1 and 2, the multifunctional underwater water quality automatic monitor based on the clustering algorithm, wherein the retractable fixed bracket is composed of two sections of stainless steel pipes with adjustable height, the length of which can be adjusted according to the water depth. The adjustable length of the retractable fixing bracket is long enough to ensure that the highest point exceeds the height of the water surface by at least one box body, so as to ensure that the box body is above the water surface in the initial position; the retractable fixing bracket is divided into upper and lower sections, the upper The section is a telescopic section, the lower section is a fixed section, the lower end of the telescopic section is provided with a spring latch, and the fixed section is distributed with a plurality of fixing holes at the same distance. It has different heights. When you need to adjust the height, you only need to press the spring latch into the fixing hole to move the telescopic joint up and down to adjust the height of the telescopic fixing bracket. When the box body needs to be lowered, it is only necessary to control the rotation of the stepper motor, and the box body will be lowered for a certain distance along the retractable fixed bracket through the fixed pulley and the movable pulley.

所述盒体只有进水口处有开口,其余四面均密封,且在盒体内置防水层防止仪器进水损坏电路,盒体内设置有下位机和电源模块,盒体上部还设置有测量开关,用于启动和关闭监测仪;盒体通过滑动模块与可调节固定支架相连。The box body only has an opening at the water inlet, the other four sides are sealed, and a waterproof layer is built in the box body to prevent the water ingress of the instrument from damaging the circuit. It is used to start and close the monitor; the box body is connected to the adjustable fixed bracket through the sliding module.

所述下位机包括单片机、多通道分光光度测量水质模块和数据存取模块,单片机作为仪器的核心板,置于盒体底部,分别与其它模块相连,完成数据处理与命令控制,所述单片机包含控制单元、外部RTC、外部晶振、信号调理放大电路和多通道ADC转换模块,所述多通道分光光度测量水质模块包括固定底座、双通道分光光度器、试管固定装置、硅光电池传感器1、硅光电池传感器2、紫外光源1、紫外光源2、滴定槽和水阀,双通道分光光度器固定在固定底座上,在试管固定装置内壁设有光路通断开关,用于盛放待测试剂的试管放置在试管固定装置内,且其开口正对盒体进水口,水阀设置于试管固定装置上端,当待测水质灌满至液面在水阀以上时,控制单元控制水阀闭合,打开滴定槽滴定当前试管内的水质;外部RTC和外部晶振均与控制单元连接,控制单元通过输出PWM波控制两个紫外光源发出不同强度及频率的紫外光,双通道分光光度器中部开有两个交叉放置的光通道,光通道的两端分别放置紫外光源以及硅光电池传感器,紫外光分别经过分光光度器内部通道照射到对应的硅光电池传感器上,然后光信号经过硅光电池传感器转换为电信号,然后输入信号调理放大电路对该电信号进行放大处理,最后经过多通道ADC转换模块输入控制单元处理;采用两个紫外光源可分别测量不同数据范围的水质参数,滴定槽内放置有不同的足量滴定试剂,用于滴定水质原液形成待测试剂,水阀与控制单元的引脚直接相连并由控制单元直接控制其开闭。所述控制单元采用ARM处理芯片STM32F103RBT6,所述信号调理放大电路包括由OPA2336UA芯片组成的电压放大电路以及阻容滤波电路,用于模拟信号的放大及滤波;所述多通道ADC转换模块搭载了AD7705高精度模数转换芯片,采集精度可达16位,采用SPI方式与控制单元通信,并采用DMA方式,实现多通道信号同时采集。The lower computer includes a single-chip microcomputer, a multi-channel spectrophotometric water quality measurement module and a data access module. The single-chip microcomputer, as the core board of the instrument, is placed at the bottom of the box, and is respectively connected with other modules to complete data processing and command control. The single-chip microcomputer includes A control unit, an external RTC, an external crystal oscillator, a signal conditioning amplifier circuit, and a multi-channel ADC conversion module. The multi-channel spectrophotometric water quality measurement module includes a fixed base, a dual-channel spectrophotometer, a test tube fixture, a silicon photocell sensor 1, and a silicon photocell Sensor 2, UV light source 1, UV light source 2, titration tank and water valve, the dual-channel spectrophotometer is fixed on the fixed base, and there is an optical path on-off switch on the inner wall of the test tube fixing device, which is used for the test tube containing the test agent. In the test tube fixing device, and its opening is facing the water inlet of the box body, the water valve is set at the upper end of the test tube fixing device. When the water to be tested is filled to the point where the liquid level is above the water valve, the control unit controls the water valve to close and open the titration tank. Titrate the water quality in the current test tube; the external RTC and the external crystal oscillator are connected to the control unit, and the control unit controls the two ultraviolet light sources to emit ultraviolet light of different intensities and frequencies by outputting PWM waves. The two ends of the optical channel are respectively placed with an ultraviolet light source and a silicon photocell sensor. The ultraviolet light is irradiated to the corresponding silicon photocell sensor through the internal channel of the spectrophotometer, and then the optical signal is converted into an electrical signal through the silicon photocell sensor, and then input The signal conditioning and amplifying circuit amplifies the electrical signal, and finally it is processed by the multi-channel ADC conversion module input control unit; two ultraviolet light sources can be used to measure water quality parameters in different data ranges respectively, and different sufficient titration reagents are placed in the titration tank. , used to titrate the water quality stock solution to form the test agent, the water valve is directly connected to the pin of the control unit, and the control unit directly controls its opening and closing. The control unit adopts the ARM processing chip STM32F103RBT6, and the signal conditioning and amplifying circuit includes a voltage amplifying circuit composed of an OPA2336UA chip and a resistance-capacitance filter circuit for amplifying and filtering analog signals; the multi-channel ADC conversion module is equipped with AD7705 High-precision analog-to-digital conversion chip, the acquisition accuracy can reach 16 bits, using SPI mode to communicate with the control unit, and using DMA mode to achieve simultaneous acquisition of multi-channel signals.

所述数据存取模块包括SD卡数据动态存取模块和EEPROM数据缓存模块,SD卡数据动态存取模块分别与控制单元和上位机双向连接,所述EEPROM数据缓存模块与控制单元连接;完成数据的离线存储。所述电源模块内置于盒体内,包括直流电源驱动模块和电压放大模块,直流电源驱动模块输出与电压放大模块输入连接,电压放大模块输出端分别与各模块电源输入端连接,为仪器各模块供电。所述电压放大模块由直流电源驱动模块供电,根据多个PT1301芯片分别设计放大电路,分别为不同模块提供工作电压。所述直流电源驱动模块由两节1.5v干电池组成。The data access module includes an SD card data dynamic access module and an EEPROM data cache module, the SD card data dynamic access module is bidirectionally connected to the control unit and the host computer, and the EEPROM data cache module is connected to the control unit; complete data offline storage. The power module is built into the box, including a DC power drive module and a voltage amplifier module. The output of the DC power drive module is connected to the input of the voltage amplifier module, and the output terminals of the voltage amplifier module are respectively connected to the power input terminals of each module to supply power to each module of the instrument. . The voltage amplifying module is powered by a DC power supply driving module, and an amplifying circuit is designed according to a plurality of PT1301 chips to provide working voltages for different modules respectively. The DC power drive module consists of two 1.5v dry batteries.

所述滑动模块包括步进电机、定滑轮与动滑轮,定滑轮固定在可伸缩固定支架的顶端,动滑轮固定于盒体靠近可伸缩固定支架一侧的外侧壁上,并与可伸缩固定支架紧密贴合,步进电机固定在盒体上部,由定滑轮引出的牵引线套接在步进电机输出轴上,若步进电机顺时针或者逆时针旋转则会带动盒体在垂直方向上移动,动滑轮在垂直方向上上下移动,动滑轮在随盒体上下移动的同时,起到润滑盒体移动以及将盒体固定到可伸缩固定支架上的作用。其中,步进电机固定端被焊接在盒体左上方,盒体通过滑动模块与可伸缩固定支架连接,通过控制步进电机转动,达到调整自身高度、测量不同水深处的水质情况的目的。The sliding module includes a stepping motor, a fixed pulley and a movable pulley. The fixed pulley is fixed on the top of the telescopic fixing bracket, and the movable pulley is fixed on the outer side wall of the box body near the telescopic fixing bracket, and is closely attached to the telescopic fixing bracket. The stepping motor is fixed on the upper part of the box body, and the traction wire drawn from the fixed pulley is sleeved on the output shaft of the stepping motor. If the stepping motor rotates clockwise or counterclockwise, it will drive the box body to move in the vertical direction, and the moving pulley It moves up and down in the vertical direction, and the movable pulley moves up and down with the box body, and plays the role of lubricating the movement of the box body and fixing the box body to the telescopic fixing bracket. Among them, the fixed end of the stepping motor is welded on the upper left of the box body, and the box body is connected with the retractable fixed bracket through the sliding module. By controlling the rotation of the stepping motor, the purpose of adjusting its own height and measuring the water quality of different water depths is achieved.

如图3所示,基于聚类算法的多功能水下水质自动监测仪整体监测水质的方法如下:As shown in Figure 3, the overall monitoring method of the multifunctional underwater water quality automatic monitor based on the clustering algorithm is as follows:

(1)开始测量前先调试监测仪:将可伸缩固定支架长度调整到适应当前水位的高度,将可伸缩固定支架插入水下,插稳固定;(1) Debug the monitor before starting the measurement: adjust the length of the retractable fixing bracket to the height suitable for the current water level, insert the retractable fixing bracket into the water, and insert it firmly;

(2)判断测量开关是否被打开,若测量开关已打开,则给控制单元输入当前水深及盒体每次下降单位高度值,并执行步骤(3);若否,则继续执行步骤(2);(2) Judging whether the measuring switch is turned on, if the measuring switch is turned on, input the current water depth and the unit height value of the box body each time to the control unit, and execute step (3); if not, continue to execute step (2) ;

(3)开始监测前,判断当前已下降高度是否大于等于输入的水深值,若在开始监测前就发现当前已下降高度大于等于输入的水深值,则说明步骤(2)输入有误,需要返回步骤(2)重新输入当前水深及盒体每次下降单位高度值;若否,则执行步骤(4);(3) Before starting monitoring, judge whether the current descended height is greater than or equal to the input water depth value. If it is found that the current descended height is greater than or equal to the input water depth value before starting monitoring, it means that the input in step (2) is wrong and needs to return Step (2) re-input the current water depth and the unit height value of the box body falling each time; if not, then execute step (4);

(4)控制单元控制步进电机正转,使盒体下降一个单位高度值,并监测当前水深位置的不同水质参数值;(4) The control unit controls the forward rotation of the stepper motor, so that the box body drops by a unit height value, and monitors different water quality parameter values at the current water depth position;

(5)一次测量结束,控制单元重新计算并判断当前已下降高度是否大于等于输入的水深值,若否,则表示仪器还没有到达水底,返回步骤(4)执行;若是,则执行步骤(6);(5) After one measurement is over, the control unit recalculates and judges whether the current descended height is greater than or equal to the input water depth value. If not, it means that the instrument has not reached the bottom, and returns to step (4) to execute; if so, execute step (6) );

(6)控制单元控制步进电机反转,使盒体上升一个单位高度值;(6) The control unit controls the stepper motor to reverse, so that the box body rises by a unit height value;

(7)控制单元计算并判断当前已上升高度是否大于等于输入的水深值,若否,则表示仪器还没有到达水面以上,返回步骤(6)执行;若是,则表示盒体已经到达水面以上,本次测量结束;(7) The control unit calculates and judges whether the current raised height is greater than or equal to the input water depth value. If not, it means that the instrument has not reached the water surface, and returns to step (6) to execute; if so, it means that the box body has reached the water surface. This measurement is over;

(8)待测量结束后,将数据存取模块连接到上位机上,Labview通过内部函数接口读取数据存取模块内部存储的数据作为待处理的样本数据集,Labview通过内部接口函数调用Python函数采用聚类算法完成样本数据处理,并通过Labview设计GUI界面进行显示。(8) After the measurement, connect the data access module to the host computer, Labview reads the data stored in the data access module through the internal function interface as the sample data set to be processed, and Labview calls the Python function through the internal interface function to use The clustering algorithm completes the sample data processing and displays it through the Labview design GUI interface.

参见图4,所述步骤(4)中测量不同水质参数的具体方法及步骤为:Referring to Figure 4, the concrete methods and steps of measuring different water quality parameters in the step (4) are:

(41)当盒体到达既定位置后,控制单元控制打开水阀,让外界水质顺着盒体上方的进水口流入试管内,若灌入的水质水面到达水阀以上,控制单元控制水阀关闭,达到取水样的目的;(41) When the box body reaches the predetermined position, the control unit controls the opening of the water valve, so that the external water quality flows into the test tube along the water inlet above the box body. If the water level of the injected water reaches above the water valve, the control unit controls the water valve to close. , to achieve the purpose of taking water samples;

(42)控制单元根据当前需要测量的水质参数控制滴定槽用不同的试剂滴定当前水样,滴定完成后关闭滴定槽;(42) the control unit controls the titration tank to titrate the current water sample with different reagents according to the water quality parameters currently required to be measured, and closes the titration tank after the titration is completed;

(43)控制单元输出频率为i的PWM波到紫外光源,使其发出相应频率及强度的紫外光,采用分光光度法测量当前水质参数α,用两个硅光电池传感器分别测N次,去掉最大值及最小值后取其平均值,并将当前水质参数结果分别存储在SD卡内;其中水质参数α为水质的COD浓度、含氮量或PH值,i表示获取到当前水质参数α所需要的PWM波的频率。(43) The control unit outputs a PWM wave with a frequency of i to the ultraviolet light source, so that it emits ultraviolet light of the corresponding frequency and intensity, uses the spectrophotometry to measure the current water quality parameter α, and uses two silicon photocell sensors to measure N times respectively, remove the maximum value and the minimum value, take the average value, and store the current water quality parameter results in the SD card respectively; where the water quality parameter α is the COD concentration, nitrogen content or PH value of the water quality, and i represents the current water quality parameter α required to obtain frequency of the PWM wave.

参见图5,聚类算法是机器学习领域一种常见的无监督学习算法,适用于训练样本的标记时未知的情况,目标是通过对无标记训练样本的学习来揭示样本数据的内在性质及规律,为进一步的数据分析做准备,其本质是将样本数据集划分为若干互不相交的子集,即样本簇,其聚类结果好坏通过簇内相似度与簇间相似度来评判,在此系统中采用k-means均值算法完成聚类,将样本数据分成若干簇,分类结果通过Labview用户界面显示,经过聚类算法处理过后的样本数据,会根据水质内部参数特性自动聚在一起,形成k个样本簇,用户可根据生成的样本簇对不同地点不同深度的水质进行划分,有区别的判断不同水质污染情况,也可以通过对水质较差区域或水深的样本簇进行分析,发现这一区域水质污染主要的影响因素是水质的哪种参数(COD、PH、含氮量等)、水质污染较严重的区域一般存在于水的哪一层深度位置,k值由用户自己输入指定。Referring to Figure 5, the clustering algorithm is a common unsupervised learning algorithm in the field of machine learning. It is suitable for cases where the labeling of training samples is unknown. The goal is to reveal the inherent nature and laws of sample data through the learning of unlabeled training samples. , to prepare for further data analysis, the essence of which is to divide the sample data set into several disjoint subsets, that is, sample clusters. The clustering results are judged by the similarity within clusters and between clusters. In this system, the k-means algorithm is used to complete the clustering, and the sample data is divided into several clusters, and the classification results are displayed through the Labview user interface. There are k sample clusters. Users can divide the water quality at different locations and depths according to the generated sample clusters, and judge different water pollution conditions differently. They can also analyze the sample clusters in areas with poor water quality or water depth to find this The main influencing factors of regional water pollution are which parameters of water quality (COD, PH, nitrogen content, etc.), and which depth of water generally exists in areas with more serious water pollution. The k value is input and specified by the user.

上述步骤(8)中,上位机采用聚类算法对样本数据进行处理,具体包括:In the above step (8), the host computer uses a clustering algorithm to process the sample data, which specifically includes:

系统借助Labview直接调用Python接口函数打开Python控制台,借助Python内置的scikit-learn包内KMeans函数编码聚类算法程序,当接口正常连接,打开Pyhon控制台后,需要先导入通过数据存取模块输入到上位机部分的不同位置、不同水深处的水质监测数据集作为样本数据集D,通过用户输入的k值,从D中随机选择k个样本作为初始均值向量,计算数据集中的每个样本数据与均值向量内的各个子向量之间的距离,距离度量函数采用高斯函数计算:dij=||xj-ui||2,1≤i≤k,1≤j≤m,其中,dij表示样本数据与均值向量之间的高斯距离,xj表示待划分地样本数据,ui表示经过聚类形成的样本簇,将样本xj划分到距离最近的簇中,然后重新计算新的均值向量,并判断与之前的均值向量是否一致,若一致则聚类完成,样本数据集被划分成k个簇,若不一致则重复上面的计算步骤,直到均值向量不再变化为止,实际操作中直接用KMeans函数可代替上面的计算步骤完成聚类任务。The system uses Labview to directly call the Python interface function to open the Python console, and uses the KMeans function in the built-in scikit-learn package in Python to encode the clustering algorithm program. When the interface is connected normally, after opening the Python console, you need to import the input through the data access module first. The water quality monitoring data sets of different positions and water depths in the upper computer part are taken as the sample data set D. According to the k value input by the user, k samples are randomly selected from D as the initial mean vector, and each sample data in the data set is calculated. The distance from each sub-vector in the mean vector, the distance metric function is calculated by using a Gaussian function: d ij =||x j -u i || 2 , 1≤i≤k, 1≤j≤m, where d ij represents the Gaussian distance between the sample data and the mean vector, x j represents the sample data to be divided, ui represents the sample cluster formed by clustering, divide the sample x j into the nearest cluster, and then recalculate the new mean vector, and judge whether it is consistent with the previous mean vector. If it is consistent, the clustering is completed, and the sample data set is divided into k clusters. If it is inconsistent, the above calculation steps are repeated until the mean vector does not change. In actual operation Using the KMeans function directly can replace the above calculation steps to complete the clustering task.

总之,本发明采用STM32实现了多通路的分光光度法测量不同水深处的COD、含氮量、PH值,实现仪器自动化、避免二次污染、节约成本、提高水质监测准确度及全面性的同时,节省了大量人力物力财力,同时,仪器支持现场测量、远程监测,尤其适用于野外水质测量;仪器通过采用多通道测量不同水质参数,有效的减少了无关因素对于水质测量的干扰,使测量更加精确快速;引入SD卡数据动态存取功能,使操作更加简单方便同时仪器体积小方便携带,且价格低廉,更加贴近于实际应用,一定程度上满足了工业与个人需求,有助于进一步改善环境污染问题,具有很高的社会实用价值与环保价值。In a word, the present invention adopts STM32 to realize multi-channel spectrophotometric measurement of COD, nitrogen content and PH value at different water depths, realizes instrument automation, avoids secondary pollution, saves costs, and improves the accuracy and comprehensiveness of water quality monitoring. , saving a lot of manpower, material and financial resources. At the same time, the instrument supports on-site measurement and remote monitoring, especially suitable for field water quality measurement; the instrument uses multiple channels to measure different water quality parameters, effectively reducing the interference of irrelevant factors on water quality measurement, making the measurement more Accurate and fast; the introduction of the SD card data dynamic access function makes the operation easier and more convenient. At the same time, the instrument is small in size and easy to carry, and the price is low, which is closer to the actual application, meets the needs of industry and individuals to a certain extent, and helps to further improve the environment The pollution problem has high social practical value and environmental protection value.

Claims (7)

1. The multifunctional underwater water quality automatic monitoring system based on the clustering algorithm is characterized in that: the monitoring system comprises an upper computer and a monitor, wherein the upper computer comprises a Labview interface design part and a Python data processing part, the upper computer designs a GUI interface through the Labview, calls a Python function by means of an internal interface function and adopts a clustering algorithm to complete sample data processing, and the monitor comprises a telescopic fixed support, a box body, a lower computer, a sliding module and a power supply module; wherein:
the lower end of the telescopic fixing bracket is fixed in water and used for fixing the whole monitor;
the box body is sealed, a hole is formed in the top end of the box body, a measuring switch is arranged outside the box body, a waterproof layer is arranged on the inner wall of the box body, and the lower computer and the power supply module are located in the waterproof layer;
the lower computer is arranged in the box body and is used for controlling the sliding module, collecting water quality parameter data and uploading the collected water quality parameter data to the upper computer;
the sliding module is used for connecting the box body and the telescopic fixing bracket;
the power module is arranged in the box body and comprises a direct current power supply driving module and a voltage amplifying module, the output end of the direct current power supply driving module is connected with the input end of the voltage amplifying module, and the output end of the voltage amplifying module is respectively connected with the power input end of each module to supply power for each module of the monitor;
the lower computer controls the sliding module to enable the box body to move up and down in the vertical direction, and then a plurality of water quality parameters of different water depths are collected;
the lower computer comprises a single chip microcomputer, a multi-channel spectrophotometric water quality measuring module and a data access module, wherein water quality information measured by the multi-channel spectrophotometric water quality measuring module is converted into an electric signal and then is output to the single chip microcomputer for processing, the data is output to the data access module after being processed by the single chip microcomputer, and the data is read from the data access module by the upper computer;
the single chip microcomputer comprises a control unit, an external RTC (real time clock), an external crystal oscillator, a signal conditioning amplifying circuit and a multi-channel ADC (analog to digital converter) conversion module, the multi-channel spectrophotometric water quality measuring module comprises a fixed base, a two-channel spectrophotometric device, a test tube fixing device, a silicon photocell sensor 1, a silicon photocell sensor 2, an ultraviolet light source 1, an ultraviolet light source 2, a titration tank and a water valve, the two-channel spectrophotometric device is fixed on the fixed base, a light path on-off switch is arranged on the inner wall of the test tube fixing device, a test tube for containing a to-be-tested agent is placed in the test tube fixing device, the opening of the test tube is right opposite to the top of a box body, the water valve is arranged at the upper end of the test tube fixing device, when the to-be-; the external RTC and the external crystal oscillator are connected with the control unit, the control unit controls the two ultraviolet light sources to emit ultraviolet light with different intensities and frequencies through outputting PWM (pulse width modulation) waves, the ultraviolet light irradiates to the corresponding silicon photocell sensors through internal channels of the spectrometer respectively, then optical signals are converted into electric signals through the silicon photocell sensors, the electric signals are amplified by the input signal conditioning and amplifying circuit, and finally the electric signals are input into the control unit through the multi-channel ADC conversion module for processing.
2. The multifunctional underwater water quality automatic monitoring system based on the clustering algorithm as claimed in claim 1, wherein: scalable fixed bolster includes two sections upper and lower stainless steel iron pipes, and the upper segment is the telescopic joint, and the lower section is the fixed knot, and the telescopic joint lower extreme has a spring bolt, and it has a plurality ofly and spring bolt complex fixed orifices to distribute on the fixed knot, and when inserting the spring bolt different fixed orifices, whole scalable fixed bolster has different heights, and telescopic joint and fixed knot pass through spring bolt and fixed orifices fixed connection.
3. The multifunctional underwater water quality automatic monitoring system based on the clustering algorithm as claimed in claim 1, wherein: the data access module comprises an SD card data dynamic access module and an EEPROM data cache module, the SD card data dynamic access module is respectively in bidirectional connection with the control unit and the upper computer, and the EEPROM data cache module is connected with the control unit.
4. The multifunctional underwater water quality automatic monitoring system based on the clustering algorithm as claimed in claim 1, wherein: the sliding module comprises a stepping motor, a fixed pulley and a movable pulley, the fixed pulley is fixed at the upper end of the telescopic fixing support, the movable pulley is fixed on the outer side wall of one side, close to the telescopic fixing support, of the box body and is connected with the telescopic fixing support, the stepping motor is fixed on the upper portion of the box body, a traction wire led out by the fixed pulley is sleeved on an output shaft of the stepping motor, the stepping motor is controlled by the single chip microcomputer to rotate clockwise or anticlockwise, the box body is driven to move up and down in the vertical direction, and the movable pulley moves up and.
5. The monitoring method of the multifunctional underwater water quality automatic monitoring system based on the clustering algorithm as claimed in any one of claims 1 to 4, characterized by comprising the following steps:
(1) debugging the monitor before starting to measure: adjusting the length of the telescopic fixed support to a height suitable for the current water level, inserting the telescopic fixed support underwater, and stably fixing the telescopic fixed support;
(2) judging whether the measurement switch is turned on, if so, inputting the current water depth and the height value of each descending unit of the box body to the control unit, and executing the step (3); if not, continuing to execute the step (2);
(3) before monitoring is started, judging whether the current lowered height is larger than or equal to an input water depth value or not, if the current lowered height is found to be larger than or equal to the input water depth value before monitoring is started, indicating that the input in the step (2) is wrong, and returning to the step (2) to input the current water depth and the height value of each time that the box body is lowered; if not, executing the step (4);
(4) the control unit controls the stepping motor to rotate forwards, so that the box body descends by a unit height value, and different water quality parameter values of the current water depth position are monitored;
(5) after one measurement is finished, the control unit recalculates and judges whether the current lowered height is larger than or equal to the input water depth value, if not, the instrument does not reach the water bottom, and the step (4) is returned to execute; if yes, executing the step (6);
(6) the control unit controls the stepping motor to rotate reversely, so that the box body rises by a unit height value;
(7) the control unit calculates and judges whether the current raised height is larger than or equal to the input water depth value, if not, the instrument does not reach the water surface, and the step (6) is returned to execute; if so, the box body is indicated to reach the water level, the control unit stores the measurement result into the data access module, and the measurement is finished;
(8) after the measurement is finished, the data access module is connected to an upper computer, the Labview reads data stored in the data access module through an internal function interface to serve as a sample data set to be processed, calls a Python function through an internal interface function to complete sample data processing through a clustering algorithm, and displays the sample data through a GUI interface designed by the Labview.
6. The method for monitoring the multifunctional underwater water quality automatic monitoring system based on the clustering algorithm as claimed in claim 5, wherein the method for monitoring the plurality of water quality parameter values of the current water depth position in the step (4) comprises the following steps:
(1) when the box body reaches the preset position, the control unit controls the water valve to be opened, so that external water quality flows into the test tube along the water inlet above the box body, and if the water level of the poured water quality reaches above the water valve, the control unit controls the water valve to be closed, so that the purpose of taking a water sample is achieved;
(2) the control unit controls the titration tank to titrate the current water sample by using different reagents according to the water quality parameters needing to be measured currently, and closes the titration tank after titration is finished;
(3) the control unit outputs PWM waves with frequency i to an ultraviolet light source to enable the ultraviolet light source to emit ultraviolet light with corresponding frequency and intensity, a spectrophotometry method is adopted to measure a current water quality parameter alpha, two silicon photocell sensors are used for measuring N times respectively, an average value of the two silicon photocell sensors is taken after the maximum value and the minimum value are removed, and current water quality parameter results are stored in an SD card respectively; wherein the water quality parameter alpha is COD concentration, nitrogen content or PH value of the water quality, and i represents the frequency of PWM wave required for obtaining the current water quality parameter alpha.
7. The monitoring method of the multifunctional underwater water quality automatic monitoring system based on the clustering algorithm according to claim 5, wherein the upper computer in the step (8) processes the sample data by adopting the clustering algorithm, and specifically comprises the following steps:
the system directly calls a Python interface function to open a Python console by means of Labview and opens the Python console by means of LabviewThe KMeans function coding clustering algorithm program in the Python built-in scimit-spare packet needs to be firstly imported into water quality monitoring data sets which are input to different positions and different water depths of an upper computer part through a data access module as a sample data set D after an interface is normally connected and a Python control console is opened, k samples are randomly selected from the D as an initial mean vector through a k value input by a user, the distance between each sample data in the data set and each sub-vector in the mean vector is calculated, and a distance measurement function adopts a Gaussian function to calculate: dij=||xj-ui||2I is more than or equal to 1 and less than or equal to k, j is more than or equal to 1 and less than or equal to m, wherein dijRepresenting the Gaussian distance, x, between the sample data and the mean vectorjRepresents the sample data to be divided, uiRepresenting the cluster of samples formed by clustering, and sampling xjDividing the data into clusters with the nearest distance, then recalculating a new mean vector, judging whether the mean vector is consistent with the previous mean vector or not, if so, finishing clustering, dividing the sample data set into k clusters, and if not, repeating the above calculation steps until the mean vector is not changed any more.
CN201811138395.6A 2018-09-28 2018-09-28 Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm Expired - Fee Related CN109270016B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811138395.6A CN109270016B (en) 2018-09-28 2018-09-28 Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811138395.6A CN109270016B (en) 2018-09-28 2018-09-28 Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm

Publications (2)

Publication Number Publication Date
CN109270016A CN109270016A (en) 2019-01-25
CN109270016B true CN109270016B (en) 2020-11-03

Family

ID=65198729

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811138395.6A Expired - Fee Related CN109270016B (en) 2018-09-28 2018-09-28 Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm

Country Status (1)

Country Link
CN (1) CN109270016B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109975215B (en) * 2019-04-30 2021-07-13 水利部交通运输部国家能源局南京水利科学研究院 A water body transparency monitoring device
CN113777085B (en) * 2021-09-14 2024-06-04 河北地质大学 Floating algae concentration monitor based on fluorescence sensing technology

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08201283A (en) * 1995-01-23 1996-08-09 Toho Keisoku Kenkyusho:Kk Water quality measuring device
CN102331485A (en) * 2011-07-12 2012-01-25 华东理工大学 Portable water quality monitor
CN103020642A (en) * 2012-10-08 2013-04-03 江苏省环境监测中心 Water environment monitoring and quality-control data analysis method
CN202996001U (en) * 2012-12-16 2013-06-12 宋婷婷 Wireless transmission device for monitoring water quality in real time
CN203758777U (en) * 2014-01-08 2014-08-06 中国人民解放军疾病预防控制所 Portable water quality sampler
CN104849424A (en) * 2015-04-29 2015-08-19 福州福光水务科技有限公司 Water quality vertical section monitoring system
CN105628433A (en) * 2014-11-04 2016-06-01 青岛清泉生物科技有限公司 Portable water quality sampler
CN107024366A (en) * 2016-12-22 2017-08-08 中国科学院遥感与数字地球研究所 A kind of Portable water sampler
CN206470077U (en) * 2016-10-11 2017-09-05 苏州工业园区清源华衍水务有限公司 A kind of water sampler
CN107655722A (en) * 2017-11-07 2018-02-02 刘剑锐 A kind of water quality sample-taking box
CN207295272U (en) * 2017-08-08 2018-05-01 惠州市德康兴家居用品有限公司 A kind of flexible clothes hanger
CN108267337A (en) * 2018-01-17 2018-07-10 南开大学 A kind of water quality detection sampling apparatus
CN108562711A (en) * 2018-07-11 2018-09-21 合肥苍旻自动化有限公司 A kind of device for water quality monitoring

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08201283A (en) * 1995-01-23 1996-08-09 Toho Keisoku Kenkyusho:Kk Water quality measuring device
CN102331485A (en) * 2011-07-12 2012-01-25 华东理工大学 Portable water quality monitor
CN103020642A (en) * 2012-10-08 2013-04-03 江苏省环境监测中心 Water environment monitoring and quality-control data analysis method
CN202996001U (en) * 2012-12-16 2013-06-12 宋婷婷 Wireless transmission device for monitoring water quality in real time
CN203758777U (en) * 2014-01-08 2014-08-06 中国人民解放军疾病预防控制所 Portable water quality sampler
CN105628433A (en) * 2014-11-04 2016-06-01 青岛清泉生物科技有限公司 Portable water quality sampler
CN104849424A (en) * 2015-04-29 2015-08-19 福州福光水务科技有限公司 Water quality vertical section monitoring system
CN206470077U (en) * 2016-10-11 2017-09-05 苏州工业园区清源华衍水务有限公司 A kind of water sampler
CN107024366A (en) * 2016-12-22 2017-08-08 中国科学院遥感与数字地球研究所 A kind of Portable water sampler
CN207295272U (en) * 2017-08-08 2018-05-01 惠州市德康兴家居用品有限公司 A kind of flexible clothes hanger
CN107655722A (en) * 2017-11-07 2018-02-02 刘剑锐 A kind of water quality sample-taking box
CN108267337A (en) * 2018-01-17 2018-07-10 南开大学 A kind of water quality detection sampling apparatus
CN108562711A (en) * 2018-07-11 2018-09-21 合肥苍旻自动化有限公司 A kind of device for water quality monitoring

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于K-means聚类和ELM神经网络的养殖水质溶解氧预测";宦娟 等;《农业工程学报》;20160930;第32卷(第17期);第174-181页 *

Also Published As

Publication number Publication date
CN109270016A (en) 2019-01-25

Similar Documents

Publication Publication Date Title
CN101183071B (en) Novel water quality analysis meter
CN101625314B (en) Advanced plant biochemical parameter non-contact monitoring device
CN101556240A (en) Chlorophyll measuring apparatus based on RGB (red, green and blue) digital signal
CN104777108B (en) The detection means and method of a kind of chlorophyll content
CN105954192A (en) Online dual-light-path water environment measurement device based on spectral measurement technology
CN205139020U (en) Handheld portable urine analysis
CN101556245A (en) Chlorophyll measurement method based on RGB digital signal
CN118393096B (en) A water quality monitoring and analysis device for water supply network and its analysis and processing system
CN108956512A (en) A kind of Multifunctional water Portable rapid detector and its application method and detection method
CN201177613Y (en) On-site analyzer for heavy metal pollutants in seawater
CN109191819B (en) A multi-point water quality monitoring and analysis system and monitoring and analysis method based on clustering algorithm
CN109270016A (en) Multifunctional underwater water quality automatic monitoring system and monitoring method based on clustering algorithm
CN119985892B (en) Portable multi-parameter water quality detector for on-site comparison of marine water quality monitoring equipment
CN113959990A (en) Multi-parameter water quality detection equipment and water quality assessment method
CN203551548U (en) Novel online water quality testing meter
CN207965180U (en) A kind of on-line chemical monitoring instrument sample cutout detection device
CN215413828U (en) Swimming pool water quality multi-parameter combination on-line monitoring appearance
CN109270014A (en) Multifunctional underwater water quality automatic monitor and monitoring method
CN213658583U (en) Portable Raman spectrum measuring device
CN212180779U (en) Split type quick on-line measuring device of many factors of quality of water
CN117147236A (en) Sampling device for monitoring water quality
CN109270015A (en) Multi-point water quality monitoring and analysis system based on improved RBFNN algorithm and monitoring analysis method
CN205607875U (en) It is open -air with solar energy tree ring collection system
CN101556244A (en) Measurement method for chlorophyll content in cucumber leaves based on RGB chlorophyll meter
CN201014981Y (en) Immersion type underwater probe device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20201103