Rotork Research Team / Mbed 2 deprecated TFM_Encoder

Dependencies:   mbed QEI

Revision:
18:3493de6fe8ce
Parent:
17:19b2c598810a
Child:
19:d9ba2f225f39
--- a/main.cpp	Wed Apr 03 10:46:47 2019 +0000
+++ b/main.cpp	Wed Apr 03 13:31:43 2019 +0000
@@ -51,8 +51,6 @@
 int CW = 57;
 int ACW = 12;
 int TimePerClick = 0;                                   //for calc of RPM
-int RPS = 0;                                            //for calc of RPM
-int rpm = 0;                                            //for calc of RPM
 int SetPoint = 1000;                                     //for adjusting the speed
 int enc = 3200;                                         //800 x4 enc = 3200 Pulses Per Rev
 int i = 0;
@@ -65,9 +63,12 @@
 int z = 3200;                                           //TimePerRev = TimePerClick * (3200/z); 3200 pulses per rev, PulseCount2_==3200 for wheel.getwhoop_ flag. i.e. 1 points per reoluition for RPM calc.
 int T = 80;                                             //Motor temp limit
 int slowloop = 0;
+int StartUp = 1;
      
 char c;                                                 //keyboard cotrol GetChar
 
+float RPS = 0;                                            //for calc of RPM
+float rpm = 0;                                            //for calc of RPM
 float duty   =   1;                                    
 float diff = 0.0;                                       //Velocity loop: diff = SetPoint - rpm;
 float AdjDiff = 0.0001;
@@ -182,7 +183,7 @@
         while((led1 == 0) && (led2 == 0))               //If no command to operate
         {
             //Aout = 0;
-            //duty = 0.7;        
+            duty = 0.7;        
             rpm = 0;
             AdjCW = CW;
             AdjACW = ACW;
@@ -607,27 +608,27 @@
 {
         Ph4();
         wait(x);
-        //pc.printf("4 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
-        Ph34(); 
-        wait(y);
+        pc.printf("4 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
+        //Ph34(); 
+        //wait(y);
         //pc.printf("34 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
         Ph3();
         wait(x);
-        //pc.printf("3 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
-        Ph23();
-        wait(y);
+        pc.printf("3 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
+        //Ph23();
+        //wait(y);
         //pc.printf("23 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
         Ph2();
         wait(x);
-        //pc.printf("2 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
-        Ph12();
-        wait(y);
+        pc.printf("2 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
+        //Ph12();
+        //wait(y);
         //pc.printf("12 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
         Ph1();
         wait(x);
-        //pc.printf("1 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
-        Ph41();
-        wait(y); 
+        pc.printf("1 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());
+        //Ph41();
+       // wait(y); 
         //pc.printf("41 StateA= %i, Pulses= %i, Revs= %i\n\r", StateA,wheel.getPulses(),wheel.getRevolutions());          
 }
 
@@ -764,6 +765,10 @@
             {
                 StepACW();
             }
+             if(c == '7')
+            {
+                pc.printf("TimePerClick = %i, TimePerRev = %.5f, RPS = %.5f, rpm = %.5f,  \n\r", TimePerClick, TimePerRev, RPS, rpm);
+            }
             if(c == 'z')                            //turn on led1 causes CW operation
             {
                 led1 = !led1;
@@ -1041,8 +1046,8 @@
 
 void VelocityLoop (void)
 {
-    diff = SetPoint - rpm;                   //difference between setpoint and the RPM measurement
-    duty = duty + (diff*AdjDiff);           //0.00001 when change required at fast rpm. 0.001 when changes required at slow rpm. duty is adjusted to speed up or slow down until difference = 0  
+        diff = SetPoint - rpm;                   //difference between setpoint and the RPM measurement
+        duty = duty + (diff*AdjDiff);           //0.00001 when change required at fast rpm. 0.001 when changes required at slow rpm. duty is adjusted to speed up or slow down until difference = 0  
     /*if (duty < 0.8)
     {
         j = 0;