Drain batteries through an LM324 controlled CEB6030L from a defunct graphics card

Dependencies:   mbed FastAnalogIn PID mbed-rtos

Revision:
5:7112e564d33a
Parent:
4:fb20b0b3f57d
Child:
7:3061a3da1c97
--- a/main.cpp	Tue Jul 05 20:03:55 2016 +0000
+++ b/main.cpp	Tue Jul 05 20:08:59 2016 +0000
@@ -17,7 +17,7 @@
     float operator()(float in) { return v = k * in + (1 - k) * v; }
     operator float() { return v; }
 };
-inline float Iin(float x) { return x * 32.9697 + 1/60.0; }
+inline float Iin(float x) { return x < 0.0008? 0 : x * 33.07273 + 0.016; }
 inline float Vin(float x) { return x * 34.08516 + 0.06567447; }
 
 Lag iget(Iin(Iget.read())), vbat(Vin(Vbat.read())), vbat_rest(Vin(Vbat.read()));
@@ -106,13 +106,13 @@
         if (header) {
             header = false;
             pc.printf("Discharging\r\n");
-            pc.printf("Duration (s)\tVbat (V)\tVbat_rest (V)\tDischarge (I)\tCapacity (mAh)\r\n");
+            pc.printf("Duration (s)\tVbat (V)\tVbat_rest (V)\tTarget (I)\tDischarge (I)\tCapacity (mAh)\r\n");
         }
         //pc.printf("Iset %f    Iget %6d %f    Vbat %6d %f    \r", Iset.read(), Iget.read_u16(), Iget.read(), Vbat.read_u16(), Vbat.read());
         //pc.printf("Iset %f      Iget %8d %f %f", Iset.read(), Iget.read_u16(), Iin(Iget.read()), (float)iget);
         //pc.printf("      Vbat %8d %f %f %f    charge %f\r", Vbat.read_u16(), Vin(Vbat.read()), (float)vbat, (float)vbat_rest, charge);
         if (active)
-            pc.printf("%-8.2f\t%f\t%f\t%f\t%f\r\n", (T.read_us()/10000)/100.0, (float)vbat, (float)vbat_rest, (float)iget, charge);
+            pc.printf("%-8.2f\t%f\t%f\t%f\t%f\t%f\r\n", (T.read_us()/10000)/100.0, (float)vbat, (float)vbat_rest, (float)Iset.read(), (float)iget, charge);
         Thread::wait(1000);
     }
 }