On the PLATO test bench, the SC10 shutter decided when light reached the camera, so its state had to be reliable. This is what you need to know to integrate it.
The connection
Over its serial port (or the USB, which shows up as a serial port), at 9600 baud, with commands terminated by a carriage return (\r), not a line feed.
The echo: every reply comes twice
The SC10 first sends back the command it received, with its prompt in front, and then the reply. If the program reads only once, it takes the echo for the answer; on the next query it reads the previous reply, and from then on everything is out of step. You have to read twice:
import serial
sc10 = serial.Serial("/dev/ttyUSB0", 9600, timeout=1)
def query(command):
sc10.reset_input_buffer()
sc10.write((command + "\r").encode("ascii"))
sc10.read_until(b"\r") # the echo of the command
return sc10.read_until(b"\r").decode("ascii").strip()
print(query("id?")) # model and version
Open is not a command
In manual mode, the shutter is opened and closed with ens, which toggles the state: if it was closed it opens, and if it was open it closes. There is no “open” and no “close”. Sending ens twice by mistake leaves the shutter the opposite way round from what the test believes.
That is why the state is always read before changing it, with ens?, which returns 1 when enabled:
def is_open():
return query("ens?") == "1"
def set_open(open_it):
if is_open() != open_it:
sc10.write(b"ens\r")
sc10.read_until(b"\r") # the echo
if is_open() != open_it:
raise RuntimeError("the shutter did not change state")
Modes and open time
Besides manual mode, the SC10 can open for a fixed time on its own or repeat cycles. The mode is chosen with mode=N (1 manual, 2 auto, 3 single, 4 repeat, 5 external gate) and the open time, in milliseconds, with open=N. For repeatable exposures it is better to let the SC10 time the opening than to do it from the computer.
From script to test bench
On an optical bench, the shutter is coordinated with the light source, the filter wheels and the power meter, and every opening has to be logged alongside the images. Integrating all of that into software you can leave running on its own is what we build, custom.