Fertirrega_v6 with EC compensated by Temperature
This commit is contained in:
@@ -357,6 +357,7 @@ static const uint16_t AD5934_Scale_Out_Max[AD5934_CH_MAX] = {
|
|||||||
|
|
||||||
extern I2C_HandleTypeDef hi2c2;
|
extern I2C_HandleTypeDef hi2c2;
|
||||||
|
|
||||||
|
extern float reference_resistor, temperature_RTD, thermal_compensaded_EC;
|
||||||
|
|
||||||
extern volatile AD5934_State_t ad5934_state;
|
extern volatile AD5934_State_t ad5934_state;
|
||||||
extern volatile uint32_t g_ms_counter; // Increment each 1ms Timer
|
extern volatile uint32_t g_ms_counter; // Increment each 1ms Timer
|
||||||
@@ -364,6 +365,9 @@ extern volatile uint32_t g_ms_counter; // Increment each 1ms Timer
|
|||||||
extern uint8_t current_mux_channel;
|
extern uint8_t current_mux_channel;
|
||||||
extern uint8_t sweep_count; // Count how many sweeps done at the same channel now (0 a 7)
|
extern uint8_t sweep_count; // Count how many sweeps done at the same channel now (0 a 7)
|
||||||
extern uint8_t is_new_channel;
|
extern uint8_t is_new_channel;
|
||||||
|
extern uint8_t current_ec_mux;
|
||||||
|
extern uint8_t current_rtd_mux;
|
||||||
|
extern uint8_t current_ref_mux;
|
||||||
|
|
||||||
extern AD5934_filter_t g_rtd_filter, g_ec_filter, g_ref_filter;
|
extern AD5934_filter_t g_rtd_filter, g_ec_filter, g_ref_filter;
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,13 @@ volatile AD5934_State_t ad5934_state = AD5934_IDLE;
|
|||||||
|
|
||||||
volatile uint32_t g_ms_counter = 0; /* Incrementado a cada 1ms no Timer */
|
volatile uint32_t g_ms_counter = 0; /* Incrementado a cada 1ms no Timer */
|
||||||
|
|
||||||
|
float reference_resistor = 0, temperature_RTD = 0, thermal_compensaded_EC = 0;
|
||||||
|
|
||||||
uint8_t current_mux_channel = AD5934_ID_RTD;
|
uint8_t current_mux_channel = AD5934_ID_RTD;
|
||||||
uint8_t current_hw_mux_connection = ADG715_Channel_Map[AD5934_CH_RTD_LOW_GAIN]; // PT100 Connection
|
uint8_t current_hw_mux_connection = ADG715_Channel_Map[AD5934_CH_RTD_LOW_GAIN]; // PT100 Connection
|
||||||
|
uint8_t current_ec_mux = AD5934_CH_EC_MID_GAIN;
|
||||||
|
uint8_t current_rtd_mux = AD5934_CH_RTD_LOW_GAIN;
|
||||||
|
uint8_t current_ref_mux = AD5934_CH_REF100R_LOW_GAIN;
|
||||||
|
|
||||||
uint8_t sweep_count = 0; /* Conta quantos sweeps foram feitos no canal atual (0 a 7) */
|
uint8_t sweep_count = 0; /* Conta quantos sweeps foram feitos no canal atual (0 a 7) */
|
||||||
|
|
||||||
@@ -205,9 +210,10 @@ float AD5934_Calculate_Temperature(float mag_ref, float mag_dut)
|
|||||||
|
|
||||||
float ratio_mag = mag_ref / mag_dut;
|
float ratio_mag = mag_ref / mag_dut;
|
||||||
|
|
||||||
if(ch_ref==AD5934_CH_REF100R_LOW_GAIN) // only for PT100
|
// This correction isn't validated
|
||||||
|
/*if(ch_ref==AD5934_CH_REF100R_LOW_GAIN) // only for PT100
|
||||||
impedance_dut = AD5934_Linear_Correction(gain_factor * ratio_mag);
|
impedance_dut = AD5934_Linear_Correction(gain_factor * ratio_mag);
|
||||||
else
|
else*/
|
||||||
impedance_dut = gain_factor * ratio_mag;
|
impedance_dut = gain_factor * ratio_mag;
|
||||||
|
|
||||||
// Calculate impedance ratio with the Reference Resistor
|
// Calculate impedance ratio with the Reference Resistor
|
||||||
@@ -503,23 +509,23 @@ void AD5934_Process_System(void)
|
|||||||
{
|
{
|
||||||
case AD5934_ID_RTD:
|
case AD5934_ID_RTD:
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET) // OFF = PT1000, ON = PT100, PA7 has internal pull-up and switch connects to GND
|
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET) // OFF = PT1000, ON = PT100, PA7 has internal pull-up and switch connects to GND
|
||||||
current_hw_mux_connection = AD5934_CH_RTD_LOW_GAIN; //PT100
|
current_rtd_mux = current_hw_mux_connection = AD5934_CH_RTD_LOW_GAIN; //PT100
|
||||||
else
|
else
|
||||||
current_hw_mux_connection = AD5934_CH_RTD_MID_GAIN; //PT1000
|
current_rtd_mux = current_hw_mux_connection = AD5934_CH_RTD_MID_GAIN; //PT1000
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AD5934_ID_EC:
|
case AD5934_ID_EC:
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_6) == GPIO_PIN_SET) // Hardware Setup: Gain Selection (PA6)
|
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_6) == GPIO_PIN_SET) // Hardware Setup: Gain Selection (PA6)
|
||||||
current_hw_mux_connection = AD5934_CH_EC_HIGH_GAIN;
|
current_ec_mux = current_hw_mux_connection = AD5934_CH_EC_HIGH_GAIN;
|
||||||
else
|
else
|
||||||
current_hw_mux_connection = AD5934_CH_EC_MID_GAIN;
|
current_ec_mux = current_hw_mux_connection = AD5934_CH_EC_MID_GAIN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AD5934_ID_REF:
|
case AD5934_ID_REF:
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET) // OFF = PT1000, ON = PT100, PA7 has internal pull-up and switch connects to GND
|
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET) // OFF = PT1000, ON = PT100, PA7 has internal pull-up and switch connects to GND
|
||||||
current_hw_mux_connection = AD5934_CH_REF100R_LOW_GAIN; // 100 Ohms Reference Resistor
|
current_ref_mux = current_hw_mux_connection = AD5934_CH_REF100R_LOW_GAIN; // 100 Ohms Reference Resistor
|
||||||
else
|
else
|
||||||
current_hw_mux_connection = AD5934_CH_REF1K_MID_GAIN; // 1K Reference Resistor
|
current_ref_mux = current_hw_mux_connection = AD5934_CH_REF1K_MID_GAIN; // 1K Reference Resistor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ADG715_SetChannels(current_hw_mux_connection); // Change the analog mux
|
ADG715_SetChannels(current_hw_mux_connection); // Change the analog mux
|
||||||
|
|||||||
+42
-171
@@ -30,7 +30,6 @@
|
|||||||
#include "digital_outputs_driver.h"
|
#include "digital_outputs_driver.h"
|
||||||
#include "ad5934_driver.h"
|
#include "ad5934_driver.h"
|
||||||
#include "rs485_driver.h"
|
#include "rs485_driver.h"
|
||||||
#include "flash_manager.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -43,10 +42,7 @@
|
|||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
#define AVG_SLOPE (4.3F)
|
|
||||||
#define V_AT_25C (1.43F)
|
|
||||||
#define V_REF_INT (1.2F)
|
|
||||||
#define STM32_TEMPERATURE_AVERAGES 4
|
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
/* Private macro -------------------------------------------------------------*/
|
||||||
@@ -59,29 +55,6 @@
|
|||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
|
||||||
|
|
||||||
uint8_t newline[]={'\r','\n'};
|
|
||||||
uint8_t doubleSpace[]={'_','_','\0'};
|
|
||||||
uint8_t newline_ph[]={'_','p','H','\n','\0'};
|
|
||||||
uint8_t newline_admi[]={'_','u','S','\n','\0'};
|
|
||||||
uint8_t newline_temp[]={' ','°','C','\n','\0'};
|
|
||||||
uint8_t newline_imag[]={'_','O','h','m','\n','\0'};
|
|
||||||
uint8_t newline_485[]={'_','a','d','\n','\0'};
|
|
||||||
uint8_t minus[]={'-',' '};
|
|
||||||
uint8_t ad_t[]={'A','d',':',' ','\0'};
|
|
||||||
uint8_t ph_t[]={'p','H',':',' ','\0'};
|
|
||||||
uint8_t tm_t[]={'T','M',':',' ','\0'};
|
|
||||||
|
|
||||||
uint8_t main_state = STATE_RUNNING_OK;
|
|
||||||
uint8_t rs485_address=0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
uint16_t AD_RES[2];
|
|
||||||
uint8_t UpdateEvent = 0;
|
|
||||||
float Temperature, Temp_Sum, V_Sense, V_Ref;
|
|
||||||
float Temp_Samples[STM32_TEMPERATURE_AVERAGES]={0};
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
@@ -107,15 +80,16 @@ int main(void)
|
|||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
uint8_t tempString[15] = {0};
|
uint8_t tempString[15] = {0};
|
||||||
uint8_t i;
|
|
||||||
uint8_t mux_connection = 0;
|
uint8_t averages = 0;
|
||||||
|
uint8_t newline = '\n';
|
||||||
|
|
||||||
// Variables for timing
|
// Variables for timing
|
||||||
uint32_t previous_millis_green = 0;
|
uint32_t previous_millis_green = 0;
|
||||||
uint32_t previous_millis_red = 0;
|
uint32_t previous_millis_red = 0;
|
||||||
uint32_t current_millis;
|
uint32_t current_millis;
|
||||||
|
|
||||||
//float temperature_RTD, admittance_EC, refResistance, update_value, ph7_interp, ph4_interp, ph_compensated;
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
@@ -148,11 +122,6 @@ int main(void)
|
|||||||
|
|
||||||
HAL_TIM_Base_Start_IT(&htim3);
|
HAL_TIM_Base_Start_IT(&htim3);
|
||||||
|
|
||||||
/*
|
|
||||||
TempSensor_Init(&hadc1);
|
|
||||||
HAL_ADCEx_Calibration_Start(&hadc1);
|
|
||||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)AD_RES, 2); // Internal Temperature conversion
|
|
||||||
*/
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET); // LED Green Off
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET); // LED Green Off
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); // LED Red Off
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); // LED Red Off
|
||||||
@@ -167,83 +136,28 @@ int main(void)
|
|||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
/*
|
|
||||||
for(i=0;i<AD5934_TEMP_AVERAGES;i++) // Loop to get stability and get averages
|
while(averages<15)
|
||||||
{
|
{
|
||||||
refResistance = AD5934_Get_Ref_Resistance(); // On Board Resistor
|
AD5934_Process_System();
|
||||||
temperature_RTD = AD5934_GetTemperature(refResistance); // Liquid Temperature is stored
|
ADS1015_Process_System();
|
||||||
admittance_EC = AD5934_GetImpedance(temperature_RTD);
|
|
||||||
ph_compensated = ADSCalculate_ph_Compensated(temperature_RTD);
|
current_millis = g_ms_counter;
|
||||||
|
|
||||||
|
if((current_millis % 20) == 0) // Send data each 20ms
|
||||||
|
{
|
||||||
|
if (g_ref_filter.value_valid) // Reference Resistor on Board: 100 Ohms or 1000 Ohms
|
||||||
|
{
|
||||||
|
reference_resistor = g_ref_filter.filtered_value;
|
||||||
|
uint16_t reference_final = AD5934_REF_OUT_SCALE_MAX - AD5934_Compress_To_IntScale(g_ref_filter.filtered_value, current_ref_mux);
|
||||||
|
|
||||||
|
averages++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_3) == GPIO_PIN_RESET) // When PB3 (with internal pull up) in the Prog Header is set to GND
|
|
||||||
{
|
|
||||||
|
|
||||||
main_state = STATE_PH4_DRY_EC_CALIBRATION;
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); // Red LED On
|
|
||||||
|
|
||||||
for(i=0;i<(2*AD5934_TEMP_AVERAGES);i++) // Loop to get stability and get averages
|
|
||||||
{
|
|
||||||
flash_data.ph4_mV = ADSCalculate_ph_mV();
|
|
||||||
temperature_RTD = AD5934_GetTemperature(refResistance); // Air Temperature is not used in the function
|
|
||||||
flash_data.ec0_mag = AD5934_GetImpedance(temperature_RTD); // Dry Probe
|
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_6) == GPIO_PIN_SET)
|
|
||||||
flash_data.EC10mS_EC5mS_switch = AD5934_CH_EC_HIGH_GAIN; // 5mS/cm option
|
|
||||||
else
|
|
||||||
flash_data.EC10mS_EC5mS_switch = AD5934_CH_EC_MID_GAIN; //10ms/cm option
|
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET)
|
|
||||||
flash_data.PT100_PT1000_switch = AD5934_CH_RTD_LOW_GAIN; //PT100 option
|
|
||||||
else
|
|
||||||
flash_data.PT100_PT1000_switch = AD5934_CH_RTD_MID_GAIN; //PT1000 option
|
|
||||||
|
|
||||||
}
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET); // Green LED On
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
|
|
||||||
while(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_3) == GPIO_PIN_RESET);
|
|
||||||
HAL_Delay(500);
|
|
||||||
|
|
||||||
main_state = STATE_PH7_WET_EC_CALIBRATION;
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET);
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_RESET); // Red LED On
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(i=0;i<(2*AD5934_TEMP_AVERAGES);i++) // Loop to get stability and get averages
|
|
||||||
{
|
|
||||||
temperature_RTD = AD5934_GetTemperature(refResistance); // Liquid Temperature is stored
|
|
||||||
flash_data.ec_factor = AD5934_EC_Calibrate_Temperature(temperature_RTD);
|
|
||||||
flash_data.ph7_mV = ADSCalculate_ph_mV();
|
|
||||||
flash_data.ec1413_mag = AD5934_GetImpedance(temperature_RTD)*flash_data.ec_factor; // Get the magnitude of the reference liquid and compensate it to 25ºC
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ph7_interp = ADSinterpolate_ph(temperature_RTD,ADS1015_PH_7_BUFFER_ROW);
|
|
||||||
ph4_interp = ADSinterpolate_ph(temperature_RTD,ADS1015_PH_4_BUFFER_ROW);
|
|
||||||
|
|
||||||
flash_data.ph_temperature = temperature_RTD;
|
|
||||||
flash_data.ph_slope_mV = (flash_data.ph7_mV - flash_data.ph4_mV) / (ph7_interp - ph4_interp);
|
|
||||||
flash_data.ph7_real = ph7_interp;
|
|
||||||
|
|
||||||
Flash_Save_Page(&flash_data); // Store Calibration parameters in Flash
|
|
||||||
|
|
||||||
|
|
||||||
HAL_Delay(500);
|
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_RESET); // Green LED On
|
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET);
|
|
||||||
|
|
||||||
|
|
||||||
main_state = STATE_RUNNING_OK;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -253,52 +167,40 @@ int main(void)
|
|||||||
|
|
||||||
current_millis = g_ms_counter;
|
current_millis = g_ms_counter;
|
||||||
|
|
||||||
if((current_millis % 100) == 0) // Send data each 50ms
|
if((current_millis % 100) == 0) // Send data each 100ms
|
||||||
{
|
{
|
||||||
|
|
||||||
if (g_ref_filter.value_valid) // Reference Resistor on Board: 100 Ohms or 1000 Ohms
|
if (g_ref_filter.value_valid) // Reference Resistor on Board: 100 Ohms or 1000 Ohms
|
||||||
{
|
{
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET) // OFF = PT1000, ON = PT100, PA7 has internal pull-up and switch connects to GND
|
//reference_resistor = g_ref_filter.filtered_value;
|
||||||
mux_connection = AD5934_CH_REF100R_LOW_GAIN; // 100 Ohms Reference Resistor
|
uint16_t reference_final = AD5934_REF_OUT_SCALE_MAX - AD5934_Compress_To_IntScale(g_ref_filter.filtered_value, current_ref_mux);
|
||||||
else
|
|
||||||
mux_connection = AD5934_CH_REF1K_MID_GAIN; // 1K Reference Resistor
|
|
||||||
|
|
||||||
uint16_t reference_final = AD5934_REF_OUT_SCALE_MAX - AD5934_Compress_To_IntScale(g_ref_filter.filtered_value, mux_connection);
|
|
||||||
intToStr(reference_final, tempString);
|
intToStr(reference_final, tempString);
|
||||||
// float ref_final = g_ref_filter.filtered_value;
|
// float ref_final = g_ref_filter.filtered_value;
|
||||||
//FloatToString(tempString, ref_final);
|
//FloatToString(tempString, ref_final);
|
||||||
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
||||||
rs485_send_broadcast(newline, (strlen((uint8_t*)newline)));
|
rs485_send_broadcast(&newline, 1);
|
||||||
}
|
|
||||||
|
|
||||||
if (g_ec_filter.value_valid) // EC
|
|
||||||
{
|
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_6) == GPIO_PIN_SET) // Hardware Setup: Gain Selection (PA6)
|
|
||||||
mux_connection = AD5934_CH_EC_HIGH_GAIN; // 5mS
|
|
||||||
else
|
|
||||||
mux_connection = AD5934_CH_EC_MID_GAIN; // 10mS
|
|
||||||
|
|
||||||
uint16_t ec_final = AD5934_Compress_To_IntScale(g_ec_filter.filtered_value, mux_connection);
|
|
||||||
intToStr(ec_final, tempString);
|
|
||||||
// float ec_final = g_ec_filter.filtered_value;
|
|
||||||
// FloatToString(tempString, ec_final);
|
|
||||||
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
|
||||||
rs485_send_broadcast(newline, (strlen((uint8_t*)newline)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_rtd_filter.value_valid) // PT100 or PT1000 in °C
|
if (g_rtd_filter.value_valid) // PT100 or PT1000 in °C
|
||||||
{
|
{
|
||||||
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7) == GPIO_PIN_SET) // OFF = PT1000, ON = PT100, PA7 has internal pull-up and switch connects to GND
|
temperature_RTD = AD5934_Calculate_Temperature(reference_resistor, g_rtd_filter.filtered_value);
|
||||||
mux_connection = AD5934_CH_RTD_LOW_GAIN; //PT100
|
uint16_t rtd_final = AD5934_RTD_OUT_SCALE_MAX - AD5934_Compress_To_IntScale(g_rtd_filter.filtered_value, current_rtd_mux);
|
||||||
else
|
|
||||||
mux_connection = AD5934_CH_RTD_MID_GAIN; //PT1000
|
|
||||||
|
|
||||||
uint16_t rtd_final = AD5934_RTD_OUT_SCALE_MAX - AD5934_Compress_To_IntScale(g_rtd_filter.filtered_value, mux_connection);
|
|
||||||
intToStr(rtd_final, tempString);
|
intToStr(rtd_final, tempString);
|
||||||
//float rtd_final = g_rtd_filter.filtered_value;
|
//float rtd_final = g_rtd_filter.filtered_value;
|
||||||
//FloatToString(tempString, rtd_final);
|
//FloatToString(tempString, rtd_final);
|
||||||
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
||||||
rs485_send_broadcast(newline, (strlen((uint8_t*)newline)));
|
rs485_send_broadcast(&newline, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_ec_filter.value_valid) // EC
|
||||||
|
{
|
||||||
|
thermal_compensaded_EC = AD5934_EC_Compensate_Magnitude_To_25C(g_ec_filter.filtered_value, temperature_RTD);
|
||||||
|
uint16_t ec_final = AD5934_Compress_To_IntScale(thermal_compensaded_EC, current_ec_mux);
|
||||||
|
intToStr(ec_final, tempString);
|
||||||
|
// float ec_final = g_ec_filter.filtered_value;
|
||||||
|
// FloatToString(tempString, ec_final);
|
||||||
|
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
||||||
|
rs485_send_broadcast(&newline, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ph_filter.value_valid) // pH
|
if (g_ph_filter.value_valid) // pH
|
||||||
@@ -308,10 +210,10 @@ int main(void)
|
|||||||
//float ph_final = g_ph_filter.filtered_value;
|
//float ph_final = g_ph_filter.filtered_value;
|
||||||
//FloatToString(tempString, ph_final);
|
//FloatToString(tempString, ph_final);
|
||||||
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
rs485_send_broadcast(tempString, (strlen((uint8_t*)tempString)));
|
||||||
rs485_send_broadcast(newline, (strlen((uint8_t*)newline)));
|
rs485_send_broadcast(&newline, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs485_send_broadcast(newline, (strlen((uint8_t*)newline)));
|
rs485_send_broadcast(&newline, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,30 +234,7 @@ int main(void)
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*
|
|
||||||
if(UpdateEvent) // Internal Temperature
|
|
||||||
{
|
|
||||||
|
|
||||||
for (i = (STM32_TEMPERATURE_AVERAGES-1); i > 0; i--)
|
|
||||||
Temp_Samples[i] = Temp_Samples[i-1];
|
|
||||||
|
|
||||||
|
|
||||||
// Read real and imaginary data
|
|
||||||
if(AD_RES[0]>0.0f)
|
|
||||||
V_Ref = (float)((V_REF_INT * 4095.0)/AD_RES[0]);
|
|
||||||
else
|
|
||||||
V_Ref = 0.0f;
|
|
||||||
V_Sense = (float)(AD_RES[1] * V_Ref) / 4095.0;
|
|
||||||
Temp_Samples[0] = (((V_AT_25C - V_Sense) * 1000.0) /AVG_SLOPE) + 25.0;
|
|
||||||
|
|
||||||
for (i = 0, Temp_Sum=0; i < STM32_TEMPERATURE_AVERAGES; i++)
|
|
||||||
Temp_Sum += Temp_Samples[i];
|
|
||||||
|
|
||||||
Temperature = Temp_Sum/((float)STM32_TEMPERATURE_AVERAGES);
|
|
||||||
|
|
||||||
UpdateEvent = 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,14 +434,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
|
|
||||||
{
|
|
||||||
UpdateEvent = 1; // Internal TEmperature
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
../Core/Src/ad5934_driver.c:40:6:AD5934_SetRegisterValue 2
|
../Core/Src/ad5934_driver.c:45:6:AD5934_SetRegisterValue 2
|
||||||
../Core/Src/ad5934_driver.c:68:10:AD5934_GetRegisterValue 3
|
../Core/Src/ad5934_driver.c:73:10:AD5934_GetRegisterValue 3
|
||||||
../Core/Src/ad5934_driver.c:103:6:AD5934_Init 1
|
../Core/Src/ad5934_driver.c:108:6:AD5934_Init 1
|
||||||
../Core/Src/ad5934_driver.c:134:6:AD5934_RestartSweep 1
|
../Core/Src/ad5934_driver.c:139:6:AD5934_RestartSweep 1
|
||||||
../Core/Src/ad5934_driver.c:157:6:AD5934_Repeat_Sweep 1
|
../Core/Src/ad5934_driver.c:162:6:AD5934_Repeat_Sweep 1
|
||||||
../Core/Src/ad5934_driver.c:170:6:AD5934_StopSweep 1
|
../Core/Src/ad5934_driver.c:175:6:AD5934_StopSweep 1
|
||||||
../Core/Src/ad5934_driver.c:190:7:AD5934_Calculate_Temperature 3
|
../Core/Src/ad5934_driver.c:195:7:AD5934_Calculate_Temperature 2
|
||||||
../Core/Src/ad5934_driver.c:231:7:AD5934_EC_Compensate_Magnitude_To_25C 2
|
../Core/Src/ad5934_driver.c:237:7:AD5934_EC_Compensate_Magnitude_To_25C 2
|
||||||
../Core/Src/ad5934_driver.c:246:7:AD5934_EC_Calibrate_Temperature 5
|
../Core/Src/ad5934_driver.c:252:7:AD5934_EC_Calibrate_Temperature 5
|
||||||
../Core/Src/ad5934_driver.c:292:7:AD5934_GetMagnitude 1
|
../Core/Src/ad5934_driver.c:298:7:AD5934_GetMagnitude 1
|
||||||
../Core/Src/ad5934_driver.c:317:10:AD5934_Compress_To_IntScale 5
|
../Core/Src/ad5934_driver.c:323:10:AD5934_Compress_To_IntScale 5
|
||||||
../Core/Src/ad5934_driver.c:347:7:AD5934_Round_Float_Precision 2
|
../Core/Src/ad5934_driver.c:353:7:AD5934_Round_Float_Precision 2
|
||||||
../Core/Src/ad5934_driver.c:372:7:AD5934_Linear_Correction 1
|
../Core/Src/ad5934_driver.c:378:7:AD5934_Linear_Correction 1
|
||||||
../Core/Src/ad5934_driver.c:391:7:AD5934_Calibrate 1
|
../Core/Src/ad5934_driver.c:397:7:AD5934_Calibrate 1
|
||||||
../Core/Src/ad5934_driver.c:413:6:AD5934_Process_System 24
|
../Core/Src/ad5934_driver.c:419:6:AD5934_Process_System 24
|
||||||
../Core/Src/ad5934_driver.c:538:6:AD5934_Sort_Array 4
|
../Core/Src/ad5934_driver.c:544:6:AD5934_Sort_Array 4
|
||||||
../Core/Src/ad5934_driver.c:560:7:AD5934_Trimmed_Mean 3
|
../Core/Src/ad5934_driver.c:566:7:AD5934_Trimmed_Mean 3
|
||||||
../Core/Src/ad5934_driver.c:586:7:AD5934_History_Average 2
|
../Core/Src/ad5934_driver.c:592:7:AD5934_History_Average 2
|
||||||
../Core/Src/ad5934_driver.c:600:6:AD5934_Process_Sample 4
|
../Core/Src/ad5934_driver.c:606:6:AD5934_Process_Sample 4
|
||||||
../Core/Src/ad5934_driver.c:646:6:AD5934_RTD_NewSample 1
|
../Core/Src/ad5934_driver.c:652:6:AD5934_RTD_NewSample 1
|
||||||
../Core/Src/ad5934_driver.c:653:6:AD5934_EC_NewSample 1
|
../Core/Src/ad5934_driver.c:659:6:AD5934_EC_NewSample 1
|
||||||
../Core/Src/ad5934_driver.c:660:6:AD5934_Reference_NewSample 1
|
../Core/Src/ad5934_driver.c:666:6:AD5934_Reference_NewSample 1
|
||||||
../Core/Src/ad5934_driver.c:676:6:ADG715_SetRegisterValue 1
|
../Core/Src/ad5934_driver.c:682:6:ADG715_SetRegisterValue 1
|
||||||
../Core/Src/ad5934_driver.c:694:6:ADG715_ResetChannels 1
|
../Core/Src/ad5934_driver.c:700:6:ADG715_ResetChannels 1
|
||||||
../Core/Src/ad5934_driver.c:706:6:ADG715_SetChannels 2
|
../Core/Src/ad5934_driver.c:712:6:ADG715_SetChannels 2
|
||||||
|
|||||||
Binary file not shown.
@@ -1,25 +1,25 @@
|
|||||||
../Core/Src/ad5934_driver.c:40:6:AD5934_SetRegisterValue 32 static
|
../Core/Src/ad5934_driver.c:45:6:AD5934_SetRegisterValue 32 static
|
||||||
../Core/Src/ad5934_driver.c:68:10:AD5934_GetRegisterValue 40 static
|
../Core/Src/ad5934_driver.c:73:10:AD5934_GetRegisterValue 40 static
|
||||||
../Core/Src/ad5934_driver.c:103:6:AD5934_Init 8 static
|
../Core/Src/ad5934_driver.c:108:6:AD5934_Init 8 static
|
||||||
../Core/Src/ad5934_driver.c:134:6:AD5934_RestartSweep 8 static
|
../Core/Src/ad5934_driver.c:139:6:AD5934_RestartSweep 8 static
|
||||||
../Core/Src/ad5934_driver.c:157:6:AD5934_Repeat_Sweep 8 static
|
../Core/Src/ad5934_driver.c:162:6:AD5934_Repeat_Sweep 8 static
|
||||||
../Core/Src/ad5934_driver.c:170:6:AD5934_StopSweep 8 static
|
../Core/Src/ad5934_driver.c:175:6:AD5934_StopSweep 8 static
|
||||||
../Core/Src/ad5934_driver.c:190:7:AD5934_Calculate_Temperature 40 static
|
../Core/Src/ad5934_driver.c:195:7:AD5934_Calculate_Temperature 40 static
|
||||||
../Core/Src/ad5934_driver.c:231:7:AD5934_EC_Compensate_Magnitude_To_25C 24 static
|
../Core/Src/ad5934_driver.c:237:7:AD5934_EC_Compensate_Magnitude_To_25C 24 static
|
||||||
../Core/Src/ad5934_driver.c:246:7:AD5934_EC_Calibrate_Temperature 152 static
|
../Core/Src/ad5934_driver.c:252:7:AD5934_EC_Calibrate_Temperature 152 static
|
||||||
../Core/Src/ad5934_driver.c:292:7:AD5934_GetMagnitude 24 static
|
../Core/Src/ad5934_driver.c:298:7:AD5934_GetMagnitude 24 static
|
||||||
../Core/Src/ad5934_driver.c:317:10:AD5934_Compress_To_IntScale 32 static
|
../Core/Src/ad5934_driver.c:323:10:AD5934_Compress_To_IntScale 32 static
|
||||||
../Core/Src/ad5934_driver.c:347:7:AD5934_Round_Float_Precision 24 static
|
../Core/Src/ad5934_driver.c:353:7:AD5934_Round_Float_Precision 24 static
|
||||||
../Core/Src/ad5934_driver.c:372:7:AD5934_Linear_Correction 24 static
|
../Core/Src/ad5934_driver.c:378:7:AD5934_Linear_Correction 24 static
|
||||||
../Core/Src/ad5934_driver.c:391:7:AD5934_Calibrate 48 static
|
../Core/Src/ad5934_driver.c:397:7:AD5934_Calibrate 48 static
|
||||||
../Core/Src/ad5934_driver.c:413:6:AD5934_Process_System 16 static
|
../Core/Src/ad5934_driver.c:419:6:AD5934_Process_System 16 static
|
||||||
../Core/Src/ad5934_driver.c:538:6:AD5934_Sort_Array 24 static
|
../Core/Src/ad5934_driver.c:544:6:AD5934_Sort_Array 24 static
|
||||||
../Core/Src/ad5934_driver.c:560:7:AD5934_Trimmed_Mean 32 static
|
../Core/Src/ad5934_driver.c:566:7:AD5934_Trimmed_Mean 32 static
|
||||||
../Core/Src/ad5934_driver.c:586:7:AD5934_History_Average 24 static
|
../Core/Src/ad5934_driver.c:592:7:AD5934_History_Average 24 static
|
||||||
../Core/Src/ad5934_driver.c:600:6:AD5934_Process_Sample 32 static
|
../Core/Src/ad5934_driver.c:606:6:AD5934_Process_Sample 32 static
|
||||||
../Core/Src/ad5934_driver.c:646:6:AD5934_RTD_NewSample 16 static
|
../Core/Src/ad5934_driver.c:652:6:AD5934_RTD_NewSample 16 static
|
||||||
../Core/Src/ad5934_driver.c:653:6:AD5934_EC_NewSample 16 static
|
../Core/Src/ad5934_driver.c:659:6:AD5934_EC_NewSample 16 static
|
||||||
../Core/Src/ad5934_driver.c:660:6:AD5934_Reference_NewSample 16 static
|
../Core/Src/ad5934_driver.c:666:6:AD5934_Reference_NewSample 16 static
|
||||||
../Core/Src/ad5934_driver.c:676:6:ADG715_SetRegisterValue 32 static
|
../Core/Src/ad5934_driver.c:682:6:ADG715_SetRegisterValue 32 static
|
||||||
../Core/Src/ad5934_driver.c:694:6:ADG715_ResetChannels 8 static
|
../Core/Src/ad5934_driver.c:700:6:ADG715_ResetChannels 8 static
|
||||||
../Core/Src/ad5934_driver.c:706:6:ADG715_SetChannels 16 static
|
../Core/Src/ad5934_driver.c:712:6:ADG715_SetChannels 16 static
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
../Core/Src/main.c:105:5:main 10
|
../Core/Src/main.c:78:5:main 10
|
||||||
../Core/Src/main.c:377:6:SystemClock_Config 4
|
../Core/Src/main.c:256:6:SystemClock_Config 4
|
||||||
../Core/Src/main.c:428:6:FloatToString 8
|
../Core/Src/main.c:307:6:FloatToString 8
|
||||||
../Core/Src/main.c:490:6:intToStr 12
|
../Core/Src/main.c:369:6:intToStr 12
|
||||||
../Core/Src/main.c:548:6:HAL_TIM_PeriodElapsedCallback 2
|
../Core/Src/main.c:427:6:HAL_TIM_PeriodElapsedCallback 2
|
||||||
../Core/Src/main.c:572:6:Error_Handler 1
|
../Core/Src/main.c:443:6:Error_Handler 1
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ Core/Src/main.o: ../Core/Src/main.c ../Core/Inc/main.h \
|
|||||||
../Core/Inc/usart.h ../Core/Inc/gpio.h ../Core/Inc/ads1015_driver.h \
|
../Core/Inc/usart.h ../Core/Inc/gpio.h ../Core/Inc/ads1015_driver.h \
|
||||||
../Core/Inc/flash_manager.h ../Core/Inc/digital_outputs_driver.h \
|
../Core/Inc/flash_manager.h ../Core/Inc/digital_outputs_driver.h \
|
||||||
../Core/Inc/ad5934_driver.h ../Core/Inc/rs485_driver.h \
|
../Core/Inc/ad5934_driver.h ../Core/Inc/rs485_driver.h \
|
||||||
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h \
|
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h
|
||||||
../Core/Inc/flash_manager.h
|
|
||||||
../Core/Inc/main.h:
|
../Core/Inc/main.h:
|
||||||
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:
|
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h:
|
||||||
../Core/Inc/stm32f1xx_hal_conf.h:
|
../Core/Inc/stm32f1xx_hal_conf.h:
|
||||||
@@ -74,4 +73,3 @@ Core/Src/main.o: ../Core/Src/main.c ../Core/Inc/main.h \
|
|||||||
../Core/Inc/ad5934_driver.h:
|
../Core/Inc/ad5934_driver.h:
|
||||||
../Core/Inc/rs485_driver.h:
|
../Core/Inc/rs485_driver.h:
|
||||||
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h:
|
../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_ll_gpio.h:
|
||||||
../Core/Inc/flash_manager.h:
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
../Core/Src/main.c:105:5:main 48 static
|
../Core/Src/main.c:78:5:main 56 static
|
||||||
../Core/Src/main.c:377:6:SystemClock_Config 88 static
|
../Core/Src/main.c:256:6:SystemClock_Config 88 static
|
||||||
../Core/Src/main.c:428:6:FloatToString 104 static
|
../Core/Src/main.c:307:6:FloatToString 104 static
|
||||||
../Core/Src/main.c:490:6:intToStr 32 static
|
../Core/Src/main.c:369:6:intToStr 32 static
|
||||||
../Core/Src/main.c:548:6:HAL_TIM_PeriodElapsedCallback 16 static
|
../Core/Src/main.c:427:6:HAL_TIM_PeriodElapsedCallback 16 static
|
||||||
../Core/Src/main.c:572:6:Error_Handler 4 static,ignoring_inline_asm
|
../Core/Src/main.c:443:6:Error_Handler 4 static,ignoring_inline_asm
|
||||||
|
|||||||
Binary file not shown.
+10156
-9938
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user