device.valve_board module

class device.valve_board.InterfaceI2C(rules, mapping, testrun=False)[source]

Bases: object

Internal helper class that controls the I2C interface and enforces safety rules on the state of its slaves (binary-state valves).

close()[source]

Close the bus and clean up.

open()[source]

Open the bus and execute all necessary initializations.

set_valve(name, state)[source]

Set state of a single valve. Safety rules are enforced.

Parameters:
  • name (str) – valve name as given by mapping

  • bool (int) – open/close or ‘which way’ in case of 3-way valve

state_all()[source]

Read current state of all valves.

class device.valve_board.InterfaceSPI(mapping, testrun=False)[source]

Bases: object

Internal helper class that controls the SPI interface (needle valves).

close()[source]

Close the bus and clean up.

open()[source]

Open the bus and execute all necessary initializations.

set_needle(name, value)[source]

Set state of a single valve. Safety rules are enforced.

Parameters:
  • name (str) – needle valve name as given by mapping

  • value (int) – value in range(0, 4096)

state_all()[source]

State of all needle valves according to software state-tracker. It is not possible to read state directly from the DAC.

class device.valve_board.Rules(valves)[source]

Bases: object

Internal helper class to define rules about valve combinations. Valves are identified by their user-friendly names (file ‘valve_mapping.json’).

The purpose of rules is to avoid unsafe pipe connections. It is assumed that closing a valve is always safe.

check(valves=None)[source]

Check if a state does not break any rules.

Parameters:

valves (dict) – state of valves {str name: bool state}

rule_disabled()[source]

Returns set of disabled valves. Rule: Valves that are elements of this set cannot be in open state.

rule_disjunctive()[source]

Returns list of disjunctive rules (sets). Rule: Up to ONE valve from each set can be open at the same time.

class device.valve_board.ValveBoard(testrun=False, **kwargs)[source]

Bases: HardwareBase

A board that connects vacuum chambers and gas sources.

Communication:

  • RaspberryPi + I2C (smbus) and SPI (spidev) interfaces

  • I2C -> 3x expander, togther they control 35 open/closed valves and 1 three-way valve

  • SPI -> 4x DA convertor, together they control 5 needle valves

Note

Expander is a MCP23017 microchip (16-bit == two 8-bit branches A, B)

DA converter is a MCP4802 microchip (8-bit) and four MCP4911 (10-bit)

close_all()[source]

Close all binary valves and needles. Not including gas01_switch.

Note: This sends close command to all valves regardless of their assumed state. Thus it can be used as a reliable fail-safe.

close_path()[source]

Close active path.

close_valve(name)[source]

Close one valve.

Parameters:

name (str) – Valve name, see file ‘valve_mapping.json’.

get_needle(which)[source]

Read state of needle valve connected to one of the chambers.

Parameters:

name (str) – Pick chamber number ‘0’, ‘1’, ‘2’, ‘3’, ‘4’.

Return int percent:

Percentage in range 0-100, where 0 is closed.

property needles
open_path(path)[source]

Open a custom path (a custom set of binary valves). Any previous path will be closed.

Parameters:

path (str) – A comma separated string containing the valves’ names. (Whitespace characters are ignored.)

Note: Active path is saved to memory and can be closed without closing any other valves using method close_path().

open_valve(name)[source]

Open one valve.

Parameters:

name (str) – Valve name, see file ‘valve_mapping.json’.

set_needle(which, percent)[source]

Change state of needle valve connected to one of the chambers.

Parameters:
  • name (int) – Pick chamber number 0, 1, 2, 3, 4.

  • percent (float) – Percentage in range 0-100, where 0 is closed.

Note: Percent values below 1.0% are rounded to “real” 0 (i.e. without

empirical offset).

set_needle_for(which, percent, duration)[source]

Open needle valve for a limited duration (“gas puff”).

Parameters:
  • name (int) – Pick chamber number 0, 1, 2, 3, 4.

  • percent (float) – Percentage in range 0-100, where 0 is closed.

  • duration (float) – Time in seconds.

switch_gas01(which)[source]

Change state of three-way valve that switches between gas 0 and 1.

Parameters:

which (int) – Pick gas, either 0 or 1.

update_frontend(device_client)[source]
property valves
exception device.valve_board.ValveRuleError[source]

Bases: CommandError

Valve could not be opened because it would violate one of the rules on valve combinations specified in class Rules.