# Measurement Computing

Stream and set Measurement Computing DAQ I/O

- Category: Data acquisition
- Capabilities: Streams, Assets, Commands, Operations, Entities
- Runs on: Linux x64, Linux ARM64, Windows x64

Read analog inputs, digital lines and counters, and set analog and digital
outputs, on Measurement Computing USB and Ethernet DAQs.

**Windows and Linux only.** It uses the **Universal Library** (`cbw64.dll`,
installed with InstaCal) on Windows and **uldaq** on Linux. There is **no
macOS build**: MCC publishes no macOS library.

## What you get

- **Analog inputs** — the channels you list, such as `ai0, ai1`, timed by the
  board's own clock.
- **Digital inputs** — one line as 0/1 (`FIRSTPORTA/0`, `AUXPORT/3`, or
  `di<n>` for bit n of the first port), or a whole port as an integer
  (`FIRSTPORTB`).
- **Event counters** — such as `ctr0` on a USB-201, as running totals since the
  input started.
- **Outputs** — the board's analog outputs (±10 V) and every digital line and
  port it can drive, set from Trellis via `ch.write(path, value)`. A line takes
  true/false (`/mcc/mcc1/AUXPORT/3`); a port takes an integer
  (`/mcc/mcc1/FIRSTPORTB`). A USB-201 has no analog output. Every write is
  recorded, and a line write is read back from the board.
- **Any number of boards in one input**, named by its **Device name**.
  Channels read `/mcc/mcc1/…`. The primary board uses bare names
  (`/mcc/mcc1/ai0`). Other boards appear in the same table and use their id
  (`/mcc/mcc1/21A3DAC/ai0`) once you tick their channels. Boards line up by
  this computer's clock, since each has its own oscillator.

## Setup

1. Install the MCC library and connect the device: **InstaCal / Universal
   Library** on Windows, **uldaq** on Linux. Phloem detects a USB board and
   offers a draft with its serial filled in. The steps below are the manual
   path.
2. In **Inputs**, add **Measurement Computing** and fill in:
   - **Device name** — a short label, e.g. `mcc1` or `engineA`. Every channel
     is named under it. Renaming it later moves the channels' calibration,
     names, tiles, pipelines and setups with them, after you confirm. Past
     recordings keep the old name, and Replay shows "previously …" beside the
     channel. From the CLI: `phloem input rename-prefix "<input>" engineA`.
   - **Unique ID** — the serial number. Leave empty for the first device
     found. On Windows, `board:0` picks the board number InstaCal gave it,
     including a **DEMO-BOARD**, which works with no hardware.
   - **Input channels** — e.g. `ai0,ai1`, or tick them in the table. It lists
     every analog input, digital line and port the board can read. A USB-201
     shows `ai0..ai7` and `AUXPORT/0..7`; the DEMO-BOARD shows AUXPORT,
     FIRSTPORTA and FIRSTPORTB, eight lines each.
   - **Sample rate** — starts at the board's own default. The DEMO-BOARD
     offers **1000 Hz per channel with a 300 000 Hz ceiling**; a 100 S/s
     module starts at 100.
   - **Digital & counter poll rate** — how often digital lines and counters
     are read.
3. Press **Test connection**. It names the board, its number of analog inputs,
   and its rate range.
4. Inputs appear on **Live**. Outputs are available in **Trellis**.

## Sample rate

- **The board's clock sets the timing.** The stream states the rate the board
  actually settled on, which may differ slightly from what you asked.
- **Rates past the board's limit are refused**, including the total across all
  channels in one scan. For example: *"8 channel(s) at 50000 Hz each asks for
  400000. Lower the sample rate to 37500 Hz"*.
- If a board does not report a limit, the field uses a safe default and shows
  no limit.
- A stated ceiling is what the board accepts, not a guarantee. The DEMO-BOARD
  holds 300 kS/s across eight channels within 0.3 %, but only an eighth of that
  on one channel, because it is a software simulator.
- **Only ticked channels are scanned.** `ai0,ai7` scans two channels, not the
  eight between them. A board that cannot do this scans the whole range and
  says so.
- **Digital lines, ports and counters** are read on this computer's clock at
  the **Digital & counter poll rate**. Every rate display shows that rate for
  them, so a 50 Hz limit switch beside a 12.5 kHz scan reads 50 Hz.
- Live shows which clock timed each channel: `backdated` for the board's scan,
  `host` for this computer.
- **Boards with no hardware clock** — USB-TC, USB-TEMP, USB-TC-AI,
  USB-TEMP-AI, USB-2001-TC, USB-TC-32 and E-TC — are read on this computer's
  clock and marked `host`.

## Triggers and clocks

- **Start trigger** — `trigger = start=rising` waits for the board's trigger
  input.
- **External sample clock** — not supported, and refused. The MCC libraries
  cannot report the real sample period under an external clock.
- **Sharing this board's clock** — `clock = pacer_out=on` drives this board's
  clock out so another instrument can follow it.

## Range and over-range

- The `range` field sets the ± volts. Leave it empty for ±10 V where the board
  has it, or its only range. A range the board lacks is refused, with the list
  it does have.
- **Over-range** — readings at either end of the converter's scale are marked
  as one `under_range` or `over_range` span, like DAQami's `OVR`. The span
  closes once readings stay off the end for 3 s.

## Stopping

**Stop** ends the acquisition after a number of samples per channel, or after a
duration. The input then shows **finished**.

## Checks before saving

Save, `phloem apply` and `apply --dry-run` refuse settings the board cannot
take: a channel it lacks (`ai9` reads "this board has ai0..ai7"), an unknown
line or counter, a scale that does not parse, or a trigger level on a digital
start. A board on another machine is not checked, so its project still opens.
What only the open board can answer, such as a missing trigger, is refused at
start.

## Notes

- Without the MCC library, the connector says so and names the file it looked
  for.
- **There is no watchdog.** If this computer stops, outputs stay where they
  were set. Do not use it to hold a hazardous actuator. Use a PLC or FPGA with
  its own failsafe.
- **A stalled scan is reported.** If the board reports RUNNING but sends
  nothing for twenty blocks (at least two seconds), the connector marks a gap
  and logs `mcc: scan stall #n — the board reports RUNNING
  and has transferred nothing for N s…`. It keeps trying in case the board
  resumes.
- Matched against DAQami 4.2.1's help and the USB-200 series datasheet.

## Supports

- Measurement Computing USB/Ethernet DAQs via uldaq on Linux (USB-1208, USB-1608, E-1608, ...)
- On Windows via the MCC Universal Library (cbw64.dll), including InstaCal-configured boards
- Replaces DAQami: the same device, acquired live into Phloem

## Connection fields

| Field | Type | Required | Notes |
|---|---|---|---|
| Device name | Text | Yes | The name this board's channels are addressed under (/mcc/<name>/ai0). Any short label; change it when a second MCC board is added. |
| Primary board (serial; empty = first device) | Text | No | Leave empty to use the first board found. Run discover (or Test connection) to list what this machine has: USB/Ethernet devices are addressed by serial, and on Windows an InstaCal-configured board — including the DEMO-BOARD — is addressed as board:<n>, e.g. board:0. |
| Input channels | Text | No | Which inputs to stream, in one comma list: analog as ai<n> (ranges ai0..ai7, ai0..=ai7, ai0-ai7 or ai0:7); a digital line as <PORT>/<bit> in the library's own port name (FIRSTPORTA/0, AUXPORT/3) or as di<n> for bit n of the board's first port; a whole port as <PORT> (FIRSTPORTB), streamed as the integer its lines form; an event counter as ctr<n> (edges since the input started, polled with the digital lines). Bare tokens are the board picked above; a token led by another board's id (21A3DAC/ai0, board:1/AUXPORT/3) streams that board too — one input may span every board on the box, each on its own clock. The table lists every line and port of every board, in exactly these spellings. |
| Sample rate (Hz, per channel) | Number | No | Hardware-paced continuous scan on any board that has a pacer — both backends now scan (`ulAInScan` on Linux, `cbAInScan` on Windows), so this is the board's own sample clock and not a host loop. Test connection reports the board's own rate window and a new input opens inside it; a rate past its ceiling — per channel, or across the channels sharing one scan — is refused by name rather than quietly coerced. A board with NO pacer (USB-TC, USB-TEMP, USB-2001-TC, USB-TC-32, E-TC) says so and samples in a software loop on this host's clock instead — its stream is stamped `host` for that reason. |
| Digital & counter poll rate (Hz) | Number | No | How often the digital ports and event counters in `channels` are read, on this host's clock. Each port is read once per poll and every line ticked from it is derived from that one read, so the lines of a port share an instant. Software-timed on every MCC board this connector has met; the stream says `host` for that reason. |
| Start | One of | No | What starts the scan. A trigger the board does not have is refused by name. |
| Trigger level (volts) | Number | No | The voltage the analog condition compares against. |
| Stop | One of | No |  |
| Samples per channel | Number | No |  |
| Duration (s) | Number | No |  |
| Sample clock | One of | No | Drive the pacer out so another instrument follows this board. |
| Input range | One of | No | The volts the analog inputs are read on. |
| Channel scaling (at source) | Text | No | Only for hardware that must scale before it emits. Everything else: calibrate the channel on its own row here (the Calibrate cell), where the correction is recorded, versioned and shown raw-beside-calibrated. |
