Browse Source

better pico adc calibration values

Thomas Buck 1 year ago
parent
commit
1638b677f0
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      pico.py

+ 9
- 3
pico.py View File

100
         # TODO supports only 2 points
100
         # TODO supports only 2 points
101
         cal_pts = [
101
         cal_pts = [
102
             #  adc,   bat
102
             #  adc,   bat
103
-            (13.65, 15.46),
104
-            (13.60, 15.34),
105
-            # TODO better values
103
+            #(13.65, 15.46),
104
+            #(13.60, 15.34),
105
+            (13.625, 15.4), # avg of above
106
+
107
+            (14.30, 16.13),
106
         ]
108
         ]
107
 
109
 
108
         # https://www.ti.com/europe/downloads/f2810_12_calibration_10.pdf
110
         # https://www.ti.com/europe/downloads/f2810_12_calibration_10.pdf
110
         offset = cal_pts[1][1] - cal_pts[1][0] * gain
112
         offset = cal_pts[1][1] - cal_pts[1][0] * gain
111
         v_bat = v_bat_uncal * gain + offset
113
         v_bat = v_bat_uncal * gain + offset
112
 
114
 
115
+        # Use this to gather calibration data
116
+        #v_bat = v_bat_uncal
117
+        #print(v_bat)
118
+
113
         # TODO auto-detect cell count
119
         # TODO auto-detect cell count
114
         n_lipo = const(4) # 4S
120
         n_lipo = const(4) # 4S
115
         v_cell = v_bat / n_lipo
121
         v_cell = v_bat / n_lipo

Loading…
Cancel
Save