'''Some basic example code for getting and setting the temperature of a chamberRequires chamberconnectlibrary, which is only compatible with python 2Install chamber connect library with pip: pip install chamberconnectlibrary'''importtimefromchamberconnectlibrary.watlowf4timportWatlowF4T#example interface_params for RS232/RS485 on port 7 (windows) Modbus address=1interface_params={'interface':'RTU','baudrate':38400,'serialport':'//./COM7','adr':1}#example interface_params for RS232/RS485 on ttyUSB0 (linux) Modbus address=1interface_params={'interface':'RTU','baudrate':38400,'serialport':'/dev/ttyUSB0','adr':1}#example interface_params for a TCP connection to 10.30.100.86interface_params={'interface':'TCP','host':'10.30.100.86'}#example for temperature only chamber (BTU-??? or BTZ-??? or custom chamber)#The WatlowF4T is highly configurable, the program must know some of this configuration.controller=WatlowF4T(alarms=8,# The number of alarms this chamber has, 8 is correct in 99% of espec chambersprofiles=True,# Does the chamber offer temperature programs (aka profiles), True in 99% of espec chambersloops=1,# The number of control loops, 1 for temperature only chambers, 2 for temperature/humidity.cond_event=9,# The event number that must be "pressed" to turn on the chamber, 9 is correct in all espec chamberscond_event_toggle=False,# Is `cond_event` maintained (True), or momentary(False), False is correct in all espec chambersrun_module=1,# The IO card slot # that contains the main run output for the chamber, 1 is correct in 99% of espec chambersrun_io=1,# The IO output on the IO card that contains the main run output for the chamber, 1 is correct in 99% of espec chamberslimits=[5],# A list of IO card slot #'s that contain a limit type card.**interface_params# The connection parameters defined above.)units=controller.get_loop_units(1)#note this is a unicode string (u'string') not an ascii string ('string')# Print the current temperature in the chamber:# controller.get_loop_pv(1) returns a dictionary with all possible temperature process_values in the chamber.# possible keys:# 'air': The temperature of the air# 'product': The temperature of the product (This is only present on chambers with "product temperature contol")# The process_value is the conditions of the chambertemp_pv=controller.get_loop_pv(1)printu'Current temperature in the chamber: {}{}'.format(temp_pv['air'],units)# Print the target temperature (temperature set point) of the chamber:# controller.get_loop_sp(1) returns a dictionary with all possible temperature set points (targets) in the chamber.# available keys:# 'current': The target temperature of the chamber.# 'constant': The target temperature of the chamber when a program is not running.temp_sp=controller.get_loop_sp(1)printu'Current target temperature of the chamber: {}{}'.format(temp_sp['current'],units)# Set the target temperature (set point) of the chamber to 60.5.# If the chamber is on and not running a program it will try and attain that temperature.# Note that this sets the `constant` parameter read by controller.get_loop_sp(1)controller.set_loop_sp(1,60.5)# Ensure the chamber is on and not running a programcontroller.const_start()# Let the chamber run 60.5 for 10 secondssleep_time=10print'sleeping for {} seconds'.format(sleep_time)time.sleep(sleep_time)# Stop the chamber from runningcontroller.stop()
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.