Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: platform_drivers AD7124_no_OS adi_console_menu tempsensors_prv
Revision 8:3d7b5897b028, committed 2021-03-24
- Comitter:
- mahphalke
- Date:
- Wed Mar 24 19:48:08 2021 +0530
- Parent:
- 7:ef6fffc246a6
- Commit message:
- Displaying iout average values
Changed in this revision
| app/ad7124_console_app.c | Show annotated file Show diff for this revision Revisions of this file |
diff -r ef6fffc246a6 -r 3d7b5897b028 app/ad7124_console_app.c
--- a/app/ad7124_console_app.c Wed Mar 24 12:33:55 2021 +0530
+++ b/app/ad7124_console_app.c Wed Mar 24 19:48:08 2021 +0530
@@ -141,8 +141,8 @@
static int32_t n_sample_data[NUM_OF_SENSOR_CHANNELS][MAX_ADC_SAMPLES];
/* RTD calibraed IOUT values for n samples */
-static float rtd_calib_iout0[MAX_RTD_SENSORS][MAX_ADC_SAMPLES];
-static float rtd_calib_iout1[MAX_RTD_SENSORS][MAX_ADC_SAMPLES];
+//static float rtd_calib_iout0[MAX_RTD_SENSORS][MAX_ADC_SAMPLES];
+//static float rtd_calib_iout1[MAX_RTD_SENSORS][MAX_ADC_SAMPLES];
/* CJC sensor ADC raw data for n samples */
static int32_t n_cjc_sample_data[MAX_THERMOCOUPLE_SENSORS][MAX_ADC_SAMPLES];
@@ -731,6 +731,8 @@
static int32_t calibrate_and_measure_3wire_rtd(uint32_t measurement_type)
{
int32_t sample_data[2][MAX_ADC_SAMPLES];
+ float rtd_calib_iout0_avg[MAX_RTD_SENSORS];
+ float rtd_calib_iout1_avg[MAX_RTD_SENSORS];
bool adc_error = false;
float temperature;
float voltage;
@@ -819,7 +821,8 @@
RTD_3WIRE_REF_MEASUREMENT_CHN, n_sample_data[RTD_3WIRE_REF_MEASUREMENT_CHN][0]);
/* Calculate equivalent Iout0 current flowing through Rref resistance */
- rtd_calib_iout0[chn][0] = voltage / get_rtd_rref();
+ //rtd_calib_iout0[chn][0] = voltage / get_rtd_rref();
+ rtd_calib_iout0_avg[chn] = voltage / get_rtd_rref();
} else {
for (sample_cnt = 0; sample_cnt < MAX_ADC_SAMPLES; sample_cnt++) {
/* Get the equivalent ADC voltage */
@@ -828,8 +831,11 @@
n_sample_data[RTD_3WIRE_REF_MEASUREMENT_CHN][sample_cnt]);
/* Calculate equivalent Iout0 current flowing through Rref resistance */
- rtd_calib_iout0[chn][sample_cnt] = voltage / get_rtd_rref();
+ //rtd_calib_iout0[chn][sample_cnt] = voltage / get_rtd_rref();
+ rtd_calib_iout0_avg[chn] += voltage / get_rtd_rref();
}
+
+ rtd_calib_iout0_avg[chn] /= MAX_ADC_SAMPLES;
}
/* Turn off the Iout0 excitation current */
@@ -862,7 +868,8 @@
n_sample_data[RTD_3WIRE_REF_MEASUREMENT_CHN][0]);
/* Calculate equivalent Iout1 current flowing through Rref resistance */
- rtd_calib_iout1[chn][0] = voltage / get_rtd_rref();
+ //rtd_calib_iout1[chn][0] = voltage / get_rtd_rref();
+ rtd_calib_iout1_avg[chn] = voltage / get_rtd_rref();
} else {
for (sample_cnt = 0; sample_cnt < MAX_ADC_SAMPLES; sample_cnt++) {
/* Get the equivalent ADC voltage */
@@ -871,9 +878,16 @@
n_sample_data[RTD_3WIRE_REF_MEASUREMENT_CHN][sample_cnt]);
/* Calculate equivalent Iout1 current flowing through Rref resistance */
- rtd_calib_iout1[chn][sample_cnt] = voltage / get_rtd_rref();
+ //rtd_calib_iout1[chn][sample_cnt] = voltage / get_rtd_rref();
+ rtd_calib_iout1_avg[chn] += voltage / get_rtd_rref();
}
+
+ rtd_calib_iout1_avg[chn] /= MAX_ADC_SAMPLES;
}
+
+ // for testing
+ printf("Iout_avg (RTD%d): %f" EOL, chn +1, rtd_calib_iout1_avg[chn] /
+ rtd_calib_iout0_avg[chn]);
/* Turn off the Iout1 excitation current */
ad7124_register_map[AD7124_IOCon1].value &= ((~AD7124_IO_CTRL1_REG_IOUT1_MSK)
@@ -983,8 +997,11 @@
chn++) {
if (sensor_enable_status[chn]) {
if (rtd_3wire_calibration_type == MEASURING_EXCITATION_CURRENT) {
- store_rtd_calibrated_iout_ratio((rtd_calib_iout1[chn][0] /
- rtd_calib_iout0[chn][0]), true);
+ //store_rtd_calibrated_iout_ratio((rtd_calib_iout1[chn][0] /
+ // rtd_calib_iout0[chn][0]), true);
+
+ store_rtd_calibrated_iout_ratio((rtd_calib_iout1_avg[chn] /
+ rtd_calib_iout0_avg[chn]), true);
}
temperature = get_rtd_temperature(n_sample_data[chn][0], MULTI_3WIRE_RTD_GAIN);
@@ -992,9 +1009,9 @@
strcat(decimal_eqv_str_arr, decimal_eqv_str);
// for testing
- sprintf(decimal_eqv_str, "%.4f ", rtd_calib_iout1[chn][0] /
- rtd_calib_iout0[chn][0]);
- strcat(decimal_eqv_str_arr, decimal_eqv_str);
+ //sprintf(decimal_eqv_str, "%.4f ", rtd_calib_iout1[chn][0] /
+ // rtd_calib_iout0[chn][0]);
+ //strcat(decimal_eqv_str_arr, decimal_eqv_str);
}
}
printf("\t%s" EOL EOL, decimal_eqv_str_arr);
@@ -1006,8 +1023,11 @@
chn++) {
if (sensor_enable_status[chn]) {
if (rtd_3wire_calibration_type == MEASURING_EXCITATION_CURRENT) {
- store_rtd_calibrated_iout_ratio((rtd_calib_iout1[chn][sample_cnt] /
- rtd_calib_iout0[chn][sample_cnt]), true);
+ //store_rtd_calibrated_iout_ratio((rtd_calib_iout1[chn][sample_cnt] /
+ // rtd_calib_iout0[chn][sample_cnt]), true);
+
+ store_rtd_calibrated_iout_ratio((rtd_calib_iout1_avg[chn] /
+ rtd_calib_iout0_avg[chn]), true);
}
temperature = get_rtd_temperature(n_sample_data[chn][sample_cnt],
@@ -1016,9 +1036,9 @@
strcat(decimal_eqv_str_arr, decimal_eqv_str);
// for testing
- sprintf(decimal_eqv_str, "%.4f ", rtd_calib_iout1[chn][sample_cnt] /
- rtd_calib_iout0[chn][sample_cnt]);
- strcat(decimal_eqv_str_arr, decimal_eqv_str);
+ //sprintf(decimal_eqv_str, "%.4f ", rtd_calib_iout1[chn][sample_cnt] /
+ // rtd_calib_iout0[chn][sample_cnt]);
+ //strcat(decimal_eqv_str_arr, decimal_eqv_str);
}
}
printf("\t%s" EOL EOL, decimal_eqv_str_arr);