Skip to content

Commit f7a2b6b

Browse files
committed
Added Controlling Thermal Platform Temperature example
1 parent 0d071f6 commit f7a2b6b

File tree

6 files changed

+211
-0
lines changed

6 files changed

+211
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Some sequences involve graphing measurement results. To properly graph results,
2828
### Installing PyCLibrary Package
2929
Some sequences require external C resources, and requires the [PyCLibrary](https://pyclibrary.readthedocs.io/en/latest/) library. To install this library, enter the command `python -m pip install pyclibrary`. Once the PyCLibrary library is installed, each sequence that involves external C resources can be run as a standalone Python file.
3030

31+
### Installing pyserial Package
32+
Some sequences involve connecting to a serial interface instrument and requires the [pyserial](https://pypi.org/project/pyserial/) library (version 3.5 or greater). Use the command `python -m pip install pyserial` to install the latest version of pyserial. Once the pyserial library is installed, each sequence that involves a serial interface can be run as a standalone Python file.
33+
3134
### General Usage
3235
For most examples, you may need to modify the specified IP address within a sequence to match the IP address that is physically set on your SpikeSafe's DIP switch. In each sequence, the default IP address of 10.0.0.220 is set in the line `ip_address = '10.0.0.220'`.
3336

application_specific_examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
These sequences address specific scenarios in which SpikeSafe functionality is used in an integrated test system, or scenarios where more advanced SpikeSafe settings need to be tuned to meet specific criteria. These sequences are for users that are comfortable with the basic functionality of the SpikeSafe PRF or PSMU. See individual folders' descriptions for more information on each sequence.
44

55
## Directory
6+
- [Controlling Thermal Platform Temperature](controlling_thermal_platform_temperature)
67
- [Fixed Pulse Count Using Software Timing](fixed_pulse_count_using_software_timing)
78
- [Making Tj Measurements](making_tj_measurements)
89
- [Measuring DC Staircase Voltages](measuring_dc_staircase_voltages)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Goal:
2+
# Use TEC to ramp up to 50°C, stabilize, and run for 10 minutes; then ramp down to 25°C, stabilize, and run for 10 minutes.
3+
4+
import logging
5+
import sys
6+
import time
7+
from datetime import datetime, timedelta
8+
from SerialInterface import SerialInterfaceDll
9+
from time import sleep
10+
11+
### set these before starting application
12+
set_temperature_one = 50
13+
set_temperature_one_stability_minutes = 10
14+
set_temperature_two = 25
15+
set_temperature_two_stability_minutes = 10
16+
17+
### setting up sequence log
18+
log = logging.getLogger(__name__)
19+
logging.basicConfig(filename='SpikeSafePythonSamples.log',format='%(asctime)s, %(levelname)s, %(message)s',datefmt='%m/%d/%Y %I:%M:%S',level=logging.INFO)
20+
21+
### start of main program
22+
try:
23+
log.info("ControllingThermalPlatformTemperature.py started.")
24+
25+
TEC_controller = SerialInterfaceDll()
26+
27+
# Set the beep enable sound
28+
TEC_controller.write_command("BEEP 1")
29+
30+
# Set the mount type to 284 TEC High Power LaserMount.
31+
# Will default sensor type, sensor coefficients, gain, fan mode, and current limit
32+
TEC_controller.write_command("TEC:MOUNT 284")
33+
34+
# Set temperature control mode
35+
TEC_controller.write_command("TEC:MODE:T")
36+
37+
# Set the heat/cool mode to both
38+
TEC_controller.write_command("TEC:HEATCOOL BOTH")
39+
40+
# Set the low set temperature limit to 10°C
41+
TEC_controller.write_command("TEC:LIMit:TLO 10")
42+
43+
# Set the high set temperature limit to 85°C
44+
TEC_controller.write_command("TEC:LIMit:THI 85")
45+
46+
# Set platform tolerance to be within 0.5°C of set point for 30 seconds
47+
TEC_controller.write_command("TEC:TOLerance 0.5, 30")
48+
49+
##### Target temperature 1
50+
51+
# Set set temperature to set_temperature_one
52+
TEC_controller.write_command("TEC:T {0}".format(set_temperature_one))
53+
54+
# Set controller output to on
55+
TEC_controller.write_command("TEC:OUT 1")
56+
57+
# Monitor until TEC is in tolerance
58+
while True:
59+
TEC_out_of_tolerance = TEC_controller.write_command("TEC:COND?")
60+
if TEC_controller.isKthBitSet(TEC_out_of_tolerance, 9) == True:
61+
break
62+
63+
# Let TEC temperature stabilize while in tolerance
64+
TEC_stability_start_time = time.time()
65+
while True:
66+
TEC_out_of_tolerance = TEC_controller.write_command("TEC:COND?")
67+
if ((TEC_controller.isKthBitSet(TEC_out_of_tolerance, 9) == True) and
68+
(time.time() - TEC_stability_start_time - 30 >= set_temperature_one_stability_minutes * 60)):
69+
break
70+
else:
71+
break
72+
73+
# Set set temperature to set_temperature_two
74+
TEC_controller.write_command("TEC:T {0}".format(set_temperature_two))
75+
76+
##### Target temperature 2
77+
78+
# Monitor until TEC is in tolerance
79+
while True:
80+
TEC_out_of_tolerance = TEC_controller.write_command("TEC:COND?")
81+
if TEC_controller.isKthBitSet(TEC_out_of_tolerance, 9) == True:
82+
break
83+
84+
# Let TEC temperature stabilize while in tolerance
85+
TEC_stability_start_time = time.time()
86+
while True:
87+
TEC_out_of_tolerance = TEC_controller.write_command("TEC:COND?")
88+
if ((TEC_controller.isKthBitSet(TEC_out_of_tolerance, 9) == True) and
89+
(time.time() - TEC_stability_start_time - 30 >= set_temperature_two_stability_minutes * 60 * 60)):
90+
break
91+
else:
92+
break
93+
94+
##### Disconnect
95+
TEC_controller.close()
96+
97+
log.info("ControllingThermalPlatformTemperature.py completed.\n")
98+
99+
except Exception as err:
100+
# print any general exception to both the terminal and the log file, then exit the application
101+
error_message = 'Program error: {}\n'.format(err)
102+
log.error(error_message)
103+
print(error_message)
104+
sys.exit(1)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Example for Controlling Thermal Platform Temperature using a Thermal Controller
2+
3+
## **Purpose**
4+
In this sequence, we will address how to control a thermal platform's temperature using a thermal controller in an integrated system. A thermal controlled platform is often used in LED/laser systems to control DUT temperature for taking precise junction temperature (Tj) measurements, and stabilizing temperature-controlled environments.
5+
6+
## Overview
7+
Operates a thermal controller (Arroyo 5400 Series TECSource) to control a thermal platform (Arroyo TEC 284 Series High Power LaserMount). The controller will have the platform to ramp up to 50°C, stabilize, and run for 10 minutes; then ramp down to 25°C, stabilize, and run for 10 minutes.
8+
9+
Install the libraries listed in the [Considerations](#considerations) section of this document. More information on TECSources can be found [here](https://www.arroyoinstruments.com/categories/temperature-controllers) and LaserMounts [here](https://www.arroyoinstruments.com/categories/lasermounts).
10+
11+
## Key Settings
12+
The following settings are configured by default. At the top of the sequence, there are multiple lines corresponding to individual test parameters. These lines may be modified to match the necessary parameters for your specific LED or Laser.
13+
14+
### Thermal Controller Settings
15+
- **Set Temperature One:** 50°C
16+
- **Set Temperature One Stability Time:** 10 minutes
17+
- **Set Temperature Two:** 25°C
18+
- **Set Temperature Two Stability Time:** 10 minutes
19+
20+
## Considerations
21+
- This sequence involves connecting to a serial thermal controller using RS-232 interface and requires the [pyserial](https://pypi.org/project/pyserial/) library. See instructions on installing this library under the "Usage" section in the [SpikeSafePythonSamples markdown file](/README.md#installing-pyserial-package).
22+
23+
## Expected Results
24+
After initializing the thermal controller, the thermal controller will ramp up to Set Temperature One at 50°C and stabilize for 10 minutes. Afterwards the thermal controller will ramp down to Set Temperature Two at 25°C and stabilize for 10 minutes.
25+
26+
## Useful Products for Controlling Thermal Platform Temperature using a Thermal Controller
27+
28+
Vektrex [Control Panel Software Application](https://www.vektrex.com/software-applications/control-panel/) provides a user interface to easily perform Tj measurements in minutes. Control Panel provides control over SpikeSafe current output, Voltage Digitizer measurements, and graphing tools such as a time square-root graphing and line-of-best-fit y-axis extrapolation in order to programmatically determine Vf(0). See the figure below:
29+
30+
![](control_panel_tj_screenshot.png)
31+
32+
For more information regarding Vektrex Control Panel, contact [email protected].
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import serial
2+
import serial.tools.list_ports as port_list
3+
from time import sleep
4+
5+
class SerialInterfaceDll(object):
6+
7+
def __init__(self, port=None, baudrate=38400, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0, write_timeout=0, command_delay=0.1):
8+
self.port = port
9+
self.baudrate = baudrate
10+
self.parity = parity
11+
self.stopbits = stopbits
12+
self.bytesize = bytesize
13+
self.timeout = timeout
14+
self.write_timeout = write_timeout
15+
self.command_delay = command_delay
16+
17+
if port == None:
18+
ports = list(port_list.comports())
19+
for p in ports:
20+
print (p)
21+
# Choosing COM port from list of available connections
22+
if "USB Serial Port" in p[1]:
23+
try:
24+
self.port = p[0]
25+
# Setting up and connecting to device
26+
self.ser = serial.Serial(port = self.port,
27+
baudrate = self.baudrate,
28+
parity = self.parity,
29+
stopbits = self.stopbits,
30+
bytesize = self.bytesize,
31+
timeout = self.timeout,
32+
write_timeout = self.write_timeout)
33+
if self.ser.is_open:
34+
print("\n" + self.port + " has been opened.\n")
35+
self.ser.write(b'*IDN? \r\n')
36+
sleep(0.1)
37+
print(bytes.decode(self.ser.read(256)))
38+
else:
39+
print("\nDid not connect to " + self.port + "\n")
40+
return
41+
except:
42+
print("Failed to connect to " + p[0])
43+
else:
44+
self.ser = serial.Serial(port = self.port,
45+
baudrate = self.baudrate,
46+
parity = self.parity,
47+
stopbits = self.stopbits,
48+
bytesize = self.bytesize,
49+
timeout = self.timeout,
50+
write_timeout = self.write_timeout)
51+
52+
53+
def close(self):
54+
self.ser.close()
55+
sleep(self.command_delay)
56+
if not self.ser.is_open:
57+
print("\n" + self.port + " has been closed.\n")
58+
return
59+
60+
def write_command(self,command):
61+
response = None
62+
self.ser.write(str.encode(command) + b'\r\n')
63+
sleep(self.command_delay)
64+
response = bytes.decode(self.ser.read(256))
65+
return(response)
66+
67+
def isKthBitSet(self, n, k):
68+
if n & (1 << (k - 1)):
69+
return True
70+
else:
71+
return False
145 KB
Loading

0 commit comments

Comments
 (0)