Bi ara bunu yazmıştım, bazı uygulamalarda kullanışlı olabiliyor, ilgilenenlerin işine yarayabilir. #More information: http://en. wikipedia. org/wiki/PID_controller # #cnr437@gmail.com # Example # #p=PID(3.0,0.4,1.2) #p. setPoint(5.0) #while True: # pid = p. update # # class PID: """ Discrete PID control """ def init (self, P=2.0, I=0.0, D=1.0, Derivator=0, Integrator=0, Integrator_max=500, Integrator_min=-500): self. Kp=P self. Ki=I self. Kd=D self. Derivator=Derivator self. Integrator=Integrator self. Integrator_max=Integrator_max self. Integrator_min=Integrator_min self. set_point=0.0 self. error=0.0 def update : """ Calculate PID output value for given reference input and feedback """ self. error = self. set_point - current_value self. P_value = self. Kp self. error self. D_value = self. Kd self. Derivator = self. error self. Integrator = self. Integrator + self. error if self. Integrator > self. Integrator_max: self. Integrator = self. Integrator_max elif self. Integrator < self. Integrator_min: self. Integrator = self. Integrator_min self. I_value = self. Integrator self. Ki PID = self. P_value + self. I_value + self. D_value return PID def setPoint : """ Initilize the setpoint of PID """ self. set_point = set_point self. Integrator=0 self. Derivator=0 def setIntegrator : self. Integrator = Integrator def setDerivator : self. Derivator = Derivator def setKp : self. Kp=P def setKi : self. Ki=I def setKd : self. Kd=D def getPoint : return self. set_point def getError : return self. error def getIntegrator : return self. Integrator def getDerivator : return self. Derivator Bizim olduğumuz her yerde herşey bizim yüzümüzden olmuştur. Ben benim amk bana bişey olmasın!