def runGPID(): gPIDInstance = gPID.gPID() gPIDInstance.ChangeSetPoint(40.0) while True: getCFPval = float(GP.getcFP()) next_PV = gPIDInstance.Compute(getCFPval) print "Present Temp: " + str(getCFPval) + "| nextPV: " + str(next_PV) GP.HeaterControl(next_PV) time.sleep(1)
def RunPIDonce(self, measurement_value): pid_raw = self.pid_control.update(measurement_value) pid = self.Constrain(pid_raw, 0.0, 100.0) sys.stdout.flush() sys.stdout.write("\rPID RAW: %.02f | PID: %.02f | Temperature: %.02f" % (pid_raw, pid, measurement_value)) if measurement_value >= self.pid_control.set_point + 30.0: self.stop() GP.HeaterControl(pid)
def UpdateVars(self): #Update the temperature variables! self.TemperatureData.append(GP.getcFP()) self.TemperatureData.pop(0) self.TrailAvg = np.average(self.TemperatureData[:self.step]) self.LeadAvg = np.average(self.TemperatureData[-self.step:]) #Update Pressure Variable #self.Pressure = GP.getPressure() #Call stability check reactor.callWhenRunning(self.StabilityWrapper) #get PID Value PIDValue = self.gPID.Compute(float(self.LeadAvg)) if int(PIDValue) != int(self.PIDVal): #write PID Value GP.HeaterControl(PIDValue) self.PIDVal = PIDValue
def killall(): GP.HeaterControl(0) reactor.stop()
def stop(self): GP.HeaterControl(0) print "Stopped" sys.exit("Overheat. Stopped.")