Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed LoRaWAN-lib SX1276Lib
Revision 13:3285ecb328a3, committed 2020-05-21
- Comitter:
- amirchaudhary
- Date:
- Thu May 21 16:36:11 2020 +0000
- Parent:
- 12:8d057a5bf72e
- Commit message:
- Analog values current readings
Changed in this revision
| app/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/app/main.cpp Thu Jan 30 13:51:38 2020 +0000
+++ b/app/main.cpp Thu May 21 16:36:11 2020 +0000
@@ -3,7 +3,8 @@
#include "SerialDisplay.h"
-AnalogIn Vbat(PA_4);
+AnalogIn Vbat1(PC_5);
+AnalogIn Vbat2(PA_4);
AnalogIn Led1(PA_1);
AnalogIn Led2(PC_0);
AnalogIn RM(PC_2);
@@ -93,29 +94,37 @@
printf("\n");
int min=0,count=0;
- float meas_Vbat,meas_Led1,meas_Led2,meas_RM,meas_Vce,meas_Exit,meas_Exit2;
- float v_Vbat,v_Led1,v_Led2,v_RM,v_Vce,v_Exit,v_Exit2;
+ float meas_Vbat1,meas_Vbat2,meas_Cbat,meas_Led1,meas_Led2,meas_RM,meas_Vce,meas_Exit,meas_Exit2;
+ float v_Vbat1,v_Vbat2,v_Cbat,v_Led1,v_Led2,v_RM,v_Vce,v_Exit,v_Exit2;
// float meas_v;
+// RGB and Relay Test
+
+
pc.printf("***Charging Mode***\n\n");
Relay= 0; // Start the test Relay =1
// printf("\tAnalogIn example\n");
printf("count");
- printf("\tVbat");
+ printf("\tVbat1");
+ printf("\tVbat2");
+ printf("\tCbat");
printf("\tLED1");
printf("\tLED2");
printf("\tRM");
printf("\tVce");
- printf("\tExit");
+ // printf("\tExit");
// printf("\tExit2");
printf("\n");
for(int j=0;j<=300;j++){
- meas_Vbat = Vbat.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+
+ meas_Vbat1 = Vbat1.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ meas_Vbat2 = Vbat2.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ // meas_Cbat = meas_Vbat1 - meas_Vbat2;
meas_Led1 = Led1.read() - Vce.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
meas_Led2 = Led2.read() - Vce.read();
meas_RM = RM.read() - Vce.read();
@@ -123,52 +132,59 @@
meas_Exit = Exit.read();
// meas_Exit2 = Exit2.read();
-
-
// Display readings
- v_Vbat = meas_Vbat * 3300 *2;
+ v_Vbat1 = meas_Vbat1 * 3.300 * 2;
+ v_Vbat2 = meas_Vbat2 * 3.300 * 2;
+ v_Cbat = v_Vbat1 - v_Vbat2;
v_Led1 = (meas_Led1 * 3.300)/2.2;
v_Led2 = (meas_Led2 * 3.300)/2.2;
v_RM = (meas_RM * 3.300)/2.2;
v_Vce = meas_Vce * 3.300;
- v_Exit = meas_Exit * 3.300/24;
+ // v_Exit = meas_Exit * 3.300/24;
// v_Exit2 = meas_Exit2 * 3.300/2.2;
-
printf("%d\t", count);
- printf("%.0f\t", v_Vbat);
+
+ printf("%.03f\t", v_Vbat1);
+ printf("%.03f\t", v_Vbat2);
+ printf("%.03f\t", v_Cbat);
printf("%.03f\t", v_Led1);
printf("%.03f\t", v_Led2);
printf("%.03f\t", v_RM);
printf("%.03f\t", v_Vce);
- printf("%.03f\t",v_Exit);
+ // printf("%.03f\t",v_Exit);
+
// printf("%.03f\t",v_Exit2);
printf("\n");
-
+
count++;
- wait(0.1); // 10 second
+ wait(0.4); // 10 second
}
count = 0;
pc.printf("***Discharging Mode 1***\n\n");
- Relay= 0; // Start the test Relay =1
-
-// printf("\tAnalogIn example\n");
+ Relay= 1; // Start the test Relay =1
+ // printf("\tAnalogIn example\n");
printf("count");
- printf("\tVbat");
+ printf("\tVbat1");
+ printf("\tVbat2");
+ printf("\tCbat");
printf("\tLED1");
printf("\tLED2");
printf("\tRM");
printf("\tVce");
- printf("\tExit");
- // printf("\tExit2");
+ // printf("\tExit");
+ // printf("\tExit2");
printf("\n");
- for(int j=0;j<=300;j++){
- meas_Vbat = Vbat.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ for(int j=0;j<=100;j++){
+
+ meas_Vbat1 = Vbat1.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ meas_Vbat2 = Vbat2.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ // meas_Cbat = meas_Vbat1 - meas_Vbat2;
meas_Led1 = Led1.read() - Vce.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
meas_Led2 = Led2.read() - Vce.read();
meas_RM = RM.read() - Vce.read();
@@ -176,30 +192,34 @@
meas_Exit = Exit.read();
// meas_Exit2 = Exit2.read();
-
-
- // Display readings
- v_Vbat = meas_Vbat * 3300 *2;
+ // Display readings
+ v_Vbat1 = meas_Vbat1 * 3.300 * 2;
+ v_Vbat2 = meas_Vbat2 * 3.300 * 2;
+ v_Cbat = v_Vbat1 - v_Vbat2;
v_Led1 = (meas_Led1 * 3.300)/2.2;
v_Led2 = (meas_Led2 * 3.300)/2.2;
v_RM = (meas_RM * 3.300)/2.2;
v_Vce = meas_Vce * 3.300;
- v_Exit = meas_Exit * 3.300/24;
+ // v_Exit = meas_Exit * 3.300/24;
// v_Exit2 = meas_Exit2 * 3.300/2.2;
-
printf("%d\t", count);
- printf("%.0f\t", v_Vbat);
+
+ printf("%.03f\t", v_Vbat1);
+ printf("%.03f\t", v_Vbat2);
+ printf("%.03f\t", v_Cbat);
printf("%.03f\t", v_Led1);
printf("%.03f\t", v_Led2);
printf("%.03f\t", v_RM);
printf("%.03f\t", v_Vce);
- printf("%.03f\t",v_Exit);
+ // printf("%.03f\t",v_Exit);
+
// printf("%.03f\t",v_Exit2);
printf("\n");
+
count++;
- wait(0.1); // 10 second
+ wait(0.5); // 10 second
}
@@ -208,52 +228,69 @@
printf("\n");
printf("\n");
pc.printf("***Discharging Mode 2***\n\n");
+
// printf("\tAnalogIn example\n");
- printf("min");
- printf("\tVbat");
+ // printf("\tAnalogIn example\n");
+ printf("count");
+ printf("\tVbat1");
+ printf("\tVbat2");
+ printf("\tCbat");
printf("\tLED1");
printf("\tLED2");
printf("\tRM");
printf("\tVce");
- printf("\tExit");
- // printf("\tExit2");
+ // printf("\tExit");
+ // printf("\tExit2");
printf("\n");
+
+
+
+
while(1) {
- Relay= 0; // Start the test Relay =1
+ Relay= 0; // Start the test Relay =1
+
- meas_Vbat = Vbat.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ for(int j=0;j<=100000;j++){
+
+ meas_Vbat1 = Vbat1.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ meas_Vbat2 = Vbat2.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
+ // meas_Cbat = meas_Vbat1 - meas_Vbat2;
meas_Led1 = Led1.read() - Vce.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
meas_Led2 = Led2.read() - Vce.read();
meas_RM = RM.read() - Vce.read();
meas_Vce = Vce.read();
meas_Exit = Exit.read();
- // meas_Exit2 = Exit2.read();
-
+ // meas_Exit2 = Exit2.read();
- // Display readings
- v_Vbat = meas_Vbat * 3300 *2;
+ // Display readings
+ v_Vbat1 = meas_Vbat1 * 3.300 * 2;
+ v_Vbat2 = meas_Vbat2 * 3.300 * 2;
+ v_Cbat = v_Vbat1 - v_Vbat2;
v_Led1 = (meas_Led1 * 3.300)/2.2;
v_Led2 = (meas_Led2 * 3.300)/2.2;
v_RM = (meas_RM * 3.300)/2.2;
v_Vce = meas_Vce * 3.300;
- v_Exit = meas_Exit * 3.300/24;
+ // v_Exit = meas_Exit * 3.300/24;
// v_Exit2 = meas_Exit2 * 3.300/2.2;
-
printf("%d\t", min);
- printf("%.0f\t", v_Vbat);
+
+ printf("%.03f\t", v_Vbat1);
+ printf("%.03f\t", v_Vbat2);
+ printf("%.03f\t", v_Cbat);
printf("%.03f\t", v_Led1);
printf("%.03f\t", v_Led2);
printf("%.03f\t", v_RM);
printf("%.03f\t", v_Vce);
- printf("%.03f\t",v_Exit);
+ // printf("%.03f\t",v_Exit);
+
// printf("%.03f\t",v_Exit2);
printf("\n");
-
-
- wait(5.0); // 10 second
+
+
+ wait(1.0); // 10 second
min++;
}
-}
+}}
\ No newline at end of file