Skip to content

Commit

Permalink
Debug Message Improvement: ADC Voltage Ref Out of Range
Browse files Browse the repository at this point in the history
Improved the ADC voltage reference out of range message to list the device and port where the voltage was observed.  Also, suggest the user modify the voltage reference in the configuration wizard for this device to avoid this error in the future and improve accuracy of temperature calculations.

Changed this message errorlevel from 'error' to 'debug'.
  • Loading branch information
nebhead committed Oct 14, 2024
1 parent 1809f0b commit c99d483
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 deletions probes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def _temp_to_resistance(self, temp, probe_profile):

return Tr

def _voltage_to_temp(self, voltage, probe_profile):
def _voltage_to_temp(self, voltage, probe_profile, port=None):
if voltage == None:
''' Transient probe detected. '''
return None, 0
Expand Down Expand Up @@ -180,9 +180,11 @@ def _voltage_to_temp(self, voltage, probe_profile):
tempF = 0.0
tempC = 0.0
Tr = 0
error_event = f'An error occurred reading the voltage from one of the ports. The voltage read ({voltage}mV) ' \
f'was outside the expected range of 0mV to {probe_profile["Vs"] * 1000}mV'
self.logger.error(error_event)
error_event = f'An error occurred reading the voltage from device: {self.device_info['device']}, port: {port}. The voltage read {(voltage / 1000):,.2f}V ({voltage}mV) ' \
f'was outside the expected range of 0mV to {probe_profile["Vs"]}V. This usually means that ' \
f'the voltage reference is set too low in the probe device configuration. To fix this issue, ' \
f'please set the voltage reference to a value greater than {(voltage / 1000):,.2f}V in the configuration wizard.'
self.logger.debug(error_event)

if self.units == 'F':
return tempF, round(Tr) # Return Calculated Temperature and Thermistor Value in Ohms
Expand All @@ -197,7 +199,7 @@ def read_all_ports(self, output_data):
port_values[port] = self.device.read_voltage(port)

''' Convert Voltage to Temperature and Tr '''
port_values[port], self.output_data['tr'][self.port_map[port]] = self._voltage_to_temp(port_values[port], self.probe_profiles[port])
port_values[port], self.output_data['tr'][self.port_map[port]] = self._voltage_to_temp(port_values[port], self.probe_profiles[port], port=port)

''' Enqueue the Temperature Readings to Port Queues '''
if port_values[port] == None:
Expand Down
5 changes: 5 additions & 0 deletions updater/post-update-message.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ <H1>
Added a critical error flag to the control script. This will be used to detect when a critical error is encountered, which may prevent
further control of the system (i.e. changing modes, etc.)
</li>
<li>
Improved the ADC voltage reference out of range message to list the device and port where the voltage was observed. Also, suggest the user
modify the voltage reference in the configuration wizard for this device to avoid this error in the future and improve accuracy of
temperature calculations. Changed this message errorlevel from 'error' to 'debug'.
</li>
</ul>
</li>
</ul>
Expand Down

0 comments on commit c99d483

Please sign in to comment.