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
Diff: app/main.cpp
- Revision:
- 12:8d057a5bf72e
- Parent:
- 11:9e35ddff7ed8
- Child:
- 13:3285ecb328a3
--- a/app/main.cpp Mon Jan 07 17:08:38 2019 +0000
+++ b/app/main.cpp Thu Jan 30 13:51:38 2020 +0000
@@ -3,12 +3,14 @@
#include "SerialDisplay.h"
-AnalogIn Vbat(A1);
-AnalogIn Led1(A2);
-AnalogIn Led2(A5);
+AnalogIn Vbat(PA_4);
+AnalogIn Led1(PA_1);
+AnalogIn Led2(PC_0);
AnalogIn RM(PC_2);
AnalogIn Vce(PB_1);
-
+DigitalOut Relay(D6);
+AnalogIn Exit(PC_4);
+//AnalogIn Exit2(PC_5);
/**
* Main application entry point.
@@ -78,21 +80,134 @@
}
int main()
-{
+{
pc.printf("mbed-os-rev: %d.%d.%d lib-rev: %d\r\n", \
MBED_MAJOR_VERSION, MBED_MINOR_VERSION,MBED_PATCH_VERSION,MBED_LIBRARY_VERSION);
pc.printf("BUILD= %s, SysClock= %d, RCC= %0X\r\n", __TIME__, SystemCoreClock, RCC->CR);
my_patch();
pc.printf("NEW SysClock= %d, NEW RCC= %0X\r\n", SystemCoreClock, RCC->CR);
- wait(3);
+ wait(1);
printf("\n");
printf("\n");
- int min=0;
- float meas_Vbat,meas_Led1,meas_Led2,meas_RM,meas_Vce;
- float v_Vbat,v_Led1,v_Led2,v_RM,v_Vce;
+ 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_v;
+
+
+
+ pc.printf("***Charging Mode***\n\n");
+ Relay= 0; // Start the test Relay =1
+
+// printf("\tAnalogIn example\n");
+ printf("count");
+ printf("\tVbat");
+ printf("\tLED1");
+ printf("\tLED2");
+ printf("\tRM");
+ printf("\tVce");
+ 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_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();
+
+
+
+ // Display readings
+ v_Vbat = meas_Vbat * 3300 *2;
+ 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_Exit2 = meas_Exit2 * 3.300/2.2;
+
+
+ printf("%d\t", count);
+ printf("%.0f\t", v_Vbat);
+ 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_Exit2);
+ printf("\n");
+
+ count++;
+ wait(0.1); // 10 second
+
+}
+ count = 0;
+
+
+ pc.printf("***Discharging Mode 1***\n\n");
+ Relay= 0; // Start the test Relay =1
+
+// printf("\tAnalogIn example\n");
+ printf("count");
+ printf("\tVbat");
+ printf("\tLED1");
+ printf("\tLED2");
+ printf("\tRM");
+ printf("\tVce");
+ 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_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();
+
+
+
+ // Display readings
+ v_Vbat = meas_Vbat * 3300 *2;
+ 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_Exit2 = meas_Exit2 * 3.300/2.2;
+
+
+ printf("%d\t", count);
+ printf("%.0f\t", v_Vbat);
+ 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_Exit2);
+ printf("\n");
+
+ count++;
+ wait(0.1); // 10 second
+}
+
+
+
+
+ printf("\n");
+ printf("\n");
+ pc.printf("***Discharging Mode 2***\n\n");
// printf("\tAnalogIn example\n");
printf("min");
printf("\tVbat");
@@ -100,34 +215,45 @@
printf("\tLED2");
printf("\tRM");
printf("\tVce");
+ printf("\tExit");
+ // printf("\tExit2");
printf("\n");
-
while(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)
- meas_Led1 = Led1.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
- meas_Led2 = Led2.read();
- meas_RM = RM.read();
+ 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();
-
- // Display readings
- v_Vbat = meas_Vbat*3300*2;
- v_Led1 = meas_Led1*3300;
- v_Led2 = meas_Led2*3300;
- v_RM = meas_RM*3300;
- v_Vce = meas_Vce*3300;
+ meas_Exit = Exit.read();
+ // meas_Exit2 = Exit2.read();
+
+
+ // Display readings
+ v_Vbat = meas_Vbat * 3300 *2;
+ 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_Exit2 = meas_Exit2 * 3.300/2.2;
printf("%d\t", min);
printf("%.0f\t", v_Vbat);
- printf("%.0f\t", v_Led1);
- printf("%.0f\t", v_Led2);
- printf("%.0f\t", v_RM);
- printf("%.0f\n", v_Vce);
+ 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_Exit2);
+ printf("\n");
-
- wait(5.0); // 1 second
+
+ wait(5.0); // 10 second
min++;
}
+
}