- Piezo 6ch 측정 + 센서(배터리, IMU, 온도) 측정: mbb 명령어 추가
- Flash Memory Piezo 측정 파라미터 추가 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,8 @@
|
||||
/*******************************************************************************
|
||||
* [모듈 개요] TMP235-Q1 아날로그 온도센서 드라이버
|
||||
*
|
||||
* TMP235-Q1은 온도에 비례하는 아날로그 전압(Vout)을 출력하는 센서이다.
|
||||
* nRF52840 SAADC의 AIN3 채널로 Vout을 읽고, mV로 변환한 뒤
|
||||
* 온도(°C)로 계산한다.
|
||||
* TMP235-Q1은 온도에 비례하는 아날로그 전압(Vout)을 출력하는 센서
|
||||
* nRF52840 SAADC의 AIN3 채널로 Vout을 읽고, mV로 변환한 뒤 온도(°C)로 계산
|
||||
*
|
||||
* 온도 계산 공식 (구간별 선형 보간):
|
||||
* - Vout <= 1500mV (0~100°C): Ta = (Vout - 500) / 10.0
|
||||
@@ -61,13 +60,17 @@
|
||||
static nrf_saadc_value_t adc_buf;
|
||||
extern char ble_tx_buffer[BLE_NUS_MAX_DATA_LEN];
|
||||
extern uint8_t ble_bin_buffer[BLE_NUS_MAX_DATA_LEN] ;
|
||||
|
||||
/* 현재 명령 소스: CMD_UART 또는 CMD_BLE */
|
||||
extern which_cmd_t cmd_type_t;
|
||||
|
||||
/* info4: 전체 센서 데이터 수집 모드 플래그 */
|
||||
extern bool info4; //cmd_parse
|
||||
extern bool info4; // main.c
|
||||
|
||||
/* 온도 측정 순서 제어 플래그 */
|
||||
extern bool go_temp; //cmd_parse
|
||||
/* info4 모드에서 온도값을 임시 저장 (°C x 100, 정수 표현) */
|
||||
extern bool go_temp; // main_timer.c
|
||||
|
||||
/* info4 모드에서 온도값 임시 저장 (°C x 100, 정수 표현) */
|
||||
volatile uint16_t info_temp; //48_C
|
||||
extern bool motion_raw_data_enabled;
|
||||
|
||||
@@ -87,9 +90,9 @@ extern bool motion_raw_data_enabled;
|
||||
*/
|
||||
void tmp235_voltage_handler(nrf_drv_saadc_evt_t const * p_event) /* TMP325 Vout reading */
|
||||
{
|
||||
|
||||
float led_temp; /* 계산된 온도 (°C, 부동소수점) */
|
||||
uint16_t led_temp_16; /* BLE 전송용 온도 (°C x 100, 정수) */
|
||||
|
||||
if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
|
||||
{
|
||||
nrf_saadc_value_t adc_result;
|
||||
@@ -113,50 +116,50 @@ void tmp235_voltage_handler(nrf_drv_saadc_evt_t const * p_event) /* TMP325 Vout
|
||||
* 100~125°C 구간: 기울기 10.1 mV/°C
|
||||
* 125~150°C 구간: 기울기 10.6 mV/°C
|
||||
*/
|
||||
if(tmp235_voltage_in_milli_volts <= 1500) {
|
||||
if(tmp235_voltage_in_milli_volts <= 1500)
|
||||
{
|
||||
/* 0~100°C: Ta = (Vout - 500mV) / 10.0 mV/°C */
|
||||
led_temp = (tmp235_voltage_in_milli_volts - 500.0f) / 10.0f + 0.0f;
|
||||
}else if(tmp235_voltage_in_milli_volts <= 1750) {
|
||||
}
|
||||
else if(tmp235_voltage_in_milli_volts <= 1750)
|
||||
{
|
||||
/* 100~125°C: 기울기가 10.1로 약간 증가 */
|
||||
led_temp = (tmp235_voltage_in_milli_volts - 1500.0f) / 10.1f + 100.0f;
|
||||
}else if(tmp235_voltage_in_milli_volts <= 2000) {
|
||||
}
|
||||
else if(tmp235_voltage_in_milli_volts <= 2000)
|
||||
{
|
||||
/* 125~150°C: 기울기가 10.6으로 더 증가 */
|
||||
led_temp = (tmp235_voltage_in_milli_volts - 1752.5f) / 10.6f + 125.0f;
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 150°C 초과 — 센서 측정 범위 벗어남 */
|
||||
DBG_PRINTF("ERR!!! Temprature is over 150c\r\n");
|
||||
}
|
||||
|
||||
/* info4 모드: 온도값을 정수(°C x 100)로 저장 (예: 36.50°C → 3650) */
|
||||
if (info4 == true){
|
||||
|
||||
if (info4 == true)
|
||||
{
|
||||
info_temp =(uint16_t)(led_temp*100);
|
||||
|
||||
}
|
||||
/* UART 모드: 소수점 2자리까지 텍스트로 출력 */
|
||||
else if(cmd_type_t == CMD_UART) {
|
||||
else if(cmd_type_t == CMD_UART)
|
||||
{
|
||||
DBG_PRINTF("To%.2f\r\n\r\n",led_temp);
|
||||
}
|
||||
/* BLE 모드: °C x 100 정수를 "rso:" 헤더로 바이너리 전송 */
|
||||
} else if(cmd_type_t == CMD_BLE) {
|
||||
led_temp_16 = (uint16_t)(led_temp*100);
|
||||
single_format_data(ble_bin_buffer, "rso:", led_temp_16);
|
||||
else if(cmd_type_t == CMD_BLE)
|
||||
{
|
||||
led_temp_16 = (uint16_t)(led_temp*100);
|
||||
single_format_data(ble_bin_buffer, "rso:", led_temp_16);
|
||||
|
||||
dr_binary_tx_safe(ble_bin_buffer,3);
|
||||
dr_binary_tx_safe(ble_bin_buffer,3);
|
||||
|
||||
// sprintf(ble_tx_buffer, "To%.2f\r\n",led_temp);
|
||||
// data_tx_handler(ble_tx_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* info4 모드: 온도 측정 완료 → 다음 단계(IMU 측정)로 전환 */
|
||||
if (info4 == true){
|
||||
|
||||
go_temp = false; /* 온도 측정 완료 표시 */
|
||||
|
||||
|
||||
motion_raw_data_enabled = true; /* IMU 데이터 수집 시작 플래그 */
|
||||
main_timer_start(); /* 메인 타이머 시작 → IMU 측정 트리거 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +176,7 @@ void tmp235_init(void)
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
/* AIN3 채널 설정: TMP235-Q1 Vout 핀 (싱글엔드 입력) */
|
||||
nrf_saadc_channel_config_t config =
|
||||
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN3); /* TMP235_Q1 Voltage Output Measurement */
|
||||
nrf_saadc_channel_config_t config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN3); /* TMP235_Q1 Voltage Output Measurement */
|
||||
err_code = nrf_drv_saadc_channel_init(0, &config);
|
||||
APP_ERROR_CHECK(err_code);
|
||||
|
||||
@@ -197,8 +199,7 @@ void tmp235_init(void)
|
||||
*/
|
||||
void tmp235_voltage_level_meas(void)
|
||||
{
|
||||
tmp235_init();
|
||||
tmp235_init(); // init 함수에 있는 걸 그냥 여기 넣어도
|
||||
//tmp235_uninit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user