
Hex-current-measurements
Dependencies: mbed LoRaWAN-lib SX1276Lib
Revision 12:630be38ec1ed, committed 2019-05-01
- Comitter:
- amirchaudhary
- Date:
- Wed May 01 17:17:56 2019 +0000
- Parent:
- 11:9e35ddff7ed8
- Commit message:
- Hex-current-measurements
Changed in this revision
app/main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9e35ddff7ed8 -r 630be38ec1ed app/main.cpp --- a/app/main.cpp Mon Jan 07 17:08:38 2019 +0000 +++ b/app/main.cpp Wed May 01 17:17:56 2019 +0000 @@ -3,11 +3,12 @@ #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); /** @@ -78,39 +79,44 @@ } 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; + int min=0,count=0; + float meas_Vbat,meas_Led1,meas_Led2,meas_RM,meas_Vce; float v_Vbat,v_Led1,v_Led2,v_RM,v_Vce; // float meas_v; + + + // printf("\tAnalogIn example\n"); printf("min"); printf("\tVbat"); printf("\tLED1"); printf("\tLED2"); printf("\tRM"); - printf("\tVce"); + // printf("\tVce"); printf("\n"); - while(1) { - + Relay= 1; // 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_Vce = Vce.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; @@ -118,16 +124,26 @@ v_RM = meas_RM*3300; v_Vce = meas_Vce*3300; + */ + + // Display readings + v_Vbat = meas_Vbat * 3.350*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; + 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_Vbat); + printf("%.03f\t", v_Led1); + printf("%.03f\t", v_Led2); + printf("%.03f\t", v_RM); + printf("\n"); - wait(5.0); // 1 second + wait(10.0); // 10 second min++; } + }