**Download this article in PDF format.**

Continuing where Part 1 left off, the next area to dive into is the processor unit or microcontroller (MCU), which is at the heart of the RF system *(see figure)*. It processes data and runs software stacks interfaced to a transceiver for RF transmission and to a pH reference design (RD) board for sensor measurement.

*Shown is a wireless sensor data-acquisition and transmission block diagram.*

Choosing a microcontroller involves several factors that must be considered:

- Peripherals
- Memory
- Processing power
- Power consumption

**Peripherals**

A microcontroller should be integrated with peripherals like an SPI bus. The transceiver and the pH reference design board are connected via SPI; therefore, two SPI peripherals are required.

**Memory**

With a decent amount of memory, a microcontroller is where protocol processing and sensor interfacing take place. Flash and RAM are two very critical components of microcontrollers. To make sure that the system won’t run out of space, 128 kB were used. These undoubtedly make application and software algorithms run smoothly and will give room for possible upgrades and added functionality, thus creating a headache-free system.

**Architecture and Processing Power**

The microprocessor must be fast enough to handle complex calculations and processes. The system employs a 32-bit microcontroller. Although a lower-bit processor might be capable, this system opts to use 32 bits for potentially higher application and algorithm requirements.

**Microprocessor Power Consumption**

The power consumption of the microcontroller shall be very low. Power is critical to those applications powered by a battery that must run for years without servicing.

**Other System Considerations**

*Error Checking*

The communications processor adds CRC to the payload in transmit mode, then detects the CRC in received mode. The payload data plus the 16-bit CRC can be encoded/decoded using Manchester.

*Cost*

The system should work with minimal component and board size—these are often determinants when cost is one of the key requirements. Instead of using discrete components, an integrated solution consisting of the MCU and the wireless devices must be considered. This eliminates the design challenge of the interconnections between the radio and MCU, which makes for a simpler board design, a more straightforward design process, and shorter bond wires, resulting in less susceptibility to interference. Utilizing single chips that combine Arm Cortex M-based MCUs and radio transceivers can reduce board component count, board layout, and overall cost.

*Calibration*

One of the keys to achieving high accuracy is performing a calibration routine. A characteristic of a pH solution as described from the Nernst equation is its high dependency to temperature. The sensor probe only gives a constant offset that can be assumed as constant at all temperature levels. Because of its high dependency to temperature, this system requires a sensor that will determine the solution temperature.

A method such as a direct substitution using the Nernst equation can be implemented, but it may exhibit some degree of error since it lacks the non-ideal property of the solution. This method only requires offset measurement of the system and the temperature reading of the unknown solution. To determine the offset introduced by the sensor, a buffer solution with pH 7 is needed. The sensor should ideally produce an output of 0 V. The analog-to-digital converter (ADC) reading will be the system offset voltage. An offset of a typical pH probe sensor could be as high as ±30 mV.

The other way, which is commonly applied in the field, involves multiple buffer solutions setting the points when constructing a general linear or nonlinear equation. This routine requires two additional pH buffer solutions that are certified and traceable by NIST. The two additional buffer solutions should at least differ by a pH value of 2.

Calibration is performed through the buffer solutions using this procedure:

*Step 1:*After removing the electrode assembly from the first buffer and rinsing it with deionized or distilled water, immerse the pH probe with the temperature sensor into the second chosen buffer solution.*Step 2:*Repeat step 1—but using the third buffer solution.*Step 3:*Formulate the equation from the measured values using the chosen buffer solution.

Several mathematical equations can be used to derive the equation for the calibration. One of the commonly applied formulas is a straight-line equation using a point slope form. This equation includes two points taken during the calibration:

P1 (Vm1, pH1) and P2 (Vm2, pH2)

where P1 and P2 were the points taken using the chosen buffer solutions.

To determine the pH level of the unknown solution, with a given point of Px (Vmx, pHx), a simple linear interpolation can be used with the equation:

(pHx − pH1)/(Vmx − Vm1) = (pH1 − pH2)/(Vm1 − Vm2), or simply pHx = (Vmx − Vm1) × (pH1 − pH2)/(Vm1 − Vm2) + pH1

For a higher degree of accuracy given a multiple set of points, a first-order linear regression can be employed. Given a set of n number of data points:

P0 (Vm0, pH0), P1 (Vm1, pH1), P2 (Vm2, pH2), P3 (Vm3, pH3), … Pn (Vmn, pHn)

the general equation, pHx = a + b × Vmx, can be formulated using a least-square method where b is the slope of the line and a is the intercept form having a value of:

and

The least-square method of approximation can be extended to the higher degree, such as a second-order degree nonlinear equation. The general equation for the second order can be found as:

pHx = a + b × Vmx + c × Vmx2

Values for a, b, and c can be calculated as:

These systems of equations can be used to solve for the given unknown variables a, b, and c through substitution or elimination, or via the matrix method.

**Hardware Design Solutions**

*Buffer Amplifier*

With this given condition, a buffer amplifier with high input impedance and very low input bias current is needed to isolate the circuit from this high source resistance. The AD8603 low-noise op amp can be used as a buffer amplifier for this application. The low input current of the AD8603 minimizes the voltage error produced by the bias current flowing through the electrode resistance. For 200-fA typical input bias current, the offset error is 0.2 mV (0.0037 pH) for a pH probe that has 1-GΩ series resistance at 25°C. Even at the maximum input bias current of 1 pA, the error is only 1 mV. Though not necessary, guarding, shielding, high-insulation resistance standoffs, and other such standard picoamp methods can be used to minimize leakage at the high-impedance input of the chosen buffer.

*Analog-to-Digital Converter*

A low-power ADC can be a favorable converter for this application. This is achievable using the AD7792 16-bit Σ-Δ ADC for precision measurement applications. It has a three-channel input that achieves low noise—only 40-nV rms noise when the update rate equals 4.17 Hz.

The parts operate with a power supply from 2.7 to 5.25 V; the ADC has a typical current consumption of 400 μA. The device is housed in a 16-lead TSSOP package. Added features include an internal bandgap reference with 4 ppm/°C drift (typical), a 1-μA maximum power-down current consumption, and an internal clock oscillator to reduce component count and printed-circuit-board (PCB) space.

*Choosing the RF Transceiver*

Based on the previous requirements, ADuCRF101 is the best fit for the intended application. The ADuCRF101 is a fully integrated data-acquisition solution designed for low-power wireless applications. The ADuCRF101 operates from 431 to 464 MHz and 862 to 928 MHz. It’s integrated with communication peripherals like the required two SPI buses. There’s also 128 kB of nonvolatile flash/EE memory and 16 kB of SRAM on chip. It’s a one-chip solution for microcontrollers and transceivers, thus minimizing the number of components and board size.

The ADuCRF101 operates directly from a battery with a supply range from 2.2 to 3.3 V and a power consumption of:

- 280 nA in power-down mode, non-retained state
- 1.9 μA in power-down mode, processor memory and RF transceiver memory retained
- 210 μA/MHz, Cortex-M3 processor in active mode
- 12.8 mA RF transceiver in receive mode, Cortex-M3 processor in power-down mode
- 9 to 32 mA RF transceiver in transmit mode, Cortex-M3 processor in power-down mode

**Software Implementation**

Software is a critical part of the wireless transmission system. It dictates how the system will behave and impacts the system’s power consumption. The system has two software parts—namely, the protocol stack and the application stack. The protocol stack is the ADRadioNet, a wireless networking protocol for the ISM band. It uses IPv6 addresses and combines most of the features expected in such solutions—that is, low power, multihop, end-to-end acknowledgement, self-healing, etc. The application stack is software that accesses the pH reference design board via SPI.

To efficiently run the two software stacks, a simple scheduler was used. A non-preemptive scheduler handles the protocol stack task; its functions are given a specific time and specific resources. However, the number of defined tasks in the system is limited. To operate efficiently, execution of the defined tasks must be completed by the non-preemptive scheduler before its time lapses. With the two stacks in system, the non-preemptive scheduler is a good fit because of the limited number of defined tasks assigned to it.

**Conclusion**

This article series has presented different challenges and solutions for the design aspects of pH wireless sensor monitoring. It has been shown that ADI data-acquisition products can essentially be leveraged to address the given challenges for pH measurement. The AD8603 op amp, or any equivalent ADI amplifier with high input impedance, can be used to counter the sensor’s high output impedance—therefore providing enough shielding to prevent system loading.

The ADuCRF101 data-acquisition system IC is able to provide a complete solution for RF data transmission. The accuracy of the data acquisition can be accomplished in hardware via a precision amplifier and ADC, or through calibration in software using mathematical statistics to formulate a general equation such as different methods of curve fitting.

*Erbe D. Reyta is a hardware applications engineer and Mark O. Ochoco is an application development engineer at Analog Devices Inc.*