mahos.inst.daq.BufferedEdgeCounter#

class mahos.inst.daq.BufferedEdgeCounter(name, conf=None, prefix=None)#

A configurable DAQ Task class for edge counting.

Counts are buffered and read at each cb_samples.

Parameters:
  • counter (str) – The device name for counter (like /Dev1/Ctr0).

  • source (str) – The pin name for counter source (like /Dev1/PFI0).

  • source_dir (bool) – (default: True) Source direction. True (False) for rising (falling) edge.

  • queue_size (int) – (default: 10000) Software buffer (queue) size for acquired data.

  • clock (str) – DAQ terminal for clock.

  • cb_samples (int) – The number of samples for each callback.

  • samples (int) – The number of samples. In infinite mode (finite=False), this is used for automatic buffer allocation.

  • buffer_size (int | None) – The input buffer size. If not given, buffer size is not set manually (automatic buffer allocation is used).

  • rate (float) – (default: 10000.0) Estimated sampling rate.

  • clock_dir (bool) – (default: True) True (False) for rising (falling) edge clock.

  • finite (bool) – (default: True) Switch if finite mode or infinite mode.

  • every (bool) – (default: False) Switch if every1 mode or not.

  • stamp (bool) – (default False) Attach timestamp for each samples.

  • drop_first (int) – (default 0) drop the data on first N callbacks.

  • diff (bool) – (default: True) If True, everyN_handler is passed differential data (<count of n-th sample> - <count of (n-1)-th sample>).

  • gate (bool) – (default: False) If True, cb_samples, samples, and buffer_size are automatically doubled and everyN_handler is passed gated data (<count of (2n+1)-th sample> - <count of (2n)-th sample>).

Finite or Infinite mode#

In finite mode (finite=True), task is finished with samples. In inifinite mode (finite=False), task continues infinitely but it can be stopped by stop().

On some device, we cannot call EveryNCallBack at arbitrary cb_samples in infinite mode. (For example, buffer size must be even integer multiple of cb_samples.) Setting buffer_size explicitly, or every=True may resolve such a situation.

Callback handlers#

You’d pass three callback handler functions: every1_handler, everyN_handler, and done_handler. If every1 mode (every=True), EveryNCallBack is called with N=1 regardress of cb_samples. And every1_handler is called at each callbacks. EveryNCallBack aquires data and call everyN_handler at each cb_samples callbacks. If every1 mode is inactive (every=False), EveryNCallBack is called after acquiring cb_samples, and everyN_handler is called for each callback. In this mode every1_handler is never called.

__init__(name, conf=None, prefix=None)#

Methods

__init__(name[, conf, prefix])

configure(params[, label])

Configure the instrument settings.

get(key[, args, label])

Get an instrument setting or measurement data.

get_buffer_size()

get_max_rate()

pop_all_block()

Get all data from buffer as list.

pop_all_opt()

Get all data from buffer as list.

pop_block()

Get data from buffer.

pop_opt()

Get data from buffer.

set_buffer_size(size)