Gedeon Nyengele / Mbed 2 deprecated ece4180_lab4_ACS712

Dependencies:   mbed

Fork of ACS712 by m b

Files at this revision

API Documentation at this revision

Comitter:
nyengele
Date:
Sun Mar 13 17:47:14 2016 +0000
Parent:
4:f6c160553ca3
Commit message:
recalibrated the sensor

Changed in this revision

ACS712.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f6c160553ca3 -r a022ca4aaa1e ACS712.h
--- a/ACS712.h	Sun Mar 13 17:29:44 2016 +0000
+++ b/ACS712.h	Sun Mar 13 17:47:14 2016 +0000
@@ -70,11 +70,11 @@
 float ACS712::translate(float val){
     switch(type){
         case 5: 
-            return (val*ratio - 2.5*ratio)/(.185*ratio);
+            return (val*ratio - 2.46*ratio)/(.185*ratio);
         case 20:
-            return (val*ratio - 2.5*ratio)/(.1*ratio);
+            return (val*ratio - 2.46*ratio)/(.1*ratio);
         case 30:
-            return (val*ratio - 2.5*ratio)/(.066*ratio);
+            return (val*ratio - 2.46*ratio)/(.066*ratio);
         default:
             return 999;
     }
diff -r f6c160553ca3 -r a022ca4aaa1e main.cpp
--- a/main.cpp	Sun Mar 13 17:29:44 2016 +0000
+++ b/main.cpp	Sun Mar 13 17:47:14 2016 +0000
@@ -7,12 +7,13 @@
     ACS712 dev(p18);
     // Connect mbed to pc's USB port
     Serial pc(USBTX, USBRX);
+    
     pc.printf("Sensor Log: \n\n\r");
 
     while (1) {
         // Read current from sensor and output to pc terminal
-        pc.printf("Sensor Value: %2.2f A\n\r", dev);
-        wait(0.200);
+        pc.printf("Sensor Value: %2.2f A\n\r", float(dev));
+        wait(1);
     }
 
 }
\ No newline at end of file