确定液体的酸性或碱性,其范围从强酸到强碱。
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™ 板配有包含易于使用功能和示例代码的库,可用于进一步开发。
功能概述
开发板
Nucleo-64 搭载 STM32F446RE MCU 提供了一种经济高效且灵活的平台,供开发者探索新想法并原型设计他们的项目。该板利用 STM32 微控制器的多功能性,使用户能够为他们的项目选择最佳的性能与功耗平衡。它配备了 LQFP64 封装的 STM32 微控制器,并包含了如用户 LED(同时作为 ARDUINO® 信号)、用户和复位按钮,以及 32.768kHz 晶体振荡器用于精确的计时操作等基本组件。Nucleo-64 板设计考虑到扩展性和灵活性,它特有的 ARDUINO® Uno
V3 扩展连接器和 ST morpho 扩展引脚头,提供了对 STM32 I/O 的完全访问,以实现全面的项目整合。电源供应选项灵活,支持 ST-LINK USB VBUS 或外部电源,确保在各种开发环境中的适应性。该板还配备了一个具有 USB 重枚举功能的板载 ST-LINK 调试器/编程器,简化了编程和调试过程。此外,该板设计旨在简化高级开发,它的外部 SMPS 为 Vcore 逻辑供电提供高效支持,支持 USB 设备全速或 USB SNK/UFP 全速,并内置加密功能,提升了项目的功效
和安全性。通过外部 SMPS 实验的专用连接器、 用于 ST-LINK 的 USB 连接器以及 MIPI® 调试连接器,提供了更多的硬件接口和实验可能性。开发者将通过 STM32Cube MCU Package 提供的全面免费软件库和示例得到广泛支持。这些,加上与多种集成开发环境(IDE)的兼容性,包括 IAR Embedded Workbench®、MDK-ARM 和 STM32CubeIDE,确保了流畅且高效的开发体验,使用户能够充分利用 Nucleo-64 板在他们的项目中的能力。
微控制器概述
MCU卡片 / MCU

建筑
ARM Cortex-M4
MCU 内存 (KB)
512
硅供应商
STMicroelectronics
引脚数
64
RAM (字节)
131072
你完善了我!
配件
Click Shield for Nucleo-64 配备了两个专有的 mikroBUS™ 插座,使得所有的 Click board™ 设备都可以轻松地与 STM32 Nucleo-64 开发板连接。这样,Mikroe 允许其用户从不断增长的 Click boards™ 范围中添加任何功能,如 WiFi、GSM、GPS、蓝牙、ZigBee、环境传感器、LED、语音识别、电机控制、运动传感器等。您可以使用超过 1537 个 Click boards™,这些 Click boards™ 可以堆叠和集成。STM32 Nucleo-64 开发板基于 64 引脚封装的微控制器,采用 32 位 MCU,配备 ARM Cortex M4 处理器,运行速度为 84MHz,具有 512Kb Flash 和 96KB SRAM,分为两个区域,顶部区域代表 ST-Link/V2 调试器和编程器,而底部区域是一个实际的开发板。通过 USB 连接方便地控制和供电这些板子,以便直接对 Nucleo-64 开发板进行编程和高效调试,其中还需要额外的 USB 线连接到板子上的 USB 迷你接口。大多数 STM32 微控制器引脚都连接到了板子左右边缘的 IO 引脚上,然后连接到两个现有的 mikroBUS™ 插座上。该 Click Shield 还有几个开关,用于选择 mikroBUS™ 插座上模拟信号的逻辑电平和 mikroBUS™ 插座本身的逻辑电压电平。此外,用户还可以通过现有的双向电平转换器,使用任何 Click board™,无论 Click board™ 是否在 3.3V 或 5V 逻辑电压电平下运行。一旦将 STM32 Nucleo-64 开发板与我们的 Click Shield for Nucleo-64 连接,您就可以访问数百个工作于 3.3V 或 5V 逻辑电压电平的 Click boards™。
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