A project log for Phmeter

PHmeter and thermometer with settable threshold alarm and relay output, bluetooth and a specific function useful for cheesemaking.

EstEst 08/21/2015 at 08:390 Comments

The pH probe outputs a small voltage negative or positive that is proportional to the PH value but has to be calibrated to compensate for the assimetry (at pH 7 the voltage should be 0 but is not) and the sensitivity of the probe (how much the voltage varies with the PH). The response of the pH probe change with the temperature (higher temperature=higher voltage output for the same pH) so the pH meter needs to know the temperature to compensate this effect. Actually also the pH of the sample itself will change with the temperature so it's a good rule of thumb take the reading when the temperature is close to 25°C. The pH probe has a very high impedance and the input stage uses a precision op amp with very low input current and the connection between the BNC connector and the op amp is made "in the air" because also the PCB has a very little conductivity. The signal buffered by the op amp is feeded to a 16 bit ADC that uses a precision voltage reference IC of 2.5 V. The temperature reading is done by a PT100 temperature probe (as this is the most precise temperature sensor and commonly used in laboratory and industrial instruments) .the resistance of this probe changes with the temperature with a ratio almost linear but to be more precise the microcontroller stores a look up table to convert the resistance measured to a temperature reading. This temperature probe has 4 wires: two are used to flow a constant current and two are used to sense the voltage across the sensor. In this way the voltage drop caused by the resistance of the wires is eliminated. The resistance of the probe is compared with a metal film resistors that is calibrated in software: a special code sent to the microcontroller by Bluetooth starts a calibration procedure for the temperature probe, a precision reference resistor of 100 ohm has to be connected in the temperature probe connector and the microcontroller stores the reading in eeprom to compensate the tolerance of the metal film resistor. The same 16 bit ADC with the precision voltage refetence of 2.5 volt that is used for the pH input is used also for the temperature. The ADC works on the sigma delta principle: a constant current charges a capacitor and the voltage across this capacitor is compared with the input. The time needed to match the two values is proportional to the input voltage. The ADC uses a quartz oscillator to chronometer the time but the oscillator frequency slightly varies with the temperature of the quartz so at each reading the ADC self calibrates using the 2.5v reference. The self calibration procedure takes more time than the conversion itself but for this application is not needed a high sampling rate.

The PIC microcontroller is programmed in assembler. The operations to calculate the pH are made using 32 bit variables and fixed point routines copyed from the microchip website.

In total 4 look up tables are used:

- The microcontroller interpolates the values stored in a look up table to convert the resistance reading of the probe in a temperature as the ratio is slightly not linear.

- To calibrate the pH probe are needed two buffer solutions at pH 7 and 4. As the pH of these solutions changes with the temperature the micro controller stores also a look up table for each of these solutions.

- To calculate the pasteurization process is used a look up table to relate the time needed to reach the pasteurization to the temperature.

The microcontroller communicates by serial protocol with a Bluetooth module that can be connected with a PC or mobile phone. As I did this project about 5 years ago the android phone was not yet so popular and I wrote a only a python script that can run on Nokia phone with symbian OS. I wrote a python script for PC too. Both on the PC and phone interfacing softwares are shown a real time chart of the pH and temperature and the samples can be exported to a spreadsheet.

The pH meter is powered by a sealed lead acid battery at 12v.