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:
12:8c355d78e081
Parent:
11:7a9837acbea0
Child:
13:e08e3540c30b
--- a/main.cpp	Tue May 30 22:41:23 2017 +0000
+++ b/main.cpp	Fri Jun 02 18:14:16 2017 +0000
@@ -59,6 +59,9 @@
 //of the AVAGO encoder with respect to the shaft
 DigitalOut led2(PB_4);
 
+//Relay to power on and off the DCPS
+DigitalOut relay1(PB_5);
+
 //AnalogIn    vref(ADC_VREF);
 //AnalogIn   tempint(ADC_TEMP);
 
@@ -190,6 +193,12 @@
         } else if (strcmp(message, "reset") == 0) {
             TIM2->CNT = 0x0000;
             printf("Encoder reset!\r\n");
+        } else if (strcmp(message, "poweron") == 0) {
+            relay1.write(1);
+            printf("DCPS on\r\n");
+        } else if (strcmp(message, "poweroff") == 0) {
+            relay1.write(0);
+            printf("DCPS off\r\n");
         }
 
     }
@@ -199,7 +208,9 @@
 //The main function
 int main()
 {
-
+    //Power onn the DCPS
+    relay1.write(1);
+    
     //counting on both A&B inputs (A at PA0, B at PA1), 4 ticks per cycle,
     //full 32-bit count
     //For L432KC to work with TIM2 one needs to reassign the system ticker
@@ -211,7 +222,10 @@
     //This is triggered by the encoder's index pulses
     //and it resets the encoder counter
     event.rise(&atint);
-
+    
+    //Set serial baud rate
+    raspi.baud(115200);
+    
     //Attach functin to call for serial interrupt event
     raspi.attach(&readData);