3 TDS Measurement Using a PIC16F17146 Microcontroller

Implementation

The image below shows the block diagram view of the application: the TDS measurement in water using PIC16F17146. This application is implemented using a relaxation oscillator circuit designed with the OPA of the PIC16F17146 microcontroller. The 0.1μF input capacitor is selected to measure TDS for a range of 0-2000 mg/L. The pulsating output is captured by the CCP module. Water temperature is measured using the ADCC module. The measured TDS values are shown over the terminal application using a EUSART module.

Figure 3-1. Circuit Diagram of TDS meter using PIC16F17146

Features and Peripherals of a PIC16F17146 Microcontroller used in the Application

The PIC16F17146 is a microcontroller featuring an 8-bit CPU core running at speeds up to 32 MHz, with 28 KB Flash, 2 KB SRAM and 256 Bytes of EEPROM. The microcontroller has a rich set of analog and digital peripherals that can be used in various sensor and real-time control applications.

This section covers the features of the microcontroller and the peripherals that are used to realize the TDS measurement system.

OPA

The built in OPA peripheral of the microcontroller is used for the implementation of the relaxation oscillator circuit. The OPA is configured to accept input through the inverting and non-inverting pins. Its output is fed to an appropriate peripheral through the dedicated output pin. In this application, the OPA module is responsible for generating a pulsating signal at its output. The conductivity (TDS) probe and the supported passive components are fed as inputs to the OPA while the OPA’s output is fed as input to the CCP module.

ADCC

The PIC16F17146 microcontroller has a 12-bit differential ADCC peripheral that supports a computation feature. In this application, the ADCC is used to read the water temperature. It samples the output of the negative temperature coefficient (NTC) sensor that is built into the TDS probe.

CCP

The CCP module is configured in Capture mode and TMR1 is used as a clock. It is used to capture the OPA output to calculate the number of pulses over a period of time. The calculated time period is then converted into corresponding TDS values.

TMR

TMR1 is a 16-bit timer and is used as a clock source for the CCP module.

EUSART

EUSART is used to connect the PC terminal application to the microcontroller. It is also used to display TDS measurement system messages over the terminal application.