![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
ADC logging with demo drive board for calibration ADC read synchronised with heater on time
Dependencies: mbed MODSERIAL FastPWM ADS8568_ADC
Diff: main.cpp
- Revision:
- 7:2d695116d636
- Parent:
- 6:75b09f0bcbd9
- Child:
- 8:325f68c1e3d2
diff -r 75b09f0bcbd9 -r 2d695116d636 main.cpp --- a/main.cpp Tue Jan 29 09:32:04 2019 +0000 +++ b/main.cpp Wed Jan 30 14:06:44 2019 +0000 @@ -32,7 +32,7 @@ short int val_array[8]; //send convert signal to channels - convt = CH_AC; + convt = CH_ABCD; wait_us(1); convt = 0; @@ -53,15 +53,16 @@ int main() { int n_samples = 20; - double r; - double r_max = 0; - double r_min = 1e10; - double r_sum = 0; - double r_sum2 = 0; - double r_mean; - double r_mean2; - double r_sd; - double r_cv; + double r1; + double r2; + double r1_max = 0; + double r1_min = 1e10; + double r1_sum = 0; + double r1_sum2 = 0; + double r1_mean; + double r1_mean2; + double r1_sd; + double r1_cv; rLED = 0; yLED = 0; @@ -87,7 +88,7 @@ yLED = 0; gLED = 1; - sprintf(outString, "I1SIG, I1REF, V1POS, V1NEG, R\r\n"); + sprintf(outString, "I1SIG, I1REF, V1POS, V1NEG, R1 I2SIG, I2REF, V2POS, V2NEG, R2\r\n"); pc.printf("%s", outString); for (int x=0; x<n_samples; x++) { @@ -98,30 +99,31 @@ drive = 0; yLED = 0; - r = (double)(val_array[5]-val_array[4])/(double)(val_array[1]-val_array[0]); - if (r < r_min) { r_min = r; } - if (r > r_max) { r_max = r; } - r_sum = r_sum + r; - r_sum2 = r_sum2 + (r*r); + r1 = (double)(val_array[5]-val_array[4])/(double)(val_array[1]-val_array[0]); + r2 = (double)(val_array[7]-val_array[6])/(double)(val_array[1]-val_array[2]); + if (r1 < r1_min) { r1_min = r1; } + if (r1 > r1_max) { r1_max = r1; } + r1_sum = r1_sum + r1; + r1_sum2 = r1_sum2 + (r1*r1); - sprintf(outString, "%5d\t %5d\t %5d\t %5d\t %f\r\n", val_array[0], val_array[1], val_array[4], val_array[5], r); + sprintf(outString, "%5d\t %5d\t %5d\t %5d\t %f %5d\t %5d\t %5d\t %5d\t %f\r\n", val_array[0], val_array[1], val_array[4], val_array[5], r1, val_array[2], val_array[1], val_array[6], val_array[7], r2); pc.printf("%s", outString); wait_ms(1000); } - r_mean = r_sum/n_samples; - r_mean2 = r_sum2/n_samples; - r_sd = sqrt(r_mean2-(r_mean*r_mean)); - r_cv = r_sd/r_mean; + r1_mean = r1_sum/n_samples; + r1_mean2 = r1_sum2/n_samples; + r1_sd = sqrt(r1_mean2-(r1_mean*r1_mean)); + r1_cv = r1_sd/r1_mean; pc.printf("Statistics:\r\n"); pc.printf("n_samples : %d\r\n", n_samples); - pc.printf("r_mean : %f\r\n", r_mean); - pc.printf("r_min : %f\r\n", r_min); - pc.printf("r_max : %f\r\n", r_max); - pc.printf("r_sd : %f\r\n", r_sd); - pc.printf("r_cv : %f\r\n", r_cv); + pc.printf("r1_mean : %f\r\n", r1_mean); + pc.printf("r1_min : %f\r\n", r1_min); + pc.printf("r1_max : %f\r\n", r1_max); + pc.printf("r1_sd : %f\r\n", r1_sd); + pc.printf("r1_cv : %f\r\n", r1_cv); rLED = 0;