Skip to content

Commit d3398ac

Browse files
Merge pull request #51 from larus-breeze/refresh_settings_from_EEPROM
Elaborate reset of all EEPROM parameters.
2 parents 038c962 + 9479558 commit d3398ac

File tree

12 files changed

+108
-33
lines changed

12 files changed

+108
-33
lines changed

Generic_Algorithms/pt2.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ template <class datatype, class basetype> class pt2
4848
old( datatype()),
4949
very_old( datatype())
5050
{
51-
basetype delta = SIN( M_PI * (DESIGN_FREQUENCY - fcutoff)) / SIN( M_PI * (fcutoff + DESIGN_FREQUENCY));
51+
tune( fcutoff);
52+
}
53+
void tune( basetype f_cutoff)
54+
{
55+
basetype delta = SIN( M_PI * (DESIGN_FREQUENCY - f_cutoff)) / SIN( M_PI * (f_cutoff + DESIGN_FREQUENCY));
5256
basetype a0x = A2 * SQR(delta) - A1 + ONE;
5357
basetype a1x = -2.0 * delta * A2 + (SQR(delta) + ONE) * A1 - 2.0 * delta;
5458
basetype a2x = A2 - delta * A1 + SQR(delta);

NAV_Algorithms/AHRS.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ AHRS_type::AHRS_type (float sampling_time)
166166
compass_calibration.set_default();
167167
}
168168

169+
void AHRS_type::tune( void)
170+
{
171+
antenna_DOWN_correction = configuration( ANT_SLAVE_DOWN) / configuration( ANT_BASELENGTH);
172+
antenna_RIGHT_correction = configuration( ANT_SLAVE_RIGHT) / configuration( ANT_BASELENGTH);
173+
automatic_magnetic_calibration = (magnetic_calibration_type)(round)(configuration(MAG_AUTO_CALIB));
174+
}
175+
169176
void
170177
AHRS_type::update (const float3vector &gyro,
171178
const float3vector &acc,

NAV_Algorithms/AHRS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class AHRS_type
5353
AHRS_type(float sampling_time);
5454
void attitude_setup( const float3vector & acceleration, const float3vector & induction);
5555

56+
void tune( void);
57+
5658
void update_magnetic_induction_data( float declination, float inclination)
5759
{
5860
declination *= (M_PI_F / 180.0f); // degrees to radiant

NAV_Algorithms/navigator.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void navigator_t::update_at_100Hz (
4747

4848
wind_observer.process_at_100_Hz( GNSS_velocity - heading_vector * TAS);
4949

50-
flight_observer.update_at_100Hz (
50+
variometer.update_at_100Hz (
5151
GNSS_velocity,
5252
ahrs.get_nav_acceleration (),
5353
heading_vector,
@@ -90,12 +90,12 @@ bool navigator_t::update_at_10Hz ()
9090

9191
wind_observer.process_at_10_Hz( ahrs);
9292

93-
vario_integrator.update (flight_observer.get_vario_GNSS(), // here because of the update rate 10Hz
93+
vario_integrator.update (variometer.get_vario_GNSS(), // here because of the update rate 10Hz
9494
ahrs.get_euler ().yaw,
9595
ahrs.get_circling_state ());
9696

9797
unsigned airborne_criteria_fulfilled = 0;
98-
if( abs( flight_observer.get_speed_compensation_GNSS()) > AIRBORNE_TRIGGER_SPEED_COMP)
98+
if( abs( variometer.get_speed_compensation_GNSS()) > AIRBORNE_TRIGGER_SPEED_COMP)
9999
++ airborne_criteria_fulfilled;
100100

101101
if( GNSS_velocity.abs() > AIRBORNE_TRIGGER_SPEED)
@@ -115,7 +115,7 @@ bool navigator_t::update_at_10Hz ()
115115
if( airborne_detector.is_airborne())
116116
atmosphere.air_density_metering(
117117
air_pressure_resampler_100Hz_10Hz.get_output(),
118-
flight_observer.get_filtered_GNSS_altitude());
118+
variometer.get_filtered_GNSS_altitude());
119119

120120

121121
return landing_detected;
@@ -130,18 +130,18 @@ void navigator_t::report_data( output_data_t &d)
130130
d.euler = ahrs.get_euler();
131131
d.q = ahrs.get_attitude();
132132

133-
d.vario = flight_observer.get_vario_GNSS(); // todo pick one vario
134-
d.vario_pressure = flight_observer.get_vario_pressure();
133+
d.vario = variometer.get_vario_GNSS(); // todo pick one vario
134+
d.vario_pressure = variometer.get_vario_pressure();
135135
d.integrator_vario = vario_integrator.get_output();
136-
d.vario_uncompensated = flight_observer.get_vario_uncompensated_GNSS();
136+
d.vario_uncompensated = variometer.get_vario_uncompensated_GNSS();
137137

138138
d.wind = wind_observer.get_instant_value();
139139
d.wind_average = wind_observer.get_average_value();
140140

141-
d.speed_compensation_TAS = flight_observer.get_speed_compensation_IAS();
142-
d.speed_compensation_GNSS = flight_observer.get_speed_compensation_GNSS();
141+
d.speed_compensation_TAS = variometer.get_speed_compensation_IAS();
142+
d.speed_compensation_GNSS = variometer.get_speed_compensation_GNSS();
143143
d.effective_vertical_acceleration
144-
= flight_observer.get_effective_vertical_acceleration();
144+
= variometer.get_effective_vertical_acceleration();
145145

146146
d.circle_mode = ahrs.get_circling_state();
147147
d.turn_rate = ahrs.get_turn_rate();
@@ -174,7 +174,7 @@ void navigator_t::report_data( output_data_t &d)
174174
d.inst_wind_corrected_N = wind_observer.get_corrected_wind()[NORTH];
175175
d.inst_wind_corrected_E = wind_observer.get_corrected_wind()[EAST];
176176
for( unsigned i=0; i<3; ++i)
177-
d.speed_compensation[i] = flight_observer.get_speed_compensation(i);
177+
d.speed_compensation[i] = variometer.get_speed_compensation(i);
178178
d.cross_acc_correction = ahrs_magnetic.get_cross_acc_correction();
179179
d.vario_wind_N = wind_observer.get_speed_compensator_wind()[NORTH];
180180
d.vario_wind_E = wind_observer.get_speed_compensator_wind()[EAST];

NAV_Algorithms/navigator.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class navigator_t
4747
ahrs_magnetic (0.01f),
4848
#endif
4949
atmosphere (101325.0f),
50-
flight_observer(),
50+
variometer(),
5151
wind_observer(),
5252
airborne_detector(),
5353
air_pressure_resampler_100Hz_10Hz(0.025f), // = 2.5 Hz @ 100Hz
@@ -67,6 +67,19 @@ class navigator_t
6767
IAS_averager(1.0f / 1.0f / 100.0f)
6868
{};
6969

70+
void tune(void)
71+
{
72+
variometer.tune();
73+
vario_integrator.tune( configuration( VARIO_INT_TC) < 0.25f
74+
? configuration( VARIO_INT_TC) // normalized stop frequency given, old version
75+
: (FAST_SAMPLING_TIME / configuration( VARIO_INT_TC) ) ); // time-constant given, new version
76+
wind_observer.tune();
77+
ahrs.tune();
78+
#if DEVELOPMENT_ADDITIONS
79+
ahrs_magnetic.tune();
80+
#endif
81+
}
82+
7083
void update_magnetic_induction_data( float declination, float inclination)
7184
{
7285
ahrs.update_magnetic_induction_data( declination, inclination);
@@ -118,7 +131,7 @@ class navigator_t
118131

119132
void reset_altitude( void)
120133
{
121-
flight_observer.reset( atmosphere.get_negative_pressure_altitude(), GNSS_negative_altitude);
134+
variometer.reset( atmosphere.get_negative_pressure_altitude(), GNSS_negative_altitude);
122135
}
123136
/**
124137
* @brief update pitot pressure
@@ -186,18 +199,13 @@ class navigator_t
186199
#endif
187200
}
188201

189-
float get_IAS( void) const
190-
{
191-
return IAS;
192-
}
193-
194202
private:
195203
AHRS_type ahrs;
196204
#if DEVELOPMENT_ADDITIONS
197205
AHRS_type ahrs_magnetic;
198206
#endif
199-
atmosphere_t atmosphere;
200-
variometer_t flight_observer;
207+
atmosphere_t atmosphere;
208+
variometer_t variometer;
201209
wind_oberserver_t wind_observer;
202210
airborne_detector_t airborne_detector;
203211

NAV_Algorithms/organizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class organizer_t
9999
configuration (SENS_TILT_PITCH),
100100
configuration (SENS_TILT_YAW));
101101
q.get_rotation_matrix (sensor_mapping);
102+
103+
navigator.tune();
102104
}
103105

104106
void update_magnetic_induction_data( double latitude, double longitude)

NAV_Algorithms/persistent_data.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ ROM persistent_data_t PERSISTENT_DATA[]=
6161

6262
ROM unsigned PERSISTENT_DATA_ENTRIES = sizeof(PERSISTENT_DATA) / sizeof(persistent_data_t);
6363

64+
bool all_EEPROM_parameters_available( void)
65+
{
66+
float dummy;
67+
for( const persistent_data_t * parameter = PERSISTENT_DATA;
68+
parameter < PERSISTENT_DATA + PERSISTENT_DATA_ENTRIES;
69+
++parameter)
70+
{
71+
if( true == read_EEPROM_value( parameter->id, dummy)) // parameter missing
72+
return false;
73+
}
74+
return true;
75+
}
76+
6477
void ensure_EEPROM_parameter_integrity( void)
6578
{
6679
bool EEPROM_has_been_unlocked = false;

NAV_Algorithms/soaring_flight_averager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ template<class value_t, bool CLAMP_OUTPUT_FIRST_CIRCLE = false, bool SOFT_TAKEOF
5151
}
5252
};
5353

54+
void tune( float normalized_stop_frequency)
55+
{
56+
averager.tune( normalized_stop_frequency);
57+
}
58+
5459
const value_t & get_output (void) const
5560
{
5661
return present_output;

NAV_Algorithms/variometer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************************//**
2-
* @file flight_observer.cpp
2+
* @file variometer.cpp
33
* @brief maintains important derived data for gliders
44
* @author Dr. Klaus Schaefer
55
* @copyright Copyright 2021 Dr. Klaus Schaefer. All rights reserved.
@@ -29,7 +29,7 @@
2929
#define ONE_DIV_BY_GRAVITY_TIMES_2 0.0509684f
3030
#define RECIP_GRAVITY 0.1094f
3131

32-
//! calculate instant windspeed and variometer data, update @ 100 Hz
32+
//! calculate variometer data, update @ 100 Hz
3333
void variometer_t::update_at_100Hz (
3434
const float3vector &gnss_velocity,
3535
const float3vector &ahrs_acceleration,

NAV_Algorithms/variometer.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************************//**
2-
* @file flight_observer.h
2+
* @file variometer.h
33
* @brief maintains important derived data for gliders
44
* @author Dr. Klaus Schaefer
55
* @copyright Copyright 2021 Dr. Klaus Schaefer. All rights reserved.
@@ -73,6 +73,13 @@ class variometer_t
7373
speed_compensation_projected_4(0.0f)
7474
{
7575
};
76+
77+
void tune( void)
78+
{
79+
vario_averager_pressure.tune( FAST_SAMPLING_TIME / configuration( VARIO_TC));
80+
vario_averager_GNSS.tune( FAST_SAMPLING_TIME / configuration( VARIO_TC));
81+
}
82+
7683
void update_at_100Hz
7784
(
7885
const float3vector &gnss_velocity,

0 commit comments

Comments
 (0)