Model for Devices

Module contents

Analog DAQ

Class for communicating with a real device. It implements the base for communicating with the device through a Controller. The experiment in mind is measuring the I-V curve of a diode, adding the logic into a separate Model for the experiment may seem redundant, but incredibly useful in bigger projects.

class PythonForTheLab.Model.analog_daq.AnalogDaq(port)[source]

Bases: object

Simple Model that reflects the logic of the MVC pattern. This model relies on the real controller for communicating with an Arduino based DAQ.

Parameters:port (str) – See pftl_daq
port

The port information

Type:str
driver

The controller

Type:Device
finalize()[source]

Set the outputs to 0V and finalize the driver

get_voltage(channel)[source]

Retrieve the voltage from the device

Parameters:channel (int) – Channel number
Returns:Quantity – The voltage read
initialize()[source]

Initialize the driver and sets the voltage on the outputs to 0

set_voltage(channel, volts)[source]

Set the voltage to a given value on a given channel

Parameters:
  • channel (int) – The channel number
  • volts (Quantity) – The value to set, a quantity using Pint

Base DAQ

Base class for the DAQ objects. It keeps track of the functions that every new model should implement. This helps keeping the code organized and to maintain downstream compliancy.

class PythonForTheLab.Model.base_daq.DAQBase(port)[source]
finalize()[source]
get_voltage(channel)[source]
initialize()[source]
set_voltage(channel, volts)[source]

Dummy DAQ Model

it only generates random values.

class PythonForTheLab.Model.dummy_daq.DummyDaq(port)[source]

Bases: PythonForTheLab.Model.base_daq.DAQBase

get_voltage(channel)[source]

Generates a randomg value

Returns:float – Random value
PythonForTheLab.Model.dummy_daq.random() → x in the interval [0, 1).