A program to monitor some parameters for a motor

Dependencies:   mbed-dev BufferSerial

Thanks to David Lowe for https://developer.mbed.org/users/gregeric/code/Nucleo_Hello_Encoder/ which I adapted for the use of TIM2 32bit timer as an encoder reader on the Nucleo L432KC board.

Revision:
20:f62feecc8334
Parent:
19:51075c725004
Child:
21:65f16b24ccd8
--- a/main.cpp	Sat Jun 17 21:04:42 2017 +0000
+++ b/main.cpp	Sun Jun 18 21:20:00 2017 +0000
@@ -97,7 +97,7 @@
 
 //Array with adc1, adc2 & adc3 correction addition,
 //experimentally determined (hardware offset voltage dependent)
-const float adc_corr[] = { 0, 0.022f, 0.2995, 0.0267};
+const float adc_corr[] = { 0, 0.022f, 0.062f, 0.022f};
 
 //Enable ADC reading and printing to the serial interface
 bool adc_en = true;
@@ -173,7 +173,7 @@
 
     //The speed computation method adapts to slow/fast speeds, in order to
     //optimize the rapport between computation precision and time windows size
-    while (pos2 == pos1 && i<49) { // The accepted max delay time is 0.5 seconds
+    while (pos2 == pos1 && i<9) { // The accepted max delay time is 0.1 seconds
         //wait_ms(10);
         // Avoiding wait(), since it uses interrupts and timing here
         // is not critical. This takes 10 ms, if not interrupted
@@ -373,8 +373,9 @@
         if (adc_en) {
             //Print phase shift in Degrees, DCPS output voltage in Volts
             // and current intensity in Ampers
-            printf("F:%3.3fU:%3.3fI:%3.3f", (3.3f*ADC_read(adc1)+0.022f)*125.62f,
-                   (3.3f*ADC_read(adc2)+0.062f)/0.207f, 3.3f*ADC_read(adc3)+0.022f);
+            printf("F:%3.3fU:%3.3fI:%3.3f", (3.3f*ADC_read(adc1)+adc_corr[1])*125.62f,
+                   (3.3f*ADC_read(adc2)+adc_corr[2])/0.207f, 
+                    3.3f*ADC_read(adc3)+adc_corr[3]);
             //Print DCPS output voltage in Volts
             //printf("U:%3.3f%", (3.3f*ADC_read(adc2)+0.062f)/0.207f);
             //Print current intensity in Ampers