Simple program for introduction of mirror actuator.

Revision:
10:bfacffec199a
Parent:
8:49ac75c42da0
Child:
11:d43f8b421d6d
--- a/main.cpp	Tue Apr 27 07:50:50 2021 +0000
+++ b/main.cpp	Wed Apr 28 08:26:37 2021 +0000
@@ -19,13 +19,11 @@
 #include "FastPWM.h"
  
 static BufferedSerial serial_port(USBTX, USBRX);
-DigitalIn big_button(PC_3);        // User Button, short and long presses!
-bool key_was_pressed = false;
-float Ts=.0002f;                         // sampling time
+DigitalIn big_button(PC_3);         // Enable button an backside
+bool key_was_pressed = false;       //
+float Ts=.0002f;                    // sampling time
 void pressed(void);
 void released(void); 
-//DigitalOut led1(LED1);
-//DigitalOut led2(LED2);
 //------------- DEFINE FILTERS ----------------
 // missing
 //------------- Define In/Out -----------------
@@ -35,7 +33,6 @@
 //AnalogIn i_act2(PC_0);
 //FastPWM i_des1(PB_10);
 //FastPWM i_des2(PA_15);
-
 DigitalOut i_enable(PC_4);
 DigitalOut laser_on(PB_0);
 ///------------- Encoder -----------------------
@@ -50,37 +47,30 @@
 DiffCounter diff1(0.0005f,Ts,4000);              // discrete differentiate, based on encoder data
 DiffCounter diff2(0.0005f,Ts,4000);              // discrete differentiate, based on encoder data
 //LinearCharacteristics i2pwm(-1.0,1.0,0.02,0.98,.02,.98);
-LinearCharacteristics i2u(-.80,.80,0.02,0.98,0.02,.98);
+LinearCharacteristics i2u(-.80,.80,0.0f,1.0f);
 LinearCharacteristics u2i(0.0,1.0,-1.0,1.0);
 
 Unwrapper_2pi uw2pi1;
 Unwrapper_2pi uw2pi2;
 //------------------------------------------
 // ----- User defined functions -----------
-ControllerLoop loop(Ts);
-uart_comm_thread uart_com(&serial_port,.05f);
-Ticker do_referencing;
-Timer glob_ti;
-path_1d p1;
-path_1d p2;
+ControllerLoop loop(Ts);                        // this is forthe main controller loop
+uart_comm_thread uart_com(&serial_port,.05f);   // this is the communication thread
+Timer glob_ti;                                  // the global timer
+path_1d p1;             // pathplanner (under constr.)
+path_1d p2;             // pathplanner (under constr.)
 path_1d *current_path;
-float A = 2.7;
-float dc=0.0;
-GPA myGPA(5, 2400, 40, 25.0, 25.0, Ts);
+// --------- GPA -----------------------------
+//init values: f0,   f1, nbPts, A0, A1, Ts
+GPA      myGPA(5 , 2400,    40, 25, 25, Ts);
+float exc=0.0;              // excitation GPA
+//------------------------------------------------------------------------------
+// --------- Mirror kinematik, define values, trafos etc there
 Mirror_Kinematic mk;
+//------------------------------------------------------------------------------
+// --------- data: overall data structure for x-change
 DATA_Xchange data;
 
-//GPA myGPA(1, 2500, 100, 30, 20, Ts);
-//GPA myGPA(5, 2500, 80, 0.3, 0.3, Ts);
-
-
-float exc=0.0;              // excitation GPA
-//        f1    f2  N  A1  A2  Ts
-
-// *****************************************************************************
-
-
-
 //******************************************************************************
 //---------- main loop -------------
 //******************************************************************************
@@ -93,34 +83,28 @@
         /* stop bit */ 1
     );
     serial_port.set_blocking(false); // force to send whenever possible and data is there
-    i_enable = 0;               // disable current first
+    i_enable = 0;       // disable current first
     counter1.reset();   // encoder reset
     counter2.reset();   // encoder reset
-    //i_des1.period_ticks(1280);
-    //i_des2.period_ticks(1280);
-    i_enable = 0;
-    mk.set_offsets(1401,1510);
+    mk.set_offsets(1401,1510);          // individal set values for global position
     glob_ti.start();
     glob_ti.reset();
-    printf("Start Mirroractuator 1.0\r\n");
     loop.init_controllers();
-//    uart_com.start_uart();
-//    loop.start_loop();
+    uart_com.start_uart();
+    loop.start_loop();
     i_des1.write(i2u(0));
     i_des2.write(i2u(0));
     ThisThread::sleep_for(200);
     uart_com.send_text((char *)"Start Mirroractuator 1.0");
    /* p1.initialize(300,10,A,0,0,0);
-    p2.initialize(300,10,-A,0,0,A);
+    p2.initialize(300,10,-A,0,0,A);*/
     laser_on = 0;
-
-
     //for(int wk =0;wk<5;wk++)
     while(0)
         {
         short c1 = counter1;            // get counts from Encoder
         short c2 = counter2;            // get counts from Encoder
-        /*current_path = &p1;
+        current_path = &p1;
         current_path->start(glob_ti.read());
         while(!current_path->finished)
             wait(.1);
@@ -129,16 +113,12 @@
         while(!current_path->finished)
             wait(.1);
         ThisThread::sleep_for(100);
-        
-      //  printf("c1,c2: %d %d \r\n",c1,c2);
-
           wait(.25);
-          laser_on = !laser_on;
+         laser_on = !laser_on;
+        }   // end of while(..)
+        i_enable = 0;
+    while(1)
+        {
+        ThisThread::sleep_for(200);
         }
-    i_enable = 0;*/
-    while(1){
-        ThisThread::sleep_for(200);
-        printf("hello\r\n");
-        }
-    
 }   // END OF main