I am stuck at and seeking different ways of thinking or knowledge sources, any help appreciated.
I am trying to design a liquid flow meter circuit using lines of IR led – Photodiode couples, driving and reading the output with uP. At first I am trying to get a stable reading of the height of the liquid, inside a rectangular cross-sectioned pipe, which the IR lines reside on.
Some specs:
- measure mass / volume of opaque liquids without interfering (no touching mechanical parts etc.)
- while on the flow, the max flow rate is 15 lt/min
- the liquid has air bubbles from small to big (this changes everything!)
- the liquid is same but some contents ( most important is fat ) changes dynamically throughout the flow
- no important levels of pressure or heat, no hazardous or special requirement liquid will flow
So basically; after all calculations if I put the liquid, half the height of the pipe I should read %50, if it is full I should read %100. I used some levels of calibration and calculation which explained below but the error is not as low as I expected. I cannot measure this precisely now because the height is about 12 millimeters, but at least when it is full I should read %100 every time! Now I have something between %95-105. Basic technology used here is spectrometer I guess, but a simpler and less precise model of it.
If I can manage to decrease the error, I will pass to liquid flow tests, which I will read many samples of 2 lines of IR light, which the liquid passes and try to find the velocity (calculating time between 2 lines which the liquid passes) and the instant height of the liquid (which leads me to the instant area of liquid passing).
Tried to write as brief as possible, I can go details if you lead me to the title.
Best wishes,
CALIBRATION & CALCULATION routines:
(Each line of IR line (with IR led and Photodiode) is called as channel-ch , so we have ch0 and ch1 )
• Ch differences Calibration:
(every ch reads of the same liquid with some differences )
At start read 100 samples, take average for each ch and choose ch0 as the reference channel, calculate a constant K1 for the ch1 which converts the reading of ch1 in terms of ch0:
Vref_ch
------------------ = K1
Vsample_ch
I will use this K1 for every measure coming from ch1 to calibrate it.
• Temp calibration
(Although I used a constant current driver for the LEDs, by temp and other affects the light power changes, in order to compensate this there is another IR line just near the pipe but without transferring any IR light only empty air is between the LED and the PD. When the other IR lines on the pipe will be sampled, this AIR line is also sampled and the reading is used to calibrate these differences that LEDs creates)
Like the ch calibration the AIR ch reading at the beginning is taken as a constant and on every sample the new AIR ch reading is used to calibrate the liquid IR ch readings:
Vref_air (constant taken at start)
------------------------------------------- = Ka
Vsample_air
I will also use this Ka for every measure coming from both ch0 and ch1 to calibrate them.
• Beer-lambert law
When the pipe is empty, because of the plastic, air etc. the reading is not 0, it is again an attenuation value. Also when the pipe has some level of liquid this empty value should be subtracted. But because of some other factors which can’t be measured or calculated, you cannot directly subtract these values but according to beer-lambert you can use the ratio of the values to cancel these effects. So I read the EMPTY values of the ch0 and ch1, calibrate and store the value which is demoted Vempty. In order to calculate the height of the liquid also the FULL value should be read and stored. At the start I also coded a calibration part which you have to make the pipe FULL of the liquid you want to measure, which we can have the Vfull and save.
After these start routines with each sample read I have to calculate this formula : ( which I am not sure %100 )
Attenuation = A
Aempty - Asample
------------------------ = height of the L
Aempty - Afull
Attenuation = -log (Vinput / Vout)
log ( Vempty / Vsample )
--------------------------- * 100 = Height of L %
log ( Vempty / Vfull )