mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_WindVane: check for valid analog pins
This commit is contained in:
parent
e5ae023be2
commit
f50326c154
@ -26,7 +26,10 @@ AP_WindVane_Analog::AP_WindVane_Analog(AP_WindVane &frontend) :
|
||||
|
||||
void AP_WindVane_Analog::update_direction()
|
||||
{
|
||||
_dir_analog_source->set_pin(_frontend._dir_analog_pin);
|
||||
if (!_dir_analog_source->set_pin(_frontend._dir_analog_pin)) {
|
||||
// pin invalid, don't have health monitoring to report yet
|
||||
return;
|
||||
}
|
||||
_current_analog_voltage = _dir_analog_source->voltage_latest();
|
||||
|
||||
const float voltage_ratio = linear_interpolate(0.0f, 1.0f, _current_analog_voltage, _frontend._dir_analog_volt_min, _frontend._dir_analog_volt_max);
|
||||
|
@ -32,14 +32,20 @@ void AP_WindVane_ModernDevice::update_speed()
|
||||
// only read temp pin if defined, sensor will do OK assuming constant temp
|
||||
float temp_ambient = 28.0f; // equations were generated at this temp in above data sheet
|
||||
if (is_positive(_frontend._speed_sensor_temp_pin.get())) {
|
||||
_temp_analog_source->set_pin(_frontend._speed_sensor_temp_pin.get());
|
||||
if (!_temp_analog_source->set_pin(_frontend._speed_sensor_temp_pin.get())) {
|
||||
// pin invalid, don't have health monitoring to report yet
|
||||
return;
|
||||
}
|
||||
analog_voltage = _temp_analog_source->voltage_average();
|
||||
temp_ambient = (analog_voltage - 0.4f) / 0.0195f; // deg C
|
||||
// constrain to reasonable range to avoid deviating from calibration too much and potential divide by zero
|
||||
temp_ambient = constrain_float(temp_ambient, 10.0f, 40.0f);
|
||||
}
|
||||
|
||||
_speed_analog_source->set_pin(_frontend._speed_sensor_speed_pin.get());
|
||||
if (!_speed_analog_source->set_pin(_frontend._speed_sensor_speed_pin.get())) {
|
||||
// pin invalid, don't have health monitoring to report yet
|
||||
return;
|
||||
}
|
||||
_current_analog_voltage = _speed_analog_source->voltage_average();
|
||||
|
||||
// apply voltage offset and make sure not negative
|
||||
|
Loading…
Reference in New Issue
Block a user