45 #include <mathlib/mathlib.h> 49 float max_start_temperature)
79 bool finished = data.hot_soaked;
85 return finished ? 0 : 1;
98 data.sensor_sample_filt[0] = 100.0f * baro_data.
pressure;
107 if (!data.cold_soaked) {
115 data.cold_soaked =
true;
116 data.low_temp = data.sensor_sample_filt[1];
117 data.high_temp = data.low_temp;
128 if (data.sensor_sample_filt[1] > data.high_temp) {
129 data.high_temp = data.sensor_sample_filt[1];
130 data.hot_soak_sat = 0;
138 data.hot_soaked =
true;
142 TC_DEBUG(
"\nBaro: %.20f,%.20f,%.20f,%.20f, %.6f, %.6f, %.6f\n\n", (
double)data.sensor_sample_filt[0],
143 (
double)data.sensor_sample_filt[1], (
double)data.low_temp, (
double)data.high_temp,
144 (
double)(data.high_temp - data.low_temp));
148 double relative_temperature = (double)data.sensor_sample_filt[1] - (
double)data.ref_temp;
149 data.P[0].update(relative_temperature, (
double)data.sensor_sample_filt[0]);
163 if (result != PX4_OK) {
164 PX4_ERR(
"unable to reset TC_B_ENABLE (%i)", result);
172 if (!data.hot_soaked || data.tempcal_complete) {
180 PX4_INFO(
"Result baro %u %.20f %.20f %.20f %.20f %.20f %.20f", sensor_index, (
double)res[0],
181 (
double)res[1], (
double)res[2], (
double)res[3], (
double)res[4], (
double)res[5]);
182 data.tempcal_complete =
true;
190 for (
unsigned coef_index = 0; coef_index <=
POLYFIT_ORDER; coef_index++) {
191 sprintf(str,
"TC_B%d_X%d", sensor_index, (
POLYFIT_ORDER - coef_index));
192 param = (float)res[coef_index];
195 if (result != PX4_OK) {
196 PX4_ERR(
"unable to reset %s", str);
int _sensor_subs[SENSOR_COUNT_MAX]
virtual ~TemperatureCalibrationBaro()
int orb_copy(const struct orb_metadata *meta, int handle, void *buffer)
TemperatureCalibrationBaro(float min_temperature_rise, float min_start_temperature, float max_start_temperature)
__EXPORT int param_set_no_notification(param_t param, const void *val)
Set the value of a parameter, but do not notify the system about the change.
float _min_temperature_rise
minimum difference in temperature before the process finishes
#define TC_ERROR_INITIAL_TEMP_TOO_HIGH
starting temperature was above the configured allowed temperature
class TemperatureCalibrationCommon Common base class for all sensor types, contains shared code & dat...
unsigned _num_sensor_instances
High-resolution timer with callouts and timekeeping.
int set_parameter(const char *format_str, unsigned index, const void *value)
set a system parameter (without system notification) and print an error if it fails ...
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
virtual int update_sensor_instance(PerSensorData &data, int sensor_sub)
update a single sensor instance
int orb_unsubscribe(int handle)
int finish_sensor_instance(PerSensorData &data, int sensor_index)
int orb_group_count(const struct orb_metadata *meta)
Get the number of published instances of a topic group.
__EXPORT param_t param_find(const char *name)
Look up a parameter by name.
int orb_check(int handle, bool *updated)
int orb_subscribe_multi(const struct orb_metadata *meta, unsigned instance)
float _max_start_temperature
maximum temperature above which the process does not start and an error is declared ...
float _min_start_temperature
minimum temperature before the process starts
#define TC_DEBUG(fmt,...)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
PerSensorData _data[SENSOR_COUNT_MAX]