device.valve_board module¶
- class device.valve_board.InterfaceI2C(rules, mapping, testrun=False)[source]¶
Bases:
objectInternal helper class that controls the I2C interface and enforces safety rules on the state of its slaves (binary-state valves).
- class device.valve_board.InterfaceSPI(mapping, testrun=False)[source]¶
Bases:
objectInternal helper class that controls the SPI interface (needle valves).
- class device.valve_board.Rules(valves)[source]¶
Bases:
objectInternal 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}
- class device.valve_board.ValveBoard(testrun=False, **kwargs)[source]¶
Bases:
HardwareBaseA board that connects vacuum chambers and gas sources.
Communication:
RaspberryPi + I2C (
smbus) and SPI (spidev) interfacesI2C -> 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_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.
- property valves¶
- exception device.valve_board.ValveRuleError[source]¶
Bases:
CommandErrorValve could not be opened because it would violate one of the rules on valve combinations specified in
class Rules.