Skip to content

Commit

Permalink
Revert "MAINT: force python 2 like integer division, since types are …
Browse files Browse the repository at this point in the history
…unclear"

This reverts commit 3f466a3.
  • Loading branch information
DavidLP committed Jan 6, 2019
1 parent 25c0036 commit 040c7ae
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions basil/HL/FEI4AdapterCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# ------------------------------------------------------------
#

from __future__ import division
import logging
from struct import pack, unpack_from, calcsize
from array import array
Expand Down Expand Up @@ -169,7 +168,7 @@ def get_voltage(self, channel, unit='V'):
kwargs = self._ch_map[channel]['ADCV']
voltage_raw = self._get_adc_value(**kwargs)

voltage = (voltage_raw - self._ch_cal[channel]['ADCV']['offset']) // self._ch_cal[channel]['ADCV']['gain']
voltage = (voltage_raw - self._ch_cal[channel]['ADCV']['offset']) / self._ch_cal[channel]['ADCV']['gain']

if unit == 'raw':
return voltage_raw
Expand All @@ -188,7 +187,7 @@ def get_current(self, channel, unit='A'):
voltage = self.get_voltage(channel)

current_raw_iq = current_raw - (self._ch_cal[channel]['ADCI']['iq_offset'] + self._ch_cal[channel]['ADCI']['iq_gain'] * voltage) # quiescent current (IQ) compensation
current = (current_raw_iq - self._ch_cal[channel]['ADCI']['offset']) // self._ch_cal[channel]['ADCI']['gain']
current = (current_raw_iq - self._ch_cal[channel]['ADCI']['offset']) / self._ch_cal[channel]['ADCI']['gain']

if unit == 'raw':
return current_raw
Expand Down Expand Up @@ -390,8 +389,8 @@ def get_temperature(self, channel, sensor='VNTC'):
kwargs = self._ch_map[channel][sensor]
temp_raw = self._get_adc_value(**kwargs)

v_adc = ((temp_raw - self._ch_cal.items()[0][1]['ADCV']['offset']) // self._ch_cal.items()[0][1]['ADCV']['gain']) # voltage, VDDA1
k = self._ch_cal[channel][sensor]['R4'] // (self._ch_cal[channel][sensor]['R2'] + self._ch_cal[channel][sensor]['R4']) # reference voltage divider
r_ntc = self._ch_cal[channel][sensor]['R1'] * (k - v_adc // self._ch_cal[channel][sensor]['VREF']) // (1 - k + v_adc // self._ch_cal[channel][sensor]['VREF']) # NTC resistance
v_adc = ((temp_raw - self._ch_cal.items()[0][1]['ADCV']['offset']) / self._ch_cal.items()[0][1]['ADCV']['gain']) # voltage, VDDA1
k = self._ch_cal[channel][sensor]['R4'] / (self._ch_cal[channel][sensor]['R2'] + self._ch_cal[channel][sensor]['R4']) # reference voltage divider
r_ntc = self._ch_cal[channel][sensor]['R1'] * (k - v_adc / self._ch_cal[channel][sensor]['VREF']) / (1 - k + v_adc / self._ch_cal[channel][sensor]['VREF']) # NTC resistance

return (self._ch_cal[channel][sensor]['B_NTC'] // (log(r_ntc) - log(self._ch_cal[channel][sensor]['R_NTC_25']) + self._ch_cal[channel][sensor]['B_NTC'] // self.T_KELVIN_25)) - self.T_KELVIN_0 # NTC temperature
return (self._ch_cal[channel][sensor]['B_NTC'] / (log(r_ntc) - log(self._ch_cal[channel][sensor]['R_NTC_25']) + self._ch_cal[channel][sensor]['B_NTC'] / self.T_KELVIN_25)) - self.T_KELVIN_0 # NTC temperature

0 comments on commit 040c7ae

Please sign in to comment.