@@ -71,6 +71,7 @@ class Gain:
71
71
DIV_2_80MV = 0x01 # shunt prog. gain set to /2, 80 mV range
72
72
DIV_4_160MV = 0x02 # shunt prog. gain set to /4, 160 mV range
73
73
DIV_8_320MV = 0x03 # shunt prog. gain set to /8, 320 mV range
74
+ AUTO = - 1 # shunt prog. gain set to automatic
74
75
75
76
class ADCResolution :
76
77
"""Constants for ``bus_adc_resolution`` or ``shunt_adc_resolution``"""
@@ -501,14 +502,14 @@ def set_calibration_16V_5A(self):
501
502
502
503
# 4. Choose an LSB between the min and max values
503
504
# (Preferrably a roundish number close to MinLSB)
504
- # CurrentLSB = 0.00016 (50uA per bit)
505
+ # CurrentLSB = 0.00016 (uA per bit)
505
506
self ._current_lsb = 0.1524 # in milliamps
506
507
507
508
# 5. Compute the calibration register
508
509
# Cal = trunc (0.04096 / (Current_LSB * RSHUNT))
509
- # Cal = 26869 (0x68f5 )
510
+ # Cal = 13434 (0x347a )
510
511
511
- self ._cal_value = 26869
512
+ self ._cal_value = 13434
512
513
513
514
# 6. Calculate the power LSB
514
515
# PowerLSB = 20 * CurrentLSB
@@ -517,41 +518,15 @@ def set_calibration_16V_5A(self):
517
518
518
519
# 7. Compute the maximum current and shunt voltage values before overflow
519
520
#
520
- # Max_Current = Current_LSB * 32767
521
- # Max_Current = 1.63835A before overflow
522
- #
523
- # If Max_Current > Max_Possible_I then
524
- # Max_Current_Before_Overflow = MaxPossible_I
525
- # Else
526
- # Max_Current_Before_Overflow = Max_Current
527
- # End If
528
- #
529
- # Max_Current_Before_Overflow = MaxPossible_I
530
- # Max_Current_Before_Overflow = 0.4
531
- #
532
- # Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT
533
- # Max_ShuntVoltage = 0.04V
534
- #
535
- # If Max_ShuntVoltage >= VSHUNT_MAX
536
- # Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX
537
- # Else
538
- # Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage
539
- # End If
540
- #
541
- # Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX
542
- # Max_ShuntVoltage_Before_Overflow = 0.04V
543
-
544
521
# 8. Compute the Maximum Power
545
- # MaximumPower = Max_Current_Before_Overflow * VBUS_MAX
546
- # MaximumPower = 0.4 * 16V
547
- # MaximumPower = 6.4W
522
+ #
548
523
549
524
# Set Calibration register to 'Cal' calcutated above
550
525
self ._raw_calibration = self ._cal_value
551
526
552
527
# Set Config register to take into account the settings above
553
528
self .bus_voltage_range = BusVoltageRange .RANGE_16V
554
- self .gain = Gain .DIV_2_80MV
529
+ self .gain = Gain .AUTO
555
530
self .bus_adc_resolution = ADCResolution .ADCRES_12BIT_1S
556
531
self .shunt_adc_resolution = ADCResolution .ADCRES_12BIT_1S
557
532
self .mode = Mode .SANDBVOLT_CONTINUOUS
0 commit comments