   double neutralAngle = 0.8*potentiometerMaxRange;
   double angle = raw_angle - neutralAngle;
   double correction_m = angle*potentiometerDistance;
-  Input = relative_position_m;
-  Setpoint = StrToFloat(pwm1.value());
-  myPID.Compute();
-}
-    
-
-
-
+  Input1 = relative_position_m/linearRange;
+  Input2 = angle/potentiometerUsedRange;
+  
+  InputRoll = StrToFloat(roll.value());
+
+}
+
+void computeSetpoint()
+{
+  Setpoint1 = StrToFloat(pwm1.value())/127.0;
+  Setpoint2 = StrToFloat(pwm2.value())/127.0;
+  SetpointRoll = StrToFloat(roll.value());
+}
+
+void computePID()
+{
+  myPID1.Compute();
+  myPID2.Compute();
+  myPIDRoll.Compute();
+}
+
+void computePIDTuning()
+{
+  myPID1.SetTunings(StrToFloat(kpm1.value()), StrToFloat(kim1.value()), StrToFloat(kdm1.value()));
+  myPID2.SetTunings(StrToFloat(kpm2.value()), StrToFloat(kim2.value()), StrToFloat(kdm2.value()));
+  myPIDRoll.SetTunings(StrToFloat(kpmr.value()), StrToFloat(kimr.value()), StrToFloat(kdmr.value()));
+
+}
+
+
+

TinyGPSCustom roll     (nmea, "ORKST", 1);  // Kite STate roll (rotation in camera frame)
TinyGPSCustom elevation(nmea, "ORKST", 2);  // Kite STate elevation
TinyGPSCustom bearing  (nmea, "ORKST", 3);  // Kite STate bearing
TinyGPSCustom kpm      (nmea, "ORKPM", 1);  // Proportional coefficient multiplicator
TinyGPSCustom kim	   (nmea, "ORKIM", 1);  // Integral coefficient multiplicator
TinyGPSCustom kdm      (nmea, "ORKDM", 1);  // Derivative coefficient multiplicator

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters (Kp, Ki, Kd)
PID myPID(&Input, &Output, &Setpoint, 1, 1, 1, DIRECT);


//*****************************************************************************//

  if ( micros() - int1time < threshold )
    return;
  int1history = int1signal;
  int1signal = bitRead(PIND, pinB);
  if ( int1history==int1signal )
    return;
  int1time = micros();
