确定液体的酸性或碱性,其范围从强酸到强碱。
A
A
硬件概览
它是如何工作的?
EZO Carrier Click - pH 基于 Atlas Scientific 的 EZO™ pH,这是一款 pH 测量接口电路板。它允许您通过将探头插入要测量 pH 的溶剂中来连接 pH 测量探头,该探头测量氢离子的浓度。EZO Carrier Click - pH 配有 BNC 连接器,用于连接适当的探头,MIKROE 也提供此类探头。EZO™ pH 需要与主机 MCU 隔离;因此,该 Click™ 板配备了 Skyworks 的双向隔离器 Si8400AB。该隔离器提供标准的双向和 I2C 通信,时钟频率高达 1.7MHz。EZO™ pH 电路是一种非
常灵敏的设备,灵敏度赋予 pH 电路其准确性。它能够读取泄漏到溶剂中的微电压。因此,除了 Si8400AB 隔离器外,为了消除电噪声,电源电压也被隔离。为此,该 Click™ 板配备了 Recom 的 ROE-0505S DC/DC 转换器。EZO™ pH 具有灵活的校准协议,允许单点、两点或三点校准。应考虑温度补偿。EZO™ pH 具有睡眠模式、连续操作、查找功能、导出/导入校准、模块状态 LED 等功能。EZO Carrier Click - pH 可以使用标准的 2 线 UART 接口与主机 MCU 通信,默
认波特率为 9600bps。在使用 UART 接口时,您可以使用我们提供的库或简单的 ASCII 命令集。您还可以通过 COMM SEL 跳线选择标准的 2 线 I2C 接口。此 Click™ 板可以通过 VCC SEL 跳线选择 3.3V 或 5V 逻辑电压级别进行操作。这样,具有 3.3V 和 5V 功能的 MCU 都可以正确使用通信线。另外,此 Click™ 板配有包含易于使用功能和示例代码的库,可用于进一步开发。
功能概述
开发板
PIC32MZ Clicker 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位带有浮点单元的 Microchip PIC32MZ 微控制器,一个 USB 连接器,LED 指示灯,按钮,一个 mikroProg 连接器,以及一个用于与外部电子设备接口的头部。得益于其紧凑的设计和清晰易识别的丝网标记,它提供了流畅且沉浸式的工作体验,允许在任
何情况下、任何地方都能访问。PIC32MZ Clicker 开 发套件的每个部分都包含了使同一板块运行最高效的必要组件。除了可以选择 PIC32MZ Clicker 的编程方式,使用 USB HID mikroBootloader 或通过外部 mikroProg 连接器为 PIC,dsPIC 或 PIC32 编程外,Clicker 板还包括一个干净且调节过的开发套件电源供应模块。USB Micro-B 连接可以提供多达 500mA 的电流,这足以操作所有板载和附加模块。所有
mikroBUS™ 本身支持的通信方法都在这块板上,包 括已经建立良好的 mikroBUS™ 插槽、重置按钮以及若干按钮和 LED 指示灯。PIC32MZ Clicker 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
PIC32
MCU 内存 (KB)
1024
硅供应商
Microchip
引脚数
64
RAM (字节)
524288
你完善了我!
配件
SMA Male to BNC Female Adapter 是一种高性能连接器,旨在无缝连接具有 SMA 公头和 BNC 母头接口的设备。具有 50 欧姆阻抗和最高 4GHz 频率,此适配器确保可靠的信号完整性。其镀金中心接触点最大限度地减少信号损失,而镀镍黄铜外壳增强了耐腐蚀性。这种直式适配器应用广泛,散装包装,品牌为 Amphenol RF。其磷青铜接触材料增加了耐用性。无论是在同轴电缆改造应用中、同轴电缆延长中,还是在需要接口转换的 OEM 同轴设置中,此适配器都是不可或缺的。在简洁的设计中,它简化了不同接口类型设备的互连,使其成为测试实验室和现场环境中的必备工具。适配器的坚固结构和适应性解决了互连难题,为需要高质量同轴连接的各种场景提供了可靠的解决方案。

使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程。

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持
库描述
该库包含 EZO Carrier Click - pH 驱动程序的 API。
关键功能:
ezocarrierph_send_cmd
- 发送命令功能。ezocarrierph_send_cmd_with_par
- 带参数的发送命令功能。ezocarrierph_send_cmd_check
- 检查已发送的命令。
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief EZO Carrier pH Click Example.
*
* # Description
* This example demonstrates the use of EZO Carrier pH click board by processing
* the incoming data and displaying them on the USB UART.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, performs the click default factory reset, and mid point calibration.
*
* ## Application Task
* Reads and processes all incoming pH value data and displays them on the USB UART.
*
* ## Additional Function
* - static void ezocarrierph_clear_app_buf ( void )
* - static void ezocarrierph_log_app_buf ( void )
* - static err_t ezocarrierph_process ( ezocarrierph_t *ctx )
* - static err_t ezocarrierdo_rsp_check ( ezocarrierdo_t *ctx, uint8_t *rsp )
* - static void ezocarrierdo_error_check ( err_t error_flag )
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "ezocarrierph.h"
// Application buffer size
#define APP_BUFFER_SIZE 200
#define PROCESS_BUFFER_SIZE 200
static ezocarrierph_t ezocarrierph;
static log_t logger;
static uint8_t app_buf[ APP_BUFFER_SIZE ] = { 0 };
static int32_t app_buf_len = 0;
static err_t error_flag;
/**
* @brief EZO Carrier pH clearing application buffer.
* @details This function clears memory of application buffer and reset its length.
* @note None.
*/
static void ezocarrierph_clear_app_buf ( void );
/**
* @brief EZO Carrier pH log application buffer.
* @details This function logs data from application buffer to USB UART.
* @note None.
*/
static void ezocarrierph_log_app_buf ( void );
/**
* @brief EZO Carrier pH data reading function.
* @details This function reads data from device and concatenates data to application buffer.
* @param[in] ctx : Click context object.
* See #ezocarrierph_t object definition for detailed explanation.
* @return @li @c 0 - Read some data.
* @li @c -1 - Nothing is read.
* See #err_t definition for detailed explanation.
* @note None.
*/
static err_t ezocarrierph_process ( ezocarrierph_t *ctx );
/**
* @brief Response check.
* @details This function checks for response and
* returns the status of response.
* @param[in] rsp Expected response.
* @return @li @c 0 - OK response.
* @li @c -1 - Error response.
* @li @c -2 - Timeout error.
* See #err_t definition for detailed explanation.
*/
static err_t ezocarrierph_rsp_check ( ezocarrierph_t *ctx, uint8_t *rsp );
/**
* @brief Check for errors.
* @details This function checks for different types of
* errors and logs them on UART or logs the response if no errors occured.
* @param[in] error_flag Error flag to check.
*/
static void ezocarrierph_error_check ( err_t error_flag );
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
ezocarrierph_cfg_t ezocarrierph_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ezocarrierph_cfg_setup( &ezocarrierph_cfg );
EZOCARRIERPH_MAP_MIKROBUS( ezocarrierph_cfg, MIKROBUS_1 );
if ( UART_ERROR == ezocarrierph_init( &ezocarrierph, &ezocarrierph_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_printf( &logger, "Device status \r\n" );
ezocarrierph_send_cmd( &ezocarrierph, EZOCARRIERPH_CMD_STATUS );
error_flag = ezocarrierph_rsp_check( &ezocarrierph, EZOCARRIERPH_RSP_OK );
ezocarrierph_error_check( error_flag );
log_printf( &logger, "Factory reset \r\n" );
ezocarrierph_send_cmd( &ezocarrierph, EZOCARRIERPH_CMD_FACTORY );
error_flag = ezocarrierph_rsp_check( &ezocarrierph, EZOCARRIERPH_RSP_READY );
ezocarrierph_error_check( error_flag );
log_printf( &logger, "Device info \r\n" );
ezocarrierph_send_cmd( &ezocarrierph, EZOCARRIERPH_CMD_DEV_INFO );
error_flag = ezocarrierph_rsp_check( &ezocarrierph, EZOCARRIERPH_RSP_OK );
ezocarrierph_error_check( error_flag );
uint8_t n_cnt = 0;
uint8_t last_reading[ APP_BUFFER_SIZE ] = { 0 };
ezocarrierph_clear_app_buf( );
ezocarrierph_send_cmd( &ezocarrierph, EZOCARRIERPH_CMD_SINGLE_READ );
ezocarrierph_process ( &ezocarrierph );
strcpy( last_reading, app_buf );
log_printf( &logger, "Mid point calibration \r\n" );
log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
log_printf( &logger, "Place probe into pH neutral solution \r\n" );
Delay_ms( 5000 );
log_printf( &logger, "Starting calibration \r\n" );
log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
log_printf( &logger, "Waiting for stable readings \r\n" );
while ( n_cnt <= 5 )
{
if ( EZOCARRIERPH_OK == ezocarrierph_process ( &ezocarrierph ) )
{
if ( 0 == strstr( app_buf, last_reading ) )
{
n_cnt++;
}
else
{
strcpy( last_reading, app_buf );
n_cnt = 0;
}
}
log_printf( &logger, "- " );
Delay_ms( 1000 );
ezocarrierph_clear_app_buf( );
}
#define MID_POINT_CALIB "mid,7.00"
log_printf( &logger, "\r\n Calibration \r\n" );
ezocarrierph_send_cmd_with_par( &ezocarrierph, EZOCARRIERPH_CMD_CAL, MID_POINT_CALIB );
error_flag = ezocarrierph_rsp_check( &ezocarrierph, EZOCARRIERPH_RSP_OK );
ezocarrierph_error_check( error_flag );
#define DISABLE_CONT_READ "0"
log_printf( &logger, "Disable continuous reading mode \r\n" );
ezocarrierph_send_cmd_with_par( &ezocarrierph, EZOCARRIERPH_CMD_CONT_READ, DISABLE_CONT_READ );
error_flag = ezocarrierph_rsp_check( &ezocarrierph, EZOCARRIERPH_RSP_OK );
ezocarrierph_error_check( error_flag );
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
log_printf( &logger, "Reading... \r\n" );
ezocarrierph_send_cmd( &ezocarrierph, EZOCARRIERPH_CMD_SINGLE_READ );
error_flag = ezocarrierph_rsp_check( &ezocarrierph, EZOCARRIERPH_RSP_OK );
ezocarrierph_error_check( error_flag );
Delay_ms( 5000 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
static void ezocarrierph_clear_app_buf ( void )
{
memset( app_buf, 0, app_buf_len );
app_buf_len = 0;
}
static void ezocarrierph_log_app_buf ( void )
{
for ( int32_t buf_cnt = 0; buf_cnt < app_buf_len; buf_cnt++ )
{
log_printf( &logger, "%c", app_buf[ buf_cnt ] );
}
}
static err_t ezocarrierph_process ( ezocarrierph_t *ctx )
{
uint8_t rx_buf[ PROCESS_BUFFER_SIZE ] = { 0 };
int32_t overflow_bytes = 0;
int32_t rx_cnt = 0;
int32_t rx_size = ezocarrierph_generic_read( ctx, rx_buf, PROCESS_BUFFER_SIZE );
if ( ( rx_size > 0 ) && ( rx_size <= APP_BUFFER_SIZE ) )
{
if ( ( app_buf_len + rx_size ) > APP_BUFFER_SIZE )
{
overflow_bytes = ( app_buf_len + rx_size ) - APP_BUFFER_SIZE;
app_buf_len = APP_BUFFER_SIZE - rx_size;
memmove ( app_buf, &app_buf[ overflow_bytes ], app_buf_len );
memset ( &app_buf[ app_buf_len ], 0, overflow_bytes );
}
for ( rx_cnt = 0; rx_cnt < rx_size; rx_cnt++ )
{
if ( rx_buf[ rx_cnt ] )
{
app_buf[ app_buf_len++ ] = rx_buf[ rx_cnt ];
}
}
return EZOCARRIERPH_OK;
}
return EZOCARRIERPH_ERROR;
}
static err_t ezocarrierph_rsp_check ( ezocarrierph_t *ctx, uint8_t *rsp )
{
uint32_t timeout_cnt = 0;
uint32_t timeout = 10000;
err_t error_flag = EZOCARRIERPH_OK;
ezocarrierph_clear_app_buf( );
while ( ( 0 == strstr( app_buf, rsp ) ) &&
( 0 == strstr( app_buf, EZOCARRIERPH_RSP_ERROR ) ) )
{
error_flag |= ezocarrierph_process( ctx );
if ( timeout_cnt++ > timeout )
{
ezocarrierph_clear_app_buf( );
return EZOCARRIERPH_ERROR_TIMEOUT;
}
Delay_ms( 1 );
}
Delay_ms( 100 );
error_flag |= ezocarrierph_process( ctx );
if ( strstr( app_buf, rsp ) )
{
return EZOCARRIERPH_OK;
}
else if ( strstr( app_buf, EZOCARRIERPH_RSP_ERROR ) )
{
return EZOCARRIERPH_ERROR;
}
else
{
return EZOCARRIERPH_ERROR;
}
}
static void ezocarrierph_error_check ( err_t error_flag )
{
switch ( error_flag )
{
case EZOCARRIERPH_OK:
{
ezocarrierph_log_app_buf( );
break;
}
case EZOCARRIERPH_ERROR:
{
log_error( &logger, " Error!" );
break;
}
case EZOCARRIERPH_ERROR_TIMEOUT:
{
log_error( &logger, " Timeout!" );
break;
}
default:
{
log_error( &logger, " Unknown!" );
break;
}
}
log_printf( &logger, "- - - - - - - - - - - - - - -\r\n" );
Delay_ms( 500 );
}
// ------------------------------------------------------------------------ END