Timer


opticaldynamics

Recommended Posts

Just set a global variable to systime() when the cool down starts, and then display 25 * 3600 - (systime() minus that variable) for the amount of time left (in secs). OK:

global starttime = systime() // when the 25 hours starts

the expression for elapsed time (in secs):

(systime() - starttime)

in hours:

(systime() - starttime) / 3600

for remaining time (in hours from 25)

25 - (systime() - starttime) / 3600

Link to comment
Share on other sites

Okay, so how would i incorporate that into my code so it will start as soon as the temperature is 80? my Code looks like this..

using("device.labjack.")
include("c:\program files\labjack\drivers\labjackud.h")//Both lines of code establish connection with LJ

//Declare global variables that will be used throughout sequence
global uppertemp
global setpoint
global synthesistime
global hysteresis
global systime()

//ZnO Synthesis, heat up to a certain temperature (uppertemp)
while(min(controltemp[0,4])<uppertemp)
   ePut(0, LJ_ioPUT_DIGITAL_BIT,6,0,0)//set FI06 to output-low (heater on)
   output=3.6
   delay(1)
endwhile

//Cool to set temp
while(max(internal[0,4])>setpoint)
   eGet(0, LJ_ioGET_DIGITAL_BIT,6,@FI06Reading,0)//set FI06 to input (heater off)
   output=0
   delay(1)
endwhile

//Control for synthesis time
private starttime = systime()
while(systime()<starttime + 3600*synthesistime)//control for 1 hour X synthesis time
   if (internal[0]<setpoint - hysteresis)
	  ePut(0, LJ_ioPUT_DIGITAL_BIT,6,0,0)//heater on
	  output=3.6
   endif
   if (internal[0]>setpoint-1)
	  eGet(0, LJ_ioGET_DIGITAL_BIT,6,@FI06Reading,0)//heater off
	  output=0
   endif
   delay(5)
endwhile


eGet(0, LJ_ioGET_DIGITAL_BIT,6,@FI06Reading,0)//heater off
output=0

Thanks

Link to comment
Share on other sites

Just make your "starttime" variable global instead of private so you can access it from screen components, and replace the 25 with synthesistime in my expressions. Also this line:

global systime()

is invalid. Systime is a reserved function so can't be used as a variable, nor needs to be declared, and putting () in a variable declaration is not valid either. The sequence executor probably just skips over the line.

Link to comment
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.