/ Freq_Meter

Files at this revision

API Documentation at this revision

Comitter:
thomasosullivan
Date:
Wed Apr 01 20:58:55 2020 +0000
Parent:
2:6077294f7007
Commit message:
Final ammeter

Changed in this revision

Ammeter_Code.cpp Show annotated file Show diff for this revision Revisions of this file
Ohmmeter_Code.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Ammeter_Code.cpp	Wed Apr 01 19:45:59 2020 +0000
+++ b/Ammeter_Code.cpp	Wed Apr 01 20:58:55 2020 +0000
@@ -1,3 +1,35 @@
+/*
+the ammeter reads the voltage accross the shunt resister that is a set value
+this is used to calculate the current in the circuit
+a value for current will be printed in mA on the LCD screen
+
+*/
+
+
 //Case x:
+lcd.locate(0.0)
+lcd.printf("Current: "); 
+
+
+AnalogIn vo(A5);  //reads the voltage across rshunt
 
-jk
\ No newline at end of file
+double vout= (3.3*vo)/4095; //converts from bits in the analog read
+double rshunt = 0.01;       //set value for rshunt
+int i;                      // declares a integer for i
+
+
+i = vout/rshunt;           // equation to find i
+
+if i<= 0.5{ 
+
+ifinal= i*1000; //converts into amps to mA
+lcd.locate(0,1);
+lcd.printf(".3f mA", ifinal);
+    }
+else {
+lcd.locate(0,1);
+lcd.printf("out of range");
+}
+//if and else staments here are based in if the i that has been found is within the parameters 
+  
+    
\ No newline at end of file
--- a/Ohmmeter_Code.cpp	Wed Apr 01 19:45:59 2020 +0000
+++ b/Ohmmeter_Code.cpp	Wed Apr 01 20:58:55 2020 +0000
@@ -13,7 +13,7 @@
 
 DigitalOut 100ohm(D6) = 0; //Transistor connected to 100ohm resistor set to short circuit
 DigitalOut 1kohm(D7) = 1; //All others set to open circuit      
-DigitalOut 10kohm(D8) = 1;
+DigitalOut 10kohm(D8) = 1; 
 DigitalOut 100kohm(D9) = 1;
 DigitalOut 1Mohm(D10) = 1;
 DigitalOut 10Mohm(D11) = 1;
@@ -23,7 +23,7 @@
 double vout = (3.3 * vo)/ 4095; //converts analog read from bits to voltage
 
 double rest;
-
+int runkown;
 double vt;
 
 rest = (vout * 100) / (3.3 - vout); //rest is an estimate as it does not account for the voltage drop in transistor
@@ -55,6 +55,7 @@
     else {
         runknown = runknown / 1000; //runkown is now printed in KΩ
         lcd.printf("%.2f kΩ", runknown);
+        }
         break;
         
     case 55000:
@@ -84,6 +85,7 @@
     else {
         runknown = runknown / 1000000;        // this will change the magnitude to MΩ
         lcd.printf("%.2f MΩ", runknown);
+        }
         break;
         
     case 5500000: