![](/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:
- 1:7f99e938ae2a
- Parent:
- 0:362148ad8f6f
- Child:
- 2:23f848b21b09
diff -r 362148ad8f6f -r 7f99e938ae2a main.cpp --- a/main.cpp Mon Jul 23 13:58:48 2018 +0000 +++ b/main.cpp Mon Jul 23 17:34:20 2018 +0000 @@ -85,7 +85,7 @@ yLED = 0; gLED = 0; - int OSR = 10; + int OSR = 5; drive = 0; drivetime_ms = 1; @@ -127,7 +127,7 @@ rLED = 0; pc.printf("Drive for %d ms\n", drivetime_ms); for (int x=0; x<8; x++){ - voltages[x] = val_array[x]*scale_factors[x]/10000; + voltages[x] = (float)val_array[x]*scale_factors[x]/10000; pc.printf("%f\n", voltages[x]); } cur1 = 2* (voltages[0] - voltages[1]); @@ -136,10 +136,14 @@ R1 = (voltages[4]- voltages[5])/cur1; R2 = (voltages[6]- voltages[7])/cur2; - pc.printf("I1 = %f\n", cur1); - pc.printf("I2 = %f\n", cur2); - pc.printf("R1 = %f\n", R1); - pc.printf("R2 = %f\n", R2); + pc.printf("V0 = %f\n", voltages[0]); + pc.printf("V1 = %f\n", voltages[1]); + pc.printf("V2 = %f\n", voltages[2]); + pc.printf("V4 = %f\n", voltages[4]); + pc.printf("V5 = %f\n", voltages[5]); + pc.printf("V6 = %f\n", voltages[6]); + pc.printf("V7 = %f\n", voltages[7]); + sprintf(outString, "R1, R2, Drive for %d ms, OSR %d\n", drivetime_ms, OSR); fprintf(fp, outString); @@ -157,8 +161,10 @@ cur1 = 2* (voltages[0] - voltages[1]); cur2 = 2* (voltages[2] - voltages[1]); - R1 = (voltages[4]- voltages[5])/cur1; - R2 = (voltages[6]- voltages[7])/cur2; + // R1 = (voltages[4]- voltages[5])/cur1; + // R2 = (voltages[6]- voltages[7])/cur2; + R1 = cur1; + R2 = cur2; sprintf(outString, "%f, %f\n", R1, R2); fprintf(fp, outString); wait_ms(100);