' {$STAMP BS2} ' {$PBASIC 2.5} '====================Declare Variables===================== AcumSeg VAR Byte ' Accumulated seconds AcumMin VAR Byte ' Accumulated Minutes AcumHor VAR Byte ' Accumulated hours Vseg VAR Byte ' seconds in progress Vmin VAR Byte ' Minutes in progress Vhor VAR Byte ' Hours in progress Tvac VAR Byte 'time programmed in vacuum Tozo VAR Byte 'time programmed in ozone Venc VAR Byte 'times that the progam Hill repeat the cycle Test VAR Byte 'This variable is used for a timer in the progam Tvac_t VAR Byte ' dysplay time p/vacuum Tozo_t VAR Byte ' dysplay time p/ozone Venc_t VAR Byte ' dysplay time p/repeat Enc VAR Byte ' Tmin VAR Byte ' Tseg VAR Byte Min_T VAR Byte Seg_T VAR Byte hor_t VAR Byte LcdCls CON $0C LcdOff CON $15 Btn0 PIN 0 Btn1 PIN 1 btn2 PIN 2 btn3 PIN 3 BtnWrk1 VAR Byte BtnWrk2 VAR Byte btnwrk3 VAR Byte btnwrk4 VAR Byte TxPin CON 8 Baud19200 CON 32 '===================initializing====================== HIGH TxPin ' Set pin high to be a serial port PAUSE 100 ' Pause for Serial LCD to initialize Maq_detenida2: 'Shutdown pump and ozone LOW 5 LOW 4 'In this part of the progam you can choose from start the cycle or check the progamed times, see the time that transcured in the cycles and program the times for the cycle SEROUT TxPin, Baud19200, [LcdCls] SEROUT TxPin, Baud19200, [" INICIO:",CR] SEROUT TxPin, Baud19200, ["(o)Ini/Det Si/Arr(o)",CR] SEROUT TxPin, Baud19200, ["(o)Lee/Prg No/Aba(o)"] SEROUT TxPin, Baud19200, [17, 22] LOW 5 'this are the buttoms to select from start or check Maq_detenida: BUTTON Btn0, 0, 255, 100, BtnWrk1, 1, Maq_Prod BUTTON Btn1, 0, 255, 100, BtnWrk2, 1, Prog_Tiempos GOTO Maq_detenida '===================setup====================== 'in this part you can see the progamed time Prog_Tiempos: DEBUG "Tone sending...", CR FREQOUT 15, 100, 2000 READ 9, Tvac, Tozo, Venc SEROUT TxPin, Baud19200, [LcdCls] SEROUT TxPin, Baud19200, [" PARAMETROS:",CR] SEROUT TxPin, Baud19200, [" Vacio:", DEC2 Tvac, CR] SEROUT TxPin, Baud19200, [" Ozono:", DEC2 Tozo, CR] SEROUT TxPin, Baud19200, [" Veces:", DEC2 Venc, CR] 'here you press the buttom to proceed Prog_Tiempos2: PAUSE 10 BUTTON Btn1, 0, 20, 200, BtnWrk2, 1, mostrar_hora BUTTON Btn1, 0, 255, 255, BtnWrk2, 1, Maq_detenida2 GOTO Prog_Tiempos2 'in this part you can see the acummulated time from the cycles mostrar_hora: READ 0, Acumseg, Acummin, Acumhor SEROUT TxPin, Baud19200, [LcdCls] SEROUT TxPin, Baud19200, [" Hrs Acum: ",DEC2 AcumSeg,":",DEC2 Acummin,":", DEC2 Acumhor,CR] FREQOUT 15, 100, 2000 'proceed buttom mostrar_hora2: PAUSE 100 BUTTON Btn1, 0, 255, 222, BtnWrk2, 1, Tvac_o_Programar GOTO mostrar_hora2 Tvac_o_Programar: FREQOUT 15, 100, 2000 WRITE 9, tvac SEROUT TxPin, Baud19200, [LcdCls] 'here u can progam the vacuum time Tvac_o_Programar2: SEROUT TxPin, Baud19200, ["Cambiar", CR] SEROUT TxPin, Baud19200, [" --->T.vacio: ", DEC2 Tvac, CR] SEROUT TxPin, Baud19200, [" T.Ozono: ", DEC2 Tozo, CR] SEROUT TxPin, Baud19200, [" N.Veces: ", DEC2 Venc, CR] BUTTON Btn1, 0, 20, 200, BtnWrk2, 1, Tozo_o_programar BUTTON Btn1, 0, 200, 200, BtnWrk2, 1, Maq_detenida2 BUTTON Btn2, 0, 10, 0, BtnWrk3, 1, Tvac_u BUTTON Btn3, 0, 10, 0, BtnWrk4, 1, Tvac_d GOTO Tvac_o_Programar2 Tvac_u: FREQOUT 15, 100, 2000 tvac=tvac+1 Tvac_d: FREQOUT 15, 100, 2000 tvac=tvac-1 GOTO Tvac_o_Programar2 Tozo_o_programar: SEROUT TxPin, Baud19200, [lcdcls] FREQOUT 15, 100, 2000 'here you can progam the ozone time Tozo_o_programar2: WRITE 10, tozo SEROUT TxPin, Baud19200, ["Cambiar", CR] SEROUT TxPin, Baud19200, [" T.vacio: ", DEC2 Tvac, CR] SEROUT TxPin, Baud19200, [" --->T.Ozono: ", DEC2 Tozo, CR] SEROUT TxPin, Baud19200, [" N.Veces: ", DEC2 Venc, CR] BUTTON Btn1, 0, 20, 200, BtnWrk2, 1, Venc_o_programar BUTTON Btn1, 0, 200, 200, BtnWrk2, 1, Maq_detenida2 BUTTON Btn2, 0, 10, 0, BtnWrk3, 1, Tozo_u BUTTON Btn3, 0, 10, 0, BtnWrk4, 1, Tozo_d GOTO Tozo_o_programar2 Tozo_u: tozo=tozo+1 GOTO Tozo_o_Programar Tozo_d: tozo=tozo-1 GOTO Tozo_o_Programar Venc_o_programar: SEROUT TxPin, Baud19200, [lcdcls] FREQOUT 15, 100, 2000 'here you progam how many times the cycle will repeat Venc_o_programar2: WRITE 11, Venc SEROUT TxPin, Baud19200, ["Cambiar", CR] SEROUT TxPin, Baud19200, [" T.vacio: ", DEC2 Tvac, CR] SEROUT TxPin, Baud19200, [" T.Ozono: ", DEC2 Tozo, CR] SEROUT TxPin, Baud19200, [" --->N.Veces: ", DEC2 Venc, CR] BUTTON Btn1, 0, 20, 200, BtnWrk2, 1, mostrar_hora BUTTON Btn1, 0, 200, 200, BtnWrk2, 1, Maq_detenida2 BUTTON Btn2, 0, 10, 0, BtnWrk3, 1, Venc_u BUTTON Btn3, 0, 10, 0, BtnWrk4, 1, Venc_d GOTO Venc_o_programar2 Venc_u: Venc=Venc+1 GOTO Venc_o_Programar Venc_d: Venc=Venc-1 GOTO Venc_o_Programar '===================main Routine====================== 'In this part the machine will start the progress of vacuum the air from a container, then when it finish the Tvac it begin to fill the container with ozone until it finnish the Tozo, then the cycle starts again until Venc ends. Maq_Prod: DEBUG "Tone sending...", CR FREQOUT 15, 100, 2000 READ 9, Tvac, Tozo, Venc FOR Enc = 1 TO Venc LOW 4 HIGH 5 SEROUT TxPin, Baud19200,["Tiempo de vacio en progreso",CR] Tmin = 0 'Ejecutar tiempo de vacio Tseg = Tvac 'Encender Bomba de vacio GOSUB reloj SEROUT TxPin, Baud19200,["Tiempo de Ozono en progreso",CR] LOW 5 HIGH 4 Tmin = Tozo-1 Tseg = 59 GOSUB reloj NEXT LOW 4 LOW 5 GOTO Maq_detenida2 Reloj: FOR Min_T = 0 TO Tmin FOR Seg_T = 0 TO Tseg No_retornar: SEROUT TxPin, Baud19200, [lcdcls] SEROUT TxPin, Baud19200, [HOME,"Tvac: ", DEC2 Tvac," Tozo: ",DEC2 Tozo, " M. veces: ", DEC2 Venc, CR] IF Tmin = 0 THEN ELSE ENDIF SEROUT TxPin, Baud19200,[ DEC2 Seg_T,":",DEC2 Min_T, " Veces: ", DEC2 Enc] 'I put this delay here so the machine can count a total sec and also you could stop the progess without waiting the machine to stop. Test=0 delay: DEBUG "test =", DEC3 test, HOME test = 1 + test BUTTON Btn0, 0, 255, 20, BtnWrk1, 1, Interr_y_Retornar IF test=60 THEN finish_d GOTO delay finish_d: NEXT NEXT retornar: RETURN Interr_y_Retornar: SEROUT TxPin, Baud19200,[lcdcls] Int_y_ret: SEROUT TxPin, Baud19200,[" Retornar e Reiniciar la maquina?", HOME] escribir: Acumseg=seg_t + acumseg acummin=MIN_t + acummin acumhor=hor_t + acumhor hor_t=0 WRITE 0, Acumseg, Acummin, acumhor Int_y_Ret2: BUTTON Btn2, 0, 255, 20, BtnWrk1, 1, Maq_detenida2 BUTTON Btn3, 0, 255, 20, BtnWrk1, 1, No_retornar GOTO Int_y_Ret2