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.

Files at this revision

API Documentation at this revision

Comitter:
tonnyleonard
Date:
Thu Jun 22 02:04:21 2017 +0000
Parent:
21:65f16b24ccd8
Child:
23:5cd74e296f59
Commit message:
Change serial reading keyword for DAC setting from dac= to v=

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jun 21 01:27:13 2017 +0000
+++ b/main.cpp	Thu Jun 22 02:04:21 2017 +0000
@@ -231,10 +231,10 @@
         } else if (strcmp(message, "adcOff") == 0) {
             adc_en = false;
             printf("M:ADC false\n");
-        } else if (p1=strstr(message, "dac=") != NULL) {
+        } else if (p1=strstr(message, "v=") != NULL) {
             //Writing the dac1 value read from serial
             //The DCPS has 1.2V offset, so we have to remove it
-            dac_val = (atof(message+p1+3)-1.2f)/15.9;
+            dac_val = (atof(message+p1+1)-1.2f)/15.9;
             dac1.write(dac_val);
         } else if (strcmp(message, "reset") == 0) {
             //encoder related counters reset command
@@ -305,8 +305,8 @@
 //The main function
 int main()
 {
-    //Power on the DCPS
-    relay1.write(1);
+    //Make sure the DCPS is off
+    relay1.write(0);
     //Set the DCPS output to (0.32x3.3)x4.7+1 = ~6V
     dac1.write(0.32);