MODEL_ADC_EX/APP/main.c

63 lines
2.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include "ADC_Temp.h"
int main() {
// Инициализируем обе таблицы одновременно с разными значениями R1
init_both_tables(3300.0f, // R1 для KST45
20000.0f, // R1 для INCAR
ALG_STEINHART);
uint16_t adc_value = 1980;
printf("\n=== Работа с обеими таблицами одновременно ===\n");
// Получаем температуру для KST45
int16_t temp_kst45 = get_temperature_log_fast_for_table(adc_value, TABLE_KST45);
printf("KST45: ADC=%u, Temp=%.1f °C\n", adc_value, temp_kst45 / 10.0f);
// Получаем температуру для INCAR
int16_t temp_incar = get_temperature_log_fast_for_table(adc_value, TABLE_INCAR);
printf("INCAR: ADC=%u, Temp=%.1f °C\n", adc_value, temp_incar / 10.0f);
// Можно переключать активную конфигурацию
printf("\n=== Переключение активной конфигурации ===\n");
set_active_config(TABLE_KST45, 3300.0f);
int16_t temp_active1 = get_temperature_log_fast(adc_value);
printf("Активная (KST45): Temp=%.1f °C\n", temp_active1 / 10.0f);
set_active_config(TABLE_INCAR, 20000.0f);
int16_t temp_active2 = get_temperature_log_fast(adc_value);
printf("Активная (INCAR): Temp=%.1f °C\n", temp_active2 / 10.0f);
// Получаем доступ к таблицам для отладки
const fast_lookup_tables_t* tables = get_fast_tables();
printf("\n=== Пример данных из таблиц быстрого поиска ===\n");
printf("KST45 таблица (первые 3 записи):\n");
for(int i = 0; i < 3; i++) {
printf(" ADC: %u, Temp: %.1f °C, R: %.2f Ω\n",
tables->kst45[i].adc_value,
tables->kst45[i].temp_c / 10.0f,
tables->kst45[i].resistance_ohm);
}
printf("\nINCAR таблица (первые 3 записи):\n");
for(int i = 0; i < 3; i++) {
printf(" ADC: %u, Temp: %.1f °C, R: %.2f Ω\n",
tables->incar[i].adc_value,
tables->incar[i].temp_c / 10.0f,
tables->incar[i].resistance_ohm);
}
// Пример обратного преобразования (температура -> сопротивление)
printf("\n=== Обратное преобразование ===\n");
int16_t temp_test = 250; // 25.0 °C
float resistance_kst45 = get_resistance_log_fast_for_table(temp_test, TABLE_KST45);
float resistance_incar = get_resistance_log_fast_for_table(temp_test, TABLE_INCAR);
printf("При %.1f °C:\n", temp_test / 10.0f);
printf(" KST45 сопротивление: %.2f Ω\n", resistance_kst45);
printf(" INCAR сопротивление: %.2f Ω\n", resistance_incar);
return 0;
}