On the PLATO test bench, the DAQ6510 measured temperatures with 4-wire PT100 probes. Here is what you need to do the same from Python, with nothing more than a socket.
The connection: SCPI over TCP, port 5025
The instrument accepts SCPI commands on TCP port 5025, one per line, terminated with a newline:
import socket
class DAQ6510:
def __init__(self, host, port=5025, timeout=60):
self.sock = socket.create_connection((host, port), timeout=timeout)
self.reader = self.sock.makefile("rb")
def write(self, command):
self.sock.sendall((command + "\n").encode("ascii"))
def query(self, command):
self.write(command)
return self.reader.readline().decode("ascii").strip()
daq = DAQ6510("192.168.1.60")
print(daq.query("*IDN?"))
Configuring the channels
Each setting applies to a list of channels. For five 4-wire PT100 probes on channels 101 to 105 of the card:
channels = "(@101:105)"
daq.write("*RST")
daq.write(f'SENS:FUNC "TEMP", {channels}')
daq.write(f"SENS:TEMP:TRAN FRTD, {channels}") # 4-wire RTD
daq.write(f"SENS:TEMP:RTD:FOUR PT100, {channels}")
daq.write(f"SENS:TEMP:UNIT CELS, {channels}")
For thermocouples you change the transducer (SENS:TEMP:TRAN TC) and set the type (SENS:TEMP:TC:TYPE K, for example). The rest of the flow is the same.
Scanning and reading the buffer
Readings are not requested one by one: you define a scan (which channels, how many times and how often), start it, and then collect everything from the buffer.
daq.write('TRAC:MAKE "test", 10000')
daq.write('ROUT:SCAN:BUFF "test"')
daq.write(f"ROUT:SCAN:CRE {channels}")
daq.write("ROUT:SCAN:COUN:SCAN 10") # 10 passes...
daq.write("ROUT:SCAN:INT 5") # ...every 5 seconds
daq.write("INIT")
daq.write("*WAI")
n = int(daq.query('TRAC:ACT? "test"'))
data = daq.query(f'TRAC:DATA? 1, {n}, "test", CHAN, TST, READ')
# channel, timestamp and reading, comma separated
The usual errors
The timeout has to cover the whole scan. *WAI makes the instrument hold every reply until it finishes. With 10 passes every 5 seconds, the next query takes almost a minute: if the program waits less, it fails even though everything is fine. The rule is timeout > passes × interval + the duration of one pass.
A buffer whose name already exists is an error. If the program always creates the same buffer at start-up, the second time the front panel shows error 1115. Either delete it first (TRAC:DEL "test") or reuse it after clearing it (TRAC:CLE).
An empty reply is not a temperature. If the network drops mid-read, what arrives may be incomplete. Check every reply before storing it and retry, rather than logging a false value.
From script to test bench
On a real bench, this scan runs in a loop for hours or days, its data is stored alongside that of the temperature controllers and the rest of the instruments, and someone needs to know when a channel spikes. That is what we build, custom.