Fertirrega_v6 AD5934 frequency at 2.5kHz
This commit is contained in:
@@ -87,10 +87,14 @@ extern "C" {
|
||||
|
||||
|
||||
// Values for frequency counts = (freq*2^27)/(1MHz/16)
|
||||
#define AD5934_FREQ_4K882HZ 0x009FF92F // 4.882kHz
|
||||
#define AD5934_FREQ_2K5HZ 0x0051EB86 // 2.5kHz
|
||||
#define AD5934_FREQ_1K953HZ 0x003FFEF3 // 1.953kHz
|
||||
#define AD5934_FREQ_1K590HZ 0x003419E3 // 1.59kHz
|
||||
#define AD5934_FREQ_0HZ 0x00000000 // 0Hz
|
||||
#define AD5934_STEP_FREQ_0 0x0000 // 0 passos
|
||||
#define AD5934_SETTLING_TIME_0S01 0x000C // 0,01s
|
||||
//#define AD5934_SETTLING_TIME_0S01 0x000C // 0,01s
|
||||
#define AD5934_SETTLING_TIME_0S01 0x0080
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Command Codes **********************************/
|
||||
@@ -122,7 +126,7 @@ extern "C" {
|
||||
#define AD5934_CH_EC_10MS 0x21
|
||||
#define AD5934_CH_EC_5MS 0x22
|
||||
*/
|
||||
|
||||
/*
|
||||
#define AD5934_CH_REF100R_LOW_GAIN 0x09
|
||||
#define AD5934_CH_REF100R_MID_GAIN 0x0A
|
||||
#define AD5934_CH_REF100R_HIGH_GAIN 0x0C
|
||||
@@ -138,7 +142,7 @@ extern "C" {
|
||||
#define AD5934_CH_EC_LOW_GAIN 0x81
|
||||
#define AD5934_CH_EC_MID_GAIN 0x82
|
||||
#define AD5934_CH_EC_HIGH_GAIN 0x84
|
||||
|
||||
*/
|
||||
#define AD5934_LOW_GAIN_BASE 0x01
|
||||
#define AD5934_MID_GAIN_BASE 0x02
|
||||
#define AD5934_HIGH_GAIN_BASE 0x04
|
||||
@@ -161,9 +165,11 @@ extern "C" {
|
||||
#define AD5934_RTD_A 3.9083e-3f
|
||||
#define AD5934_RTD_B (-5.775e-7f)
|
||||
|
||||
#define AD5934_TEMP_AVERAGES 8
|
||||
#define AD5934_EC_AVERAGES 8
|
||||
#define AD5934_TEMP_AVERAGES 16
|
||||
#define AD5934_EC_AVERAGES 16
|
||||
|
||||
#define AD5934_EC_ALPHA_PER_C 0.02f
|
||||
#define AD5934_EC_TEMP_REF_C 25.0f
|
||||
|
||||
union Bytes2Int
|
||||
{
|
||||
@@ -183,13 +189,59 @@ union Short2Long
|
||||
uint32_t number;
|
||||
};
|
||||
|
||||
extern int16_t temperature_dut_samples[AD5934_TEMP_AVERAGES][2];
|
||||
extern int16_t temperature_ref_samples[AD5934_TEMP_AVERAGES][2];
|
||||
typedef enum {
|
||||
AD5934_CH_REF100R_LOW_GAIN = 0,
|
||||
AD5934_CH_REF100R_MID_GAIN,
|
||||
AD5934_CH_REF100R_HIGH_GAIN,
|
||||
|
||||
AD5934_CH_REF1K_LOW_GAIN,
|
||||
AD5934_CH_REF1K_MID_GAIN,
|
||||
AD5934_CH_REF1K_HIGH_GAIN,
|
||||
|
||||
AD5934_CH_REF10K_LOW_GAIN,
|
||||
AD5934_CH_REF10K_MID_GAIN,
|
||||
AD5934_CH_REF10K_HIGH_GAIN,
|
||||
|
||||
AD5934_CH_RTD_LOW_GAIN,
|
||||
AD5934_CH_RTD_MID_GAIN,
|
||||
AD5934_CH_RTD_HIGH_GAIN,
|
||||
|
||||
AD5934_CH_EC_LOW_GAIN,
|
||||
AD5934_CH_EC_MID_GAIN,
|
||||
AD5934_CH_EC_HIGH_GAIN,
|
||||
|
||||
AD5934_CH_MAX // Guarda automaticamente o número total de canais (15)
|
||||
} AD5934_Channel_t;
|
||||
|
||||
static const uint8_t ADG715_Channel_Map[AD5934_CH_MAX] = {
|
||||
[AD5934_CH_REF100R_LOW_GAIN] = (ADG715_SW1 | ADG715_SW4),
|
||||
[AD5934_CH_REF100R_MID_GAIN] = (ADG715_SW2 | ADG715_SW4),
|
||||
[AD5934_CH_REF100R_HIGH_GAIN] = (ADG715_SW3 | ADG715_SW4),
|
||||
|
||||
[AD5934_CH_REF1K_LOW_GAIN] = (ADG715_SW1 | ADG715_SW5),
|
||||
[AD5934_CH_REF1K_MID_GAIN] = (ADG715_SW2 | ADG715_SW5),
|
||||
[AD5934_CH_REF1K_HIGH_GAIN] = (ADG715_SW3 | ADG715_SW5),
|
||||
|
||||
[AD5934_CH_REF10K_LOW_GAIN] = (ADG715_SW1 | ADG715_SW6),
|
||||
[AD5934_CH_REF10K_MID_GAIN] = (ADG715_SW2 | ADG715_SW6),
|
||||
[AD5934_CH_REF10K_HIGH_GAIN] = (ADG715_SW3 | ADG715_SW6),
|
||||
|
||||
[AD5934_CH_RTD_LOW_GAIN] = (ADG715_SW1 | ADG715_SW7),
|
||||
[AD5934_CH_RTD_MID_GAIN] = (ADG715_SW2 | ADG715_SW7),
|
||||
[AD5934_CH_RTD_HIGH_GAIN] = (ADG715_SW3 | ADG715_SW7),
|
||||
|
||||
[AD5934_CH_EC_LOW_GAIN] = (ADG715_SW1 | ADG715_SW8),
|
||||
[AD5934_CH_EC_MID_GAIN] = (ADG715_SW2 | ADG715_SW8),
|
||||
[AD5934_CH_EC_HIGH_GAIN] = (ADG715_SW3 | ADG715_SW8)
|
||||
};
|
||||
|
||||
extern int16_t temperature_dut_samples[2][AD5934_TEMP_AVERAGES];
|
||||
extern int16_t temperature_ref_samples[2][AD5934_TEMP_AVERAGES];
|
||||
extern float temperature_display[AD5934_TEMP_AVERAGES];
|
||||
|
||||
extern int16_t ec_dut_samples[AD5934_EC_AVERAGES][2];
|
||||
extern int16_t ec_ref1_samples[AD5934_EC_AVERAGES][2];
|
||||
extern int16_t ec_ref2_samples[AD5934_EC_AVERAGES][2];
|
||||
extern int16_t ec_dut_samples[2][AD5934_EC_AVERAGES];
|
||||
extern int16_t ec_ref1_samples[2][AD5934_EC_AVERAGES];
|
||||
extern int16_t ec_ref2_samples[2][AD5934_EC_AVERAGES];
|
||||
extern float ec_display[AD5934_EC_AVERAGES];
|
||||
extern float ec_temp_dut[AD5934_EC_AVERAGES];
|
||||
|
||||
@@ -211,7 +263,9 @@ uint32_t AD5934_Sweep(void);
|
||||
|
||||
void AD5934_RestartSweep(void);
|
||||
|
||||
float AD5934_GetTemperature(void);
|
||||
float AD5934_Get_Ref_Resistance(void);
|
||||
|
||||
float AD5934_GetTemperature(float mag_ref);
|
||||
|
||||
float AD5934_GetImpedance(float temperature_dut);
|
||||
|
||||
@@ -221,7 +275,9 @@ float AD5934_Round_Float_Precision(float value, uint8_t number_of_decimals);
|
||||
|
||||
float AD5934_Linear_Correction(float raw_value);
|
||||
|
||||
float AD5934_Get_Target_Conductivity(float temp);
|
||||
float AD5934_EC_Compensate_To_25C(float ec_raw_uScm, float temp_C);
|
||||
|
||||
float AD5934_EC_Calibrate_Temperature(float temp_C);
|
||||
|
||||
void ADG715_SetRegisterValue(char value);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define INC_ADS1015_DRIVER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "main.h" // Assuming HAL is included via main.h
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "flash_manager.h"
|
||||
@@ -125,9 +126,9 @@ extern "C" {
|
||||
|
||||
#define ADS1015_KELVIN_OFFSET 273.15f // Constante de conversão Kelvin
|
||||
#define ADS1015_ADC_MAX 4095.0f
|
||||
#define ADS1015_ADC_VREF 3.3f
|
||||
#define ADS1015_ADC_VREF 1024.0f //1.024V in mV
|
||||
#define PH_DELTA_CALIB 3.0f // Difference between pH 7 and pH 4 used in calibration
|
||||
#define ADS1015_PH_AVERAGES 8
|
||||
#define ADS1015_PH_AVERAGES 16
|
||||
|
||||
#define ADS1015_TEMPERATURE_ROW 0
|
||||
#define ADS1015_PH_4_BUFFER_ROW 1
|
||||
@@ -149,7 +150,7 @@ typedef enum {
|
||||
|
||||
|
||||
|
||||
extern float ph_averages[ADS1015_PH_AVERAGES];
|
||||
extern float ph_dut_samples[ADS1015_PH_AVERAGES];
|
||||
|
||||
|
||||
|
||||
@@ -171,9 +172,10 @@ void ADSstartComparator_SingleEnded(ADS1015_I2C* i2c, uint8_t channel, int16_t
|
||||
int16_t ADSgetLastConversionResults();
|
||||
void ADSsetGain(ADS1015_I2C* i2c, adsGain_t gain);
|
||||
adsGain_t ADSgetGain(ADS1015_I2C* i2c);
|
||||
float ADSCalculate_ph_Volts(void);
|
||||
float ADSCalculate_ph_mV(void);
|
||||
float ADSCalculate_ph_Compensated(float temp_dut);
|
||||
float ADSCalculate_ph_Uncompensated(void);
|
||||
float ADSinterpolate_ph(float temp_dut, uint8_t row_index);
|
||||
float ADSRound_Float_Precision(float value, uint8_t number_of_decimals);
|
||||
|
||||
#endif /* INC_ADS1015_DRIVER_H_ */
|
||||
|
||||
@@ -27,14 +27,17 @@
|
||||
typedef struct __attribute__((packed, aligned(4)))
|
||||
{
|
||||
uint32_t magic_number; // 4 bytes (Validação)
|
||||
float ph4_volts; // 4 bytes
|
||||
float ph7_volts; // 4 bytes
|
||||
float ph4_mV; // 4 bytes
|
||||
float ph7_mV; // 4 bytes
|
||||
float ph_temperature; // 4 bytes
|
||||
float ph_slope_mV; // 4 bytes
|
||||
float ph7_real; // 4 bytes
|
||||
float ec1413_mag; // 4 bytes
|
||||
float ec0_mag; // 4 bytes
|
||||
float temperature_value; // 4 bytes
|
||||
float ec_factor; // 4 bytes
|
||||
uint8_t PT100_PT1000_switch; // 1 byte
|
||||
uint8_t EC10mS_EC5mS_switch; // 1 byte
|
||||
uint8_t reserved[998]; // Preenchimento para completar 1024 bytes (1KB)
|
||||
uint8_t reserved[986]; // Preenchimento para completar 1024 bytes (1KB)
|
||||
} FlashPage_t;
|
||||
|
||||
extern FlashPage_t flash_data;
|
||||
|
||||
@@ -127,12 +127,13 @@ void Error_Handler(void);
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
#define STATE_RUNNING_OK 0x00
|
||||
#define STATE_SETUP_CALIBRATION 0x01
|
||||
#define STATE_RS485_SUPPLY_FAULT 0x02
|
||||
#define STATE_PH_SUPPLY_FAULT 0x03
|
||||
#define STATE_EC_RTD_SUPPLY_FAULT 0x04
|
||||
#define STATE_NO_SETUP_CALIBRATION 0x05
|
||||
#define STATE_HIGH_AMBIENT_TEMPERATURE 0x06
|
||||
#define STATE_NO_SETUP_CALIBRATION 0x01
|
||||
#define STATE_PH4_DRY_EC_CALIBRATION 0x02
|
||||
#define STATE_PH7_WET_EC_CALIBRATION 0x03
|
||||
#define STATE_RS485_SUPPLY_FAULT 0x04
|
||||
#define STATE_PH_SUPPLY_FAULT 0x05
|
||||
#define STATE_EC_RTD_SUPPLY_FAULT 0x06
|
||||
#define STATE_HIGH_AMBIENT_TEMPERATURE 0x07
|
||||
|
||||
extern uint8_t main_state;
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
Reference in New Issue
Block a user