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
Diff: src/adc.cpp
- Revision:
- 8:d3d7dca419b3
- Parent:
- 6:39442d493098
- Child:
- 9:816b9a4e4f21
--- a/src/adc.cpp Wed Dec 05 00:20:34 2018 +0000 +++ b/src/adc.cpp Thu Dec 06 16:22:11 2018 +0000 @@ -36,14 +36,59 @@ } +void getADCresults(void){ + + unsigned int v48x = 0; + unsigned int v24x = 0; + unsigned int v12x = 0; + unsigned int i48x = 0; + unsigned int i24x = 0; + unsigned int i12x = 0; + + for(unsigned int i=0;i<100;i++){ + v48x = v48x + VIN48.read_u16(); + v24x = v24x + VIN24.read_u16(); + v12x = v12x + VIN12.read_u16(); + i48x = i48x + IIN48.read_u16(); + i24x = i24x + IIN24.read_u16(); + i12x = i12x + IIN12.read_u16(); + } + v48 = v48x/100; + v24 = v24x/100; + v12 = v12x/100; + i48 = i48x/100; + i24 = i24x/100; + i12 = i12x/100; +} + void getADCvolts(void){ - v48 = VIN48.read_u16(); - v24 = VIN24.read_u16(); - v12 = VIN12.read_u16(); + + unsigned int v48x = 0; + unsigned int v24x = 0; + unsigned int v12x = 0; + + for(unsigned int i=0;i<100;i++){ + v48x = v48x + VIN48.read_u16(); + v24x = v24x + VIN24.read_u16(); + v12x = v12x + VIN12.read_u16(); + } + v48 = v48x/100; + v24 = v24x/100; + v12 = v12x/100; } void getADCamps(void){ - i48 = IIN48.read_u16(); - i24 = IIN24.read_u16(); - i12 = IIN12.read_u16(); + + unsigned int i48x = 0; + unsigned int i24x = 0; + unsigned int i12x = 0; + + for(unsigned int i=0;i<100;i++){ + i48x = i48x + IIN48.read_u16(); + i24x = i24x + IIN24.read_u16(); + i12x = i12x = IIN12.read_u16(); + } + i48 = i48x/100; + i24 = i24x/100; + i12 = i12x/100; } \ No newline at end of file