
presentatie versie met potmeters enabled
Dependencies: Encoder HIDScope mbed
Diff: main.cpp
- Revision:
- 9:831891bb0d11
- Parent:
- 8:f2f45be5a060
- Child:
- 10:93a76bd81eef
--- a/main.cpp Thu Oct 29 17:46:33 2015 +0000 +++ b/main.cpp Mon Nov 02 11:55:24 2015 +0000 @@ -44,7 +44,8 @@ bool loop_start = false; bool calib_start = false; bool reset = false; - bool switch_xy = false; + bool program = false; + // LED outputs on bioshield DigitalOut led_right(D2); @@ -61,7 +62,8 @@ // switch axes // bool switch_xy = false; // bool for switching axes double sw1 = 0; // counter for switching axes - double t_switch = 0.6; // seconds for switching + double t_switch = 0.8; // seconds for switching + bool switch_xy = false; // physical constants const double L = 36; // lenght of arms @@ -110,7 +112,7 @@ double phi_two_curr = 0; // REFERENCE SETTINGS - double input_threshold = 0.25; // the minimum value the signal must have in order to change the reference. + double input_threshold = 0.5; // the minimum value the signal must have in order to change the reference. // Define storage variables for reference values (also start position) double c_reference_x = 60, c_reference_y = 0; // x-settings (no y-settings because these are calculated from the current x-position) @@ -442,8 +444,8 @@ double xy_input2 = output2_amp; // use potmeter for debugging purposes (note: does not give a smooth signal due to mechanical breakdown) - //xy_input1 = potright.read(); - //xy_input2 = potleft.read(); + xy_input1 = potright.read(); + xy_input2 = potleft.read(); // add a threshold to the signals and limit to [0,1] xy_input1 = adapt_signal(xy_input1); @@ -453,8 +455,7 @@ switch_axes(xy_input1,xy_input2); double xy_main_input = xy_input1 - xy_input2 ; // subtract inputs to create a signal that can go from -1 to 1 - - //scope.set(0,xy_main_input); + // limit the output between -1 and 1 (signal is not supposed to be able to go above but last check) if(xy_main_input>1) {xy_main_input = 1;} if(xy_main_input<-1) {xy_main_input = -1;} @@ -474,7 +475,7 @@ if(switch_xy == true){yy = reference_f(xy_main_input,c_reference_y,y_min,y_max,Vmax_y);} // start the pre-programmed movement - // square_move(); + // if(program){square_move();} // check the references (otherwise unwanted behavior) //if(yy < y_min){yy = y_min;} @@ -512,11 +513,6 @@ phi_one = reset_phi_one; phi_two = reset_phi_two; } - - scope.set(0,yy); - scope.set(1,y_min); - scope.set(2,y_max); - scope.send(); }