PicoDAQ

class picodaq.device.PicoDAQ(port: str | None = None)

Representation of USB connection to PicoDAQ device

Parameters:

port – Serial port of device to connect

If no port is given, connects to the first device identified by devices() as a suitable candidate.

You typically do not need to use this class directly. The AnalogIn, DigitalIn, AnalogOut, and DigitalOut classes can find the picoDAQ by themselves.

close(stream: Stream = None) None

Stop and close the device.

Parameters:

stream – reference to the calling stream

The device is stopped immediately, but only actually closed if no open streams remain. At that point, all parameters are reset.

You typically do not have to call this directly, as the streams call it internally.

command(cmd: str, feedback=True) List[str]

Send a command and optionally collect feedback.

Parameters:
  • cmd – a command line for the picoDAQ device

  • feedback – whether to wait for confirmation

The given command is sent directly to the picoDAQ. Consult the hardware API for details.

If feedback is True, waits for and returns feedback. Otherwise returns immediately and returns None.

continuous() None

Select continuous recording mode

This cancels a previous episodic(...) call. You normally do not need to call this, as continuous recording is the default.

episodic(duration: Time, period: Time | None = None, count: int | None = None) None

Select episodic recording mode

Parameters:
  • duration – Duration of each episode

  • period – start-to-start time between episodes

  • count – number of episodes before automatically stopping

The period is measured start-to-start and is optional if triggering is enabled, in which cases it specifies the minimum period.

The count parameter, if given, specifies that the recording will stop automatically after that number of episodes have been recorded. Otherwise, it continues until the user stops the recording.

The specified duration of each episode may be internally lengthened slightly so that it constitutes an even number of USB transfer chunks.

In episodic mode, the timing of any stimuli is modified such that there is one train per episode and the defined inter-train intervals are ignored. The timing between start of the episode and the first pulse of a stimulus is determined by the delay parameter on the stimulus.

See also continuous.

immediate() None

Disable triggering

This cancels a preceding trigger(...) call, so recording commences immediately upon start(). You normally do not have to call this, as immediate start is the default operation.

isopen() bool

True if the device is currently open

Returns true whether the device has been opened directly by the user or indirectly through AnalogIn and friends.

isrunning() bool

Report whether the device has been started

open(stream: Stream = None) None

Open the device

Parameters:

stream – reference to the calling stream

You typically do not have to call this directly. If you do, make sure that your calls to open() and to close() are matched.

sendwave(idx: int, wav: ndarray) None

Send wave data

Parameters:
  • idx – the index number of the wave

  • wav – the raw data as int16

The data are transmitted to the device using the “wave” command.

start() None

Start the acquisition

Both input and output are started in synchrony. You typically do not have to call this explicitly, as reading from an AnalogIn or DigitalIn automatically starts the acquisition.

stop() None

Stop the acquisition

You typically do not have to call this explicitly, as closing AnalogIn or DigitalIn does it automatically.

trigger(source: int, polarity: int) None

Define triggering

Parameters:
  • source – the digital line to monitor

  • polarity – edge on which to trigger

The recording (whether continuous or episodic) is not actually started until the given trigger condition is met. The source parameter (0, 1, 2, or 3) specifies a digital channel. The polarity parameter specifies whether the system triggers on rising edge (polarity > 0) or on falling edge (polarity < 0).

See also immediate.

verify(force: bool = False) bool

Confirm whether recording and stimulation parameters are OK

Parameters:

force – Re-verify unconditionally

You typically don’t have to call this directly, as streams check for you.

The device keeps track of parameter changes since last call to verify and returns without doing work if there have been none. The force parameter causes unconditional re-verification.