Simple program for introduction of mirror actuator.

Revision:
8:49ac75c42da0
Parent:
7:942fd77d5e19
Child:
10:bfacffec199a
--- a/main.cpp	Thu Apr 15 05:36:55 2021 +0000
+++ b/main.cpp	Tue Apr 27 07:50:03 2021 +0000
@@ -16,11 +16,12 @@
 #include "Mirror_Kinematic.h"
 #include "data_structs.h"
 #include "uart_comm_thread.h"
+#include "FastPWM.h"
  
 static BufferedSerial serial_port(USBTX, USBRX);
-InterruptIn button(USER_BUTTON);        // User Button, short and long presses!
+DigitalIn big_button(PC_3);        // User Button, short and long presses!
 bool key_was_pressed = false;
-float Ts=.0005f;                         // sampling time
+float Ts=.0002f;                         // sampling time
 void pressed(void);
 void released(void); 
 //DigitalOut led1(LED1);
@@ -30,6 +31,11 @@
 //------------- Define In/Out -----------------
 AnalogOut i_des1(PA_5);
 AnalogOut i_des2(PA_4);
+//AnalogIn i_act1(PA_3);
+//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 -----------------------
@@ -44,14 +50,15 @@
 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(-1.0,1.0,0.0,1.0,0.0,1.0);
+LinearCharacteristics i2u(-.80,.80,0.02,0.98,0.02,.98);
+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,.1f);
+uart_comm_thread uart_com(&serial_port,.05f);
 Ticker do_referencing;
 Timer glob_ti;
 path_1d p1;
@@ -59,11 +66,14 @@
 path_1d *current_path;
 float A = 2.7;
 float dc=0.0;
+GPA myGPA(5, 2400, 40, 25.0, 25.0, Ts);
 Mirror_Kinematic mk;
 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
 
@@ -86,16 +96,20 @@
     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(0,0);
+    mk.set_offsets(1401,1510);
     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);
     laser_on = 0;
@@ -122,7 +136,9 @@
           laser_on = !laser_on;
         }
     i_enable = 0;*/
-    while(1)
-        ThisThread::sleep_for(2000);
+    while(1){
+        ThisThread::sleep_for(200);
+        printf("hello\r\n");
+        }
     
 }   // END OF main