Thomas Burgers / Mbed 2 deprecated ZZ-TheChenneRobot

Dependencies:   Encoder HIDScope MODSERIAL QEI biquadFilter mbed

Revision:
17:aa167ab3cf75
Parent:
16:a8d2c721cf56
Child:
18:6c065915f474
--- a/main.cpp	Thu Oct 08 10:26:03 2015 +0000
+++ b/main.cpp	Thu Oct 08 10:32:07 2015 +0000
@@ -24,6 +24,7 @@
 volatile bool looptimerflag;
 const double  cw=0;                     // zero is clockwise (front view)
 const double  ccw=1;                    // one is counterclockwise (front view)
+double reference_turn = 0;
 
 const double Gain_P_turn=0.0067; 
                     // stel setpoint tussen (0 en 360) en position tussen (0 en 360)
@@ -96,6 +97,12 @@
              pwm_motor_turn = 0.5f;       // motorspeed            
              pc.printf("positie = %d \r\n", motor_turn.getPulses()); }
              
+        // Change Reference button
+         if (buttonL1.read() < 0.5){      //if button pressed
+             pc.printf("Reference after = %d \r\n", Reference);
+             change_reference_positive(Reference_turn)                 
+             pc.printf("Reference after = %d \r\n", Reference); }       
+             
         // Wait until looptimer flag is true then execute PID controller.  
         else
             {
@@ -104,7 +111,7 @@
         looptimerflag = false;
         
         //reference = (potmeter.read()-0.5)*2000;  // Potmeter bepaald reference (uitgeschakeld) 
-        reference_turn = 15;
+        //reference_turn = 15; //BOVENAAN IN SCRIPT GEPLAATST
         
         // Keep motor position between -4200 and 4200 counts
         if ((motor_turn.getPulses()>4200) || (motor_turn.getPulses()<-4200)) // If value is outside -4200 and 4200 (number of counts equal to one revolution) reset to zero
@@ -213,4 +220,10 @@
 //void get_sample() // HIDSCOPE sample fuction
 //{
 //    get_sample = 1;
-//}
\ No newline at end of file
+//}
+
+
+void change_reference_positive (double Reference)
+{
+    Reference=Reference+45;
+}
\ No newline at end of file