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.
Revision 1:748e07bbe96e, committed 2011-12-05
- Comitter:
- chris
- Date:
- Mon Dec 05 14:23:15 2011 +0000
- Parent:
- 0:7d24851a0521
- Commit message:
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Dec 02 17:11:13 2011 +0000
+++ b/main.cpp Mon Dec 05 14:23:15 2011 +0000
@@ -19,12 +19,10 @@
int num_256;
int num_512;
int num_1024;
-int num_2048;
+int num_spike;
int main() {
- pc.baud(115200);
-
int num_samples = 0;
num_4 = 0;
@@ -36,7 +34,7 @@
num_256 = 0;
num_512 = 0;
num_1024 = 0;
- num_2048 = 0;
+ num_spike = 0;
// Take the average over 500,000 samples
@@ -52,9 +50,9 @@
num_samples++;
}
}
-
+
AVERAGE /= NUM_SAMPLES;
-
+
num_samples = 0;
pc.printf("Average = %f\n",AVERAGE);
@@ -62,16 +60,19 @@
// Now start sampling series of 500,000
// acculumating the errors seen in each range
pc.printf("Profiling %d samples\n",SAMPLE_BLOCKS*NUM_SAMPLES);
+
+
for (int j=0; j < SAMPLE_BLOCKS ; j++) {
t.reset();
t.start();
-
+
for (int i = 0; i < NUM_SAMPLES ; i++) {
float a = ain.read();
- if (a > (AVERAGE + 0.5000)) {
- num_2048++; // > 2048 lsb
+
+ if (a == 1.0) {
+ num_spike++; // > 2048 lsb
} else if (a > (AVERAGE + 0.2500)) {
num_1024++; // > 1024 lsb
} else if (a > (AVERAGE + 0.0625)) {
@@ -95,7 +96,23 @@
num_samples++;
}
t.stop();
-
+
+ if (j==0) {
+ pc.printf("Samples\t");
+ pc.printf("4\t");
+ pc.printf("8\t");
+ pc.printf("16\t");
+ pc.printf("32\t");
+ pc.printf("64\t");
+ pc.printf("128\t");
+ pc.printf("256\t");
+ pc.printf("512\t");
+ pc.printf("1024\t");
+ pc.printf("Spikes\t");
+ pc.printf("Time\n");
+ }
+
+
// Every 500,000 print the results
pc.printf("%d\t",num_samples);
pc.printf("%d\t",num_4);
@@ -107,9 +124,9 @@
pc.printf("%d\t",num_256);
pc.printf("%d\t",num_512);
pc.printf("%d\t",num_1024);
- pc.printf("%d\t",num_2048);
- pc.printf("%f\n",t.read());
+ pc.printf("%d\t",num_spike);
+ pc.printf("%fs\n",t.read());
}
-
+
pc.printf("==== Test Complete ====\n");
}