Professional Documents
Culture Documents
Error; int PWR; task main() { SetSensorLight(IN_3); Off(OUT_A); repeat(3) { PlayToneEx(660,200,4,false); Wait(800); } Mid=SENSOR_3; PlayToneEx(780,200,4,false); while(abs(PWR)<1000) { Error=SENSOR_3-Mid; Integral += Error; Derivative=Error-PrevError; PrevError=Error; PWR=(Kp*Error)+(Ki*Integral)+(Kd*Derivative); OnFwd(OUT_BC,PWR); Wait(dt); } Wait(50); Float(OUT_ABC); }