ADC logging with demo drive board for calibration

Dependencies:   mbed MODSERIAL FastPWM ADS8568_ADC

Files at this revision

API Documentation at this revision

Comitter:
paullj
Date:
Tue Mar 17 15:06:40 2020 +0000
Parent:
30:ab214b681d9b
Commit message:
Reverted to last working revision

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r ab214b681d9b -r 0888ce8aa0e1 main.cpp
--- a/main.cpp	Tue Mar 17 15:02:33 2020 +0000
+++ b/main.cpp	Tue Mar 17 15:06:40 2020 +0000
@@ -4,8 +4,8 @@
 #include "MODSERIAL.h"
 
 #define MEAS_DELAY       60  // measurement delay after turning on FET (us)
-#define LOG_INTERVAL    200  // log file interval (ms)
-#define START_DELAY     100  // pause for startup (ms)
+#define LOG_INTERVAL   1000  // log file interval (ms)
+#define START_DELAY    1000  // pause for startup (ms)
 #define N_STEPS         100
 #define BUFFER_SIZE    4096
 
@@ -96,10 +96,10 @@
         }
     }
     
-    if (i_board != -1) pc.printf("Drive board: %d   ADC measurement: PWM heater pulse. 60us delay\n",drive_board_serial_number[i_board]);
+    if (i_board != -1) pc.printf("Drive board: Board %d   ADC measurement: PWM heater pulse, 60us delay\n",drive_board_serial_number[i_board]);
     else pc.printf("Drive board UID match not found\n");
 
-    pc.printf("eTime,        I1,         V1,     R1_adc,     R1_ohm,       I2,         V2,     R2_adc,     R2_ohm\n");
+    pc.printf("iStep,      eTime,        I1,         V1,     R1_adc,     R1_ohm,       I2,         V2,     R2_adc,     R2_ohm\n");
     
     wait_ms(START_DELAY);
     timer.start();
@@ -108,8 +108,8 @@
     led_0 = 0;
     led_1 = 1;
     
-    while(!user_1) {
-        while (pc.getcNb()!='p' && !user_0);
+    for (int iStep=0; iStep<N_STEPS; iStep++) {
+
         eTime = timer.read_ms();
     
         for (int iHeater=0; iHeater <2; iHeater++) {
@@ -148,11 +148,10 @@
                 
             //Wait before drivinng other heater
             wait_ms(LOG_INTERVAL/2);
-            wait_us(MEAS_DELAY);
 
         }
         //Write output for iHeater
-        pc.printf("%10d, %10d, %10.6f, %10.6f, %10d, %10d, %10.6f, %10.6f \n", curr[0], v[0], r_adc[0], r_ohm[0], curr[1], v[1], r_adc[1], r_ohm[1]);
+        pc.printf("%5d, %10d, %10d, %10d, %10.6f, %10.6f, %10d, %10d, %10.6f, %10.6f \n", iStep, eTime, curr[0], v[0], r_adc[0], r_ohm[0], curr[1], v[1], r_adc[1], r_ohm[1]);
         
     }