Model for Devices

Module contents

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 PFTL.model.base_daq.DAQBase(port)[source]
finalize()[source]
get_input_voltage(channel)[source]
get_output_voltage(channel)[source]
idn()[source]
initialize()[source]
set_output_voltage(channel, volts)[source]

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 PFTL.model.analog_daq.AnalogDaq(port)[source]

Bases: DAQBase

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_input_voltage(channel)[source]

Retrieve the voltage from the device

Parameters:

channel (int) – Channel number

Returns:

Quantity – The voltage read

get_output_voltage(channel)[source]

Gets the voltage from a given output channel

Parameters:

channel (int) – The channel number

Returns:

Quantity – The voltage setpoint in the channel

initialize()[source]

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

set_output_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

Dummy DAQ model

Simulated device that allows to run the program without any DAQ card attached to the computer.

It returns random values for the methods that should read from the device.

class PFTL.model.dummy_daq.DummyDaq(port)[source]

Bases: DAQBase

get_input_voltage(channel)[source]

Generates a random value in Volts

Returns:

Quantity – Random value

get_output_voltage(channel)[source]

Generates a random value in Volts

Returns:

Quantity – Random value

PFTL.model.dummy_daq.random() x in the interval [0, 1).