||DIGITAL WATER-LEVEL METER
Digital Electronics Unit
In many applications a digital value is desired (for storage, analysis or accuracy). Although the above circuit can be used as an input to an analogue to digital unit, a more elegant and robust solution is to go directly to digital from the probe.
The capacitance probe is connected to an ICM7555 running in astable mode. The 7555 has an advantage as an oscillator for this application because the timing capacitor is grounded. The probe will be the timing capacitor.
The period of oscillation is proportional to the capacitance and therefore to the water level. The period is measured using the capture feature of any Microchip PIC microcontroller that has the CCP (Capture, Compare and PWM) hardware. In this schematic and code example, a 16F88 is used. The output of the ICM7555 is connected to the CCP1 pin.
Timer 1 is setup to count the crystal frequency divided by four, so the count increments every 0.25 microseconds with a crystal frequency of 16MHz. The timer runs freely and rolls over to zero after the maximum count is reached.
CCP1 is setup to capture the timer 1 count after sixteen cycles of the 7555 oscillator, thus giving a larger count for better resolution, and some averaging. The difference in the timer 1 counts between successive captures is the measurement.
The time taken for the measurement is only a few milliseconds maximum, so further averaging can be done by taking multiple measurements without affecting the dynamic response in applications where a wave profile needs to be measured.
Only one resistor is needed on the 7555 in astable mode compared to two with a standard 555. The resistor should be a low temperature coefficient type eg. from the RC55 series from Farnell or equivalent. The value required can be determined by immersing the probe to the maximum level and setting the resistor value so that the 7555 frequency is about 5kHz. This will be the minimum frequency and the maximum period of oscillation. Typically, this is around 1nF.
The 7555 frequency can drift with temperature (see curve in data sheet) and for this reason the air temperature can also be measured so that a correction can be made if required, either in the PIC program or in post-processing of the data. Generally it is better to perform this correction using a computer to convert the values with suitable high precision. Alternatively, record the response of the probe over the desired temperature range and correct for this.
In this example, the ambient temperature near the 7555 is measured using an LM35 analog temperature sensor.
The level measurement can be scaled to water level in the PIC or in the post processing of the data. The measured value is generally more than enough for the probe resolution.
In the code example, the measured value is output without scaling to the RS232 serial port in ASCII format so that the data can be viewed and saved to a file using a terminal program such as gtkterm on Linux, Teraterm or Hyperterminal in Windows. Temperature is also output in degrees Celcius.
Only the 7555, the temperature sensor and a local +5V regulator really need to be near the probe - if the cost can be justified, a MAX485 can be used to transmit the 7555 pulses differentially (RS422 mode) via a twisted pair cable, eg. CAT5 data cable, to the rest of the electronics at some distance. At this end there is another MAX485 to convert the differential signals back to single ended. Other pairs in the cable can be used for the temperature and to send unregulated DC to the remote regulator.
PCB stakes are also known as PCB risers