FOR 32V 3.2A

Fork of INA219 by Components

Files at this revision

API Documentation at this revision

Comitter:
andcor02
Date:
Thu Apr 12 14:21:51 2018 +0000
Parent:
0:eee9c8ba72ff
Commit message:
FOR 32V 3.2A

Changed in this revision

INA219.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/INA219.cpp	Thu Aug 28 10:32:20 2014 +0000
+++ b/INA219.cpp	Thu Apr 12 14:21:51 2018 +0000
@@ -49,31 +49,28 @@
 // Public Methods
 
 void INA219::calibrate_16v_400mA()
+
 {
+    //THIS IS FOR 32V 3.2A, SEE HERE FOR CONFIG:
+    //https://github.com/adafruit/Adafruit_INA219/blob/master/Adafruit_INA219.cpp
     // ASSUMING A 0.1 OHM RESISTOR!
-    write_register_u16(INA219_REG_CALIBRATION, 8192);
+    write_register_u16(INA219_REG_CALIBRATION, 4096);
 
     // Write to config register
 
     uint16_t resolution_mask = 0x0000;
     
-    if (resolution == RES_12BITS)
+
         resolution_mask = INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_1S_532US;
-    else if (resolution == RES_11BITS)
-        resolution_mask = INA219_CONFIG_BADCRES_11BIT | INA219_CONFIG_SADCRES_11BIT_1S_276US;
-    else if (resolution == RES_10BITS)
-        resolution_mask = INA219_CONFIG_BADCRES_10BIT | INA219_CONFIG_SADCRES_10BIT_1S_148US;
-    else // resolution == RES_9BITS
-        resolution_mask = INA219_CONFIG_BADCRES_9BIT | INA219_CONFIG_SADCRES_9BIT_1S_84US;
 
-    write_register_u16(INA219_REG_CONFIG, INA219_CONFIG_BVOLTAGERANGE_16V |
-                    INA219_CONFIG_GAIN_1_40MV |
+    write_register_u16(INA219_REG_CONFIG, INA219_CONFIG_BVOLTAGERANGE_32V |
+                    INA219_CONFIG_GAIN_8_320MV |
                     resolution_mask |
                     INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS);
                     
     // Set current divider
-    current_divider = 20;
-    power_divider = 1;
+    current_divider = 10;
+    power_divider = 2;
 }
 
 int16_t INA219::read_current_raw()