This is an old revision of the document!
The ADuCM360_demo_cn0326 is a pH monitor with automatic temperature compensation demo project, for the EVAL-ADICUP360 base board with additional EVAL-CN0326-PMDZ pmod, created using the GNU ARM Eclipse Plug-ins in Eclipse environment.
This project is a good example for how to use EVAL-ADICUP360 board in different combinations with pmod boards. It expand the list of possible applications that can be done with the base board.
The ADuCM360_demo_cn0326 project uses the EVAL-CN0326-PMDZ pmod which is a pH sensor signal conditioner and digitizer with automatic temperature compensation.
The CN0326 circuit provides a complete solution for pH sensors with internal resistance between 1 MΩ and several GΩ. It consist of pH probe buffer, Pt1000 RTD for temperature compensation and 24-bits ADC with 3 differential analog inputs.
The pH probe consists of a glass measuring electrode and a reference electrode, which is analogous to a battery. When the probe is place in a solution, the measuring electrode generates a voltage depending on the hydrogen activity of the solution, which is compared to the potential of the reference electrode. As the solution becomes more acidic (pH < 7) the potential of the glass electrode becomes more positive (+mV) in comparison to the reference electrode; and as the solution becomes more alkaline (pH > 7) the potential of the glass electrode becomes more negative (−mV) in comparison to the reference electrode.
The change in temperature of the solution changes the activity of its hydrogen ions. When the solution is heated, the hydrogen ions move faster which result in an increase in potential difference across the two electrodes. In addition, when the solution is cooled, the hydrogen activity decreases causing a decrease in the potential difference. Electrodes are designed ideally to produce a zero volt (0 V) potential when placed in a buffer solution with a pH of 7 (neutral pH).
The EVAL-CN0326-PMDZ comes with an evaluation software which can help you to test and to calibrate your pmod before you use it.
The potential changes are outputted as ADC 24-bits value which is received via SPI interface of the EVAL-ADICUP360 board. The ADC analog differential channels are:
The ADuCM360_demo_cn0326 application purchase ADC outputs from input channels, calculates voltage, temperature and pH values. You can choose to use internal excitation current of the ADC (IOUT2) or calculate bias current of the circuit (see USE_IOUT2 parameter).
A UART interface (9600 baud rate and 8-bits data length) is used, as a command line interpreter, to send the results to terminal window: temperature and ph values. Beside this two the interpreter process other three commands: help, calibrate channel/channels and ADC reset.
To start the command line interpreter you need to press ENTER key (CR) from the keyboard and after that just type in <help> to see available commands. The output data are send via UART using semihosting mechanism.
The project uses below formula to determine output ADC code for an input voltage on either channel:
AIN - analog input voltage
GAIN - gain value in the in-amp setting
N - ADC resolution (24)
The temperature value is calculated using RTD resistance value and it varies from 0°C (1000 Ω) to 100°C (1385 Ω):
Rrtd - RTD resistance at T°C
Rmin - RTD resistance at 0°C
α - temperature coefficient (0.00385 Ω/Ω/°C)
To calculate pH value is used Nernst equation:
E - voltage of the hydrogen electrode with unknown activity
α - zero point tolerance (±30 mV)
T - ambient temperature in °C
n - valence, number of charges on ion (1 at 25 °C)
F - Faraday constant (96485 coulombs/mol)
R - Avogadro's number (8314 mV-coulombs /°K mol)
pHiso - reference hydrogen ion concentration (7)
Semihosting is a mechanism that connect the target firmware's standard IO (printf, scanf/fgets, open, write, read, close, etc) to your host PC via JTAG or SWD. It’s easy to configure it with open source tooling - the newlib C standard library and OpenOCD JTAG implementation.
You can automatic enable semihosting and configure it by using the project ADuCM36x C/C+ + Project template, which offer you the ability to select how do you want to use semihosting.
This example present the possibility to use semihosting to output messages with printf() by using a physical serial connection as UART. It uses the newlib GNU ARM library which actually links the UART physical port to standard C functions. You need only to overwrite _write() function, which is marked as weak function in the GNU ARM library, with your own function that write characters to UART (the same for _read() function when you want to use scanf() in your code).
Connect the EVAL-CN0326-PMD to the SPI_PMOD connector of the EVAL-ADICUP360 board. In order to program the base board you need to use the DEBUG USB. After you program the board you can switch to USER USB and you are set to use the application. The important jumpers and switches configuration are highlighted in red.
The ADuCM360_cn0326_demo use UART connection via P0.6/P0.7 and SPI0 channel of the ADuCM360 to communicate with CN0326 board.
We recommend not opening the project directly, but rather import it into Eclipse and make a local copy in your Eclipse workspace.
The source code and include files of the ADuCM360_demo_cn0326 can be found on Github:
The necessary instructions on how to import the ADuCM360_demo_cn0326 project form the projects examples in the Git repository, can be found in How to import existing projects from the GIT Repository page.
After completion of the steps above the program will remain written into the system flash and it will run by default every time the board is powered up.
The ADuCM360_demo_cn0326 project use ADuCM36x C/C++ Project structure.
This project contains: system initialization part - disabling watchdog, setting system clock, enabling clock for peripherals; port configuration for SPI0, UART via P0.6/P0.7; SPI, UART read/write functions; AD7793 control, voltage conversion, command interpreter, temperature and pH calculations.
In the src and include folders you will find the source and header files related to CN0326 software application. The Communication.c/h files contain SPI and UART specific data, meanwhile the AD7793.c/h files contain the ADC control data and the CN0326.c/h files contain the pH monitor application data.
In the appropriate header files you can configure next parameters:
#define AD7793_GAIN AD7793_GAIN_1
#define USE_IOUT2 NO
#define TOLERANCE 0
The system folder contains system related files (try not to change these files):