summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormjc <mjc@avtechpulse.com>2000-01-01 00:01:01 +0900
committermjc <mjc@avtechpulse.com>2000-01-01 00:01:01 +0900
commit21423c3785df243d03cde5bc7817445f95e8fba1 (patch)
treec8cfec7b59f99ea52f54fbde696ee4ae6283cbc8
parent4dc26232f303ff91955ed5656da5bae6d8978242 (diff)
make self-cal min count configurable
-rw-r--r--device-functions.c26
-rw-r--r--flash.c1
-rw-r--r--globals.h4
3 files changed, 26 insertions, 5 deletions
diff --git a/device-functions.c b/device-functions.c
index 9f3a086..b6df2af 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -65,11 +65,27 @@ static float get_bounded_float (float val_in, float default_val)
{
// limits returned value within +/- 1 order of magnitude
- if (val_in > 10.0 * default_val) {
+ if (val_in > (10.0 * default_val)) {
return default_val;
}
- if (val_in < default_val / 10.0) {
+ if (val_in < (default_val / 10.0)) {
+ return default_val;
+ }
+
+ return val_in;
+}
+
+
+static int get_bounded_int (int val_in, int default_val)
+{
+ // limits returned value within +/- 1 order of magnitude
+
+ if (val_in > (10 * default_val)) {
+ return default_val;
+ }
+
+ if (val_in < (default_val / 10)) {
return default_val;
}
@@ -81,7 +97,7 @@ static float get_float_with_min (float val_in, float default_val)
{
// limits returned value within +2 / -0 order of magnitude
- if (val_in > 100.0 * default_val) {
+ if (val_in > (100.0 * default_val)) {
return default_val;
}
@@ -3916,7 +3932,9 @@ int go_cal(CalStruct *caldata)
caldata->max_change = 0.0;
caldata->avg_change = 0.0;
- min_val = 40e-6;
+ min_val = get_bounded_int (globals.Flash.self_cal_min_count, SELF_CAL_MIN_COUNT) /
+ get_bounded_float (globals.Flash.self_cal_ref_freq, SELF_CAL_REF_FREQ);
+
if (caldata->cal_type == pwl_period_values) {
max_val = 4.0 / globals.Flash.min_freq[caldata->channel];
chk_val = 0.25 / globals.Flash.max_freq[caldata->channel];
diff --git a/flash.c b/flash.c
index 529ce74..ba89401 100644
--- a/flash.c
+++ b/flash.c
@@ -518,6 +518,7 @@ static void initFlashValues(FlashStruct *mem)
mem->prf_limiter=1;
mem->self_cal_ref_freq = SELF_CAL_REF_FREQ;
+ mem->self_cal_min_count = SELF_CAL_MIN_COUNT;
mem->pcb116c_mon=1; /* more recent ADC, different reading code */
mem->warn_even_if_output_off=0;
diff --git a/globals.h b/globals.h
index 147eb7e..a55c4ca 100644
--- a/globals.h
+++ b/globals.h
@@ -231,6 +231,7 @@
// hardware default values
#define DEFAULT_OUTPUT_ON_DELAY 0.8 // needs at least 800 ms, due to soft-on circuit
#define SELF_CAL_REF_FREQ 1e7 // 10 MHz
+#define SELF_CAL_MIN_COUNT 400 // 1 in 400
// menu stuff
#define Main_Menu_On 0
@@ -465,8 +466,9 @@ typedef struct {
char prf_limiter; /* 243 */
float self_cal_ref_freq; /* 244 */
+ short self_cal_min_count; /* 248 */
- char spare_padding[8]; /* 248 - padding between common and per-channel sections of the */
+ char spare_padding[6]; /* 250 - padding between common and per-channel sections of the */
/* flash eeprom. Adjust size if variables added to common section, */
/* so that per-channel section starts at 256 */