Don't use battery temperature to determine fan type (#1331)

* Don't use battery temperature to determine fan type

* Add cloudlog

* Init is_uno
old-commit-hash: 017b1f6770
commatwo_master
Willem Melching 5 years ago committed by GitHub
parent 0d307b16b8
commit 907a97f1ee
  1. 6
      selfdrive/thermald/power_monitoring.py
  2. 28
      selfdrive/thermald/thermald.py

@ -58,12 +58,11 @@ def panda_current_to_actual_current(panda_current):
class PowerMonitoring: class PowerMonitoring:
def __init__(self, is_uno): def __init__(self):
self.last_measurement_time = None # Used for integration delta self.last_measurement_time = None # Used for integration delta
self.power_used_uWh = 0 # Integrated power usage in uWh since going into offroad self.power_used_uWh = 0 # Integrated power usage in uWh since going into offroad
self.next_pulsed_measurement_time = None self.next_pulsed_measurement_time = None
self.integration_lock = threading.Lock() self.integration_lock = threading.Lock()
self.is_uno = is_uno
# Calculation tick # Calculation tick
def calculate(self, health): def calculate(self, health):
@ -90,6 +89,7 @@ class PowerMonitoring:
self.last_measurement_time = now self.last_measurement_time = now
return return
is_uno = health.health.hwType == log.HealthData.HwType.uno
# Get current power draw somehow # Get current power draw somehow
current_power = 0 current_power = 0
if get_battery_status() == 'Discharging': if get_battery_status() == 'Discharging':
@ -132,7 +132,7 @@ class PowerMonitoring:
self.next_pulsed_measurement_time = None self.next_pulsed_measurement_time = None
return return
elif self.next_pulsed_measurement_time is None and not self.is_uno: elif self.next_pulsed_measurement_time is None and not is_uno:
# On a charging EON with black panda, or drawing more than 400mA out of a white/grey one # On a charging EON with black panda, or drawing more than 400mA out of a white/grey one
# Only way to get the power draw is to turn off charging for a few sec and check what the discharging rate is # Only way to get the power draw is to turn off charging for a few sec and check what the discharging rate is
# We shouldn't do this very often, so make sure it has been some long-ish random time interval # We shouldn't do this very often, so make sure it has been some long-ish random time interval

@ -180,16 +180,11 @@ def thermald_thread():
current_connectivity_alert = None current_connectivity_alert = None
time_valid_prev = True time_valid_prev = True
should_start_prev = False should_start_prev = False
handle_fan = None
is_uno = (read_tz(29, clip=False) < -1000) is_uno = False
if is_uno or not ANDROID:
handle_fan = handle_fan_uno
else:
setup_eon_fan()
handle_fan = handle_fan_eon
params = Params() params = Params()
pm = PowerMonitoring(is_uno) pm = PowerMonitoring()
while 1: while 1:
health = messaging.recv_sock(health_sock, wait=True) health = messaging.recv_sock(health_sock, wait=True)
@ -201,6 +196,18 @@ def thermald_thread():
usb_power = health.health.usbPowerMode != log.HealthData.UsbPowerMode.client usb_power = health.health.usbPowerMode != log.HealthData.UsbPowerMode.client
ignition = health.health.ignitionLine or health.health.ignitionCan ignition = health.health.ignitionLine or health.health.ignitionCan
# Setup fan handler on first connect to panda
if handle_fan is None and health.health.hwType != log.HealthData.HwType.unknown:
is_uno = health.health.hwType == log.HealthData.HwType.uno
if is_uno or not ANDROID:
cloudlog.info("Setting up UNO fan handler")
handle_fan = handle_fan_uno
else:
cloudlog.info("Setting up EON fan handler")
setup_eon_fan()
handle_fan = handle_fan_eon
# Handle disconnect # Handle disconnect
if health_prev is not None: if health_prev is not None:
if health.health.hwType == log.HealthData.HwType.unknown and \ if health.health.hwType == log.HealthData.HwType.unknown and \
@ -244,8 +251,9 @@ def thermald_thread():
max_comp_temp = max(max_cpu_temp, msg.thermal.mem / 10., msg.thermal.gpu / 10.) max_comp_temp = max(max_cpu_temp, msg.thermal.mem / 10., msg.thermal.gpu / 10.)
bat_temp = msg.thermal.bat / 1000. bat_temp = msg.thermal.bat / 1000.
fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed, ignition) if handle_fan is not None:
msg.thermal.fanSpeed = fan_speed fan_speed = handle_fan(max_cpu_temp, bat_temp, fan_speed, ignition)
msg.thermal.fanSpeed = fan_speed
# thermal logic with hysterisis # thermal logic with hysterisis
if max_cpu_temp > 107. or bat_temp >= 63.: if max_cpu_temp > 107. or bat_temp >= 63.:

Loading…
Cancel
Save