Hello! I don't have much experience with kOS, and am basically new to programming, but i'm figuring things out. At the moment, I'm trying to write my own automated plane pilot, using raw controls, but i ran into a problem. I am passing a desired pitch of the craft(pitch above horizon) to my script andd it adjustes the control surfaces to achieve this pitch via a PID loop. The problem with this is the PID tuning. It either works super slowly, but stable, or works faster, but becomes unstable at higher altitudes. When i look at the cooked controls, and see how well and quickly they react, it comes to my mind that there must be a better way:). Could someone pass me an idea how to counter this problem? My script is this(i hope it's ok to post it here): clearscreen. //Attitude Control - Vectors lock fore to ship:facing:vector. lock aft to (-fore). lock up to ship:up:vector. lock rightrot to ship:facing * r(0,90,0). lock right to rightrot:vector. lock left to -1*right. lock top to vcrs(fore,right). lock bottom to -1*top. lock righthor to vcrs(fore,up). lock lefthor to -1*righthor. lock forehor to vcrs(right,up). lock afthor to (-forehor). //Attitude Control - Angles lock absaoa to vang(fore,srfprograde:vector). lock aoa to vang(top,srfprograde:vector)-90. lock sideslip to vang(right,srfprograde:vector)-90. lock pitchangle to vang(fore,forehor)*((90-vang(fore,up))/abs(90-vang(fore,up))). lock rollangle to vang(left,righthor)*((90-vang(top,righthor))/abs(90-vang(top,righthor))). //roll angle, 0 at level flight set wantpitch to pitchangle. set wantroll to 0. set k to 1. on ag3 {set k to k + 0.1. preserve.}. on ag4 {set K to K - 0.1. preserve.}. on ag7 {set wantpitch to wantpitch + 1. Preserve.} on ag8 {set wantpitch to wantpitch - 1. Preserve.} on ag5 {set wantroll to wantroll + 1. Preserve.} on ag6 {set wantroll to wantroll - 1. Preserve.} set kpi to 0.001 * k. //pitchgains set kpp to 0.02 * k. set kpd to 0.002 * k. when ship:altitude > 100000 then {set kpi to 0.005. when ship:altitude > 15000 then {set kpi to 0.003. when ship:altitude > 20000 then {rcs on. preserve.}. preserve.}. preserve.}. set kri to 0. //rollgains set krp to 0.05. set krd to 0.05. set Ep to wantpitch - pitchangle. if Ep > 10 {set Ep to 10.}. set Epo to Ep. Set Ip to 0. set T to time:seconds. set Er to wantroll - rollangle. if Er > 10 {set Er to 10.}. set Ero to Er. Set Ir to 0. wait 0.05. until false{ set Ep to wantpitch - pitchangle. if Ep > 10 {set Ep to 10.}. set dt to time:Seconds - T. set Dp to kpd*(Ep-Epo)/dt. set Pp to kpp*Ep. set Ip to Ip + kpi*(Ep+Epo)*dt. if Ip > 1 {set Ip to 1.}. set ship:control:pitch to Pp+Ip+Dp. set Epo to Ep. set Er to rollangle - wantroll. set Pr to krp*Er. set Ir to Ir + kri*(Er+Ero)*dt. if Ir > 1 {set Ir to 1.}. set Dr to krd*(Er-Ero)/dt. set ship:control:roll to (Pr+Ir+Dr). print "K= " + K at(0,15). print "Pp= " + round(Pp,5) at(0,19). print "Dp= " + round(Dp,5) at(0,20). print "Ip= " + round(Ip,5) at(0,21). print "pitchcontrol= " + 100*round(ship:control:pitch,3) +"%" at(0,22). print "Pitchangle= " + round(pitchangle,2) at(0,23). print "Wantpitch = " + round(wantpitch,2) at(30,23). Print "Ep= " + round(Ep,2) at(0,24). print "Pr= " + round(Pr,5) at(0,26). print "Dr= " + round(Dr,5) at(0,27). print "Ir= " + round(Ir,5) at(0,28). Print "Er= " + round(Er,2) at(0,29). print "Rollangle= " + round(rollangle,2) at(0,30). print "Wantroll= " + round(wantroll,2) at(30,30). set Ero to Er. set T to time:seconds. wait 0.05. } I am using FAR by the way. Thanks in advance