Hardware Controls¶
This module contains GPIO hardware controls for:
- the temperature sensors,
- the electric heaters (PID controlled),
- the LEDs.
- Jin Cheng & Hayley Weir 08/12/16:
- the PID class
- Hayley Weir 11/12/16:
- GPIO controls, LED controls, initialisation function, hardware components testing
- Jin Cheng 12/12/16:
- function cleanup and asynchronisation, the asynchronous PWM control queue, documentation
- Jin Cheng 17/01/17:
- allow customisation of PID params from the web interface
-
class
robotchem.hardware.
PID
(init_val, Kp=None, Ki=None, Kd=None, set_point=None)[source]¶ Bases:
object
An object representing a PID controller, allowing the two heaters to have separate PID params.
Stores historical integral and derivative values so far, while the set point can be updated after class construction and at any point in time.
-
robotchem.hardware.
_read_adc
(channel, adc_object, gain=1, scale=5.405405405405405e-06)[source]¶ Reads measurement at a ADC channel with a specified GAIN. Converts the measurement mV into current in amps with a scaling factor.
Parameters: - channel – channel number on the ADC device
- gain – factor of gain in ADC. No gain by default.
- scale – scale factor of the final output, by default converts mV into current in ampere.
Returns: ADC measurement.
-
robotchem.hardware.
cleanup
(*heaters, wipe=False)[source]¶ Cleans up the whole GPIO board. Use when exception is raised.
Parameters: - heaters (list[ RPi.GPIO.PWM, ..) – heater PWM objects
- wipe (bool) – run the hardware GPIO cleanup. Resets all previous PWM and ADC instances.
-
robotchem.hardware.
flash_LED
(*pins, period=0.15)[source]¶ An async coroutine that routinely flashes the LEDs.
Parameters: - pins – pin numbers of LED bulbs
- period – the LED will flash every x seconds.
-
robotchem.hardware.
indicate_heating
(_loop)[source]¶ Indicate the device is heating in an active calorimetry by turning on/off LED lights.
Parameters: _loop (asyncio.BaseEventLoop) – the main event loop
-
robotchem.hardware.
indicate_starting_up
()[source]¶ Indicate the device is heating to start_temp by turning on/off LED lights.
-
robotchem.hardware.
initialize
(board_only=False)[source]¶ - Initial setup for GPIO board.
- Make all GPIO output pins set up as outputs.
- Start standby LED color (green).
- If not board_only, instantiate and return new heater PWM and ADC reader objects.
Parameters: board_only (bool) – If false, do not instantiate new heater and ADC reader objects. Return type: None | tuple[ (RPi.GPIO.PWM, RPi.GPIO.PWM, Adafruit_ADS1x15.ADS1115, ) Returns: If not board-only, a tuple of reference, sample PWM objects
-
robotchem.hardware.
measure_all
(loop, adc_object)[source]¶ A convenience function to measure all readings with one concurrent Future object.
Parameters: - loop – the main event loop.
- adc_object – the adc object representing the Analogue-to-Digital converter bytes reader from the Adafruit library.
Returns: a tuple containing reference cell temp, sample cell temp, reference heater current, sample heater current.
-
robotchem.hardware.
read_current_ref
(adc_object, *args, **kwargs)[source]¶ An async wrapper function for reading real-time current at the reference.
-
robotchem.hardware.
read_current_sample
(adc_object, *args, **kwargs)[source]¶ An async wrapper function for reading real-time current at the sample.
-
robotchem.hardware.
read_temp
(identifier)[source]¶ Reads from the One-Wire thermocouple temperature info from its bus.
Parameters: identifier (str) – the unique 1-wire device identifier string. Return type: float Returns: measured temperature, in Celsius