Snippets

Espec North America Example for WD

Created by Myles Metzler last modified
'''
Some basic example code for getting and setting the temperature of a chamber

Requires chamberconnectlibrary, which is only compatible with python 2

Install chamber connect library with pip:
    pip install chamberconnectlibrary

'''
import time
from chamberconnectlibrary.watlowf4t import WatlowF4T

#example interface_params for RS232/RS485 on port 7 (windows) Modbus address=1
interface_params = {'interface':'RTU', 'baudrate':38400, 'serialport':'//./COM7', 'adr':1}

#example interface_params for RS232/RS485 on ttyUSB0 (linux) Modbus address=1
interface_params = {'interface':'RTU', 'baudrate':38400, 'serialport':'/dev/ttyUSB0', 'adr':1}

#example interface_params for a TCP connection to 10.30.100.86
interface_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 chambers
    profiles=True,           # Does the chamber offer temperature programs (aka profiles), True in 99% of espec chambers
    loops=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 chambers
    cond_event_toggle=False, # Is `cond_event` maintained (True), or momentary(False), False is correct in all espec chambers
    run_module=1,            # The IO card slot # that contains the main run output for the chamber, 1 is correct in 99% of espec chambers
    run_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 chambers
    limits=[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 chamber
temp_pv = controller.get_loop_pv(1)
print u'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)
print u'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 program
controller.const_start()

# Let the chamber run 60.5 for 10 seconds
sleep_time = 10
print 'sleeping for {} seconds'.format(sleep_time)
time.sleep(sleep_time)

# Stop the chamber from running
controller.stop()

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.