Exemple #1
0
def switch_on_the_heating_without_a_pump():
    global x
    x = 100
    wait()
    pump.off()
    three_way_valve.open(x)
    the_state_of_the_heating_system()
Exemple #2
0
def turn_off_the_heating():
    global x
    x = 0
    wait()
    three_way_valve.open(x)
    pump.off()
    the_state_of_the_heating_system()
Exemple #3
0
# create our pump "object"
print('[INFO]: Initialize the pump')
pump.init(PUMP_GPIO_PIN)

# check the pin
print('[INFO]: Check pump pin')
pump_pin = pump.pin()
print('        Pump is set up to use pin: {pin}'.format(pin=pump_pin))

# prime the pump (seconds)
print('[INFO]: Prime pump')
PRIME_TIME = 10
pump.prime(PRIME_TIME)
print('[INFO]: Pump OFF')
pump.off()
sleep(3)

# test on / off / toggle
print('[INFO]: Pump ON')
pump.on()
sleep(3)
print('[INFO]: Pump OFF')
pump.off()
sleep(3)
print('[INFO]: Pump Toggle (ON)')
pump.toggle()
sleep(3)
print('[INFO]: Pump Toggle (OFF)')
pump.toggle()
sleep(10)
Exemple #4
0
# imports
import CarRun2 as m
import pump as p
from time import sleep

# init
m.motor_init()
p.init(25)

# prime the pump (seconds)
print('[INFO]: Prime pump...')
PRIME_TIME = 10
p.prime(PRIME_TIME)
print('[INFO]: Pump OFF')
p.off()
sleep(3)

# Move Around ##################################
print('[INFO]: Move NORTH')
m.run(1) # north
sleep(1)

print('[INFO]: Pump Toggle (ON)')
p.toggle() # pump on
sleep(1)

print('[INFO]: Face WEST')
m.spin_left(1) # face west 
sleep(1)
Exemple #5
0
def main():
    setLight(50000, 512)
    # Target Temperature
    targetTemp = 19.0

    P = 1.2
    I = 1
    D = 0.4

    # PID Parameters
    integralTerm = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

    #Initial PID measures
    print("targetTemp: %s " % targetTemp)

    PIDOut, pastError = TempPID(0, 0, integralTerm, targetTemp, P, I, D)

    #Setup download
    webUpload.targetTempDownload()
    webUpload.PDownload()
    webUpload.IDownload()
    webUpload.DDownload()

    webUpload.targetTempUpload(targetTemp)

    webUpload.pUpload(P)
    webUpload.iUpload(I)
    webUpload.dUpload(D)

    while True:
        #Each cycle is 30 seconds
        second = utime.localtime()[5]
        minute = utime.localtime()[4]
        print(utime.localtime())
        if second % 30 == 0:

            #Measure
            pump.pwm(0)
            setLight(50000, 512)

            time.sleep(0.5)

            inten = intensity()
            temp = getTemp()

            #PID Controls
            PIDOut, pastError = TempPID(temp, pastError, integralTerm,
                                        targetTemp, P, I, D)
            integralTerm.append(pastError)
            integralTerm.pop(0)
            pwmpump, cooler = pidMap(PIDOut)

            try:
                # Webupload and Oled
                OLEDMessage(temp, inten, PIDOut, pwmpump, cooler)
                webUpload.both(temp, inten, PIDOut, pwmpump, cooler)
            except Exception as e:
                print("Error: " + str(e))
                print("Pump: " + pwmpump)
                print("Cooler: " + cooler)

        elif second % 15 == 0:
            print("Starting Downloads... \n")

            try:
                targetTemp = webUpload.targetTempDownload2()
                P = webUpload.PDownload2()
                I = webUpload.IDownload2()
                D = webUpload.DDownload2()

            except OSError as e:
                print(e)
                print("Error in download")

            print("Current target temperature is: " + str(targetTemp))
            print("Current P is: " + str(P))
            print("Current I is: " + str(I))
            print("Current D is: " + str(D))
            print(utime.localtime())
            print("\n")

        if minute % 4 == 0 and second == 20:
            try:
                do_connect()
                print("Refreshing...")
                webUpload.targetTempdisconnect()
                webUpload.PDisconnect()
                webUpload.IDisconnect()
                webUpload.DDisconnect()

                time.sleep(1)

                webUpload.targetTempDownload()
                webUpload.PDownload()
                webUpload.IDownload()
                webUpload.DDownload()

                time.sleep(1)

                webUpload.pUpload(P)
                webUpload.iUpload(I)
                webUpload.dUpload(D)

                print("Done \n")
            except Exception as e:
                print(e)
                print("Refreshing Error")

        if minute == 1 and second == 12:
            pump.forwards()
        elif minute == 3 and second == 12:
            pump.off()
        elif minute == 4 and second == 12:
            pump.backwards()
        elif minute == 6 and second == 12:
            pump.off()

        time.sleep(1)