## NI Clock Source Notes

### Table of Calibrated Values

SpikeGLX maintains a table of NI clock sources in the file

- `_Calibration\calibrated_sample_rates_nidq.ini`

The entries in this table have the form:

    Name : Set_rate=Measured_rate

- Name: This is just a label you provide to help you recognize different sources you might use in your lab. We expect you might pick a name like `Whisper` if you are using a Janelia-built Whisper multiplexer, or `Internal` if electing to use program the NI device’s own internal Ctr0 clock. We now auto-generate a suggestion for your convenience.

- Set_rate: This is the rate that is used to program a clock, for example, a Whisper’s clock is nominally 25000 Hz, or you might set 25000 Hz to program the NI internal clock.

- Measured_rate: Until you have done a calibration the measured rate is initialized to be the `Set_rate`. When you use the SpikeGLX calibration features, the measured rate is updated with a more accurate measurement result. In any case, the `Measured_rate` is used as the best available estimator of the true sampling rate for the device.

### Simultaneous Sampling vs Multiplexing

How fast can the device go?

S-series (61xx) and some X-series (63xx) devices support simultaneous sampling, which means that each AI channel has its own amplifier and ADC, so can digitize samples independently and in parallel. These devices can sample at their maximum advertised rate at any channel count.

By contrast, M-series (62xx) and some X-series devices have a single amplifier/ADC pipeline that is shared by all AI channels. The inputs are switched into the digitizer in a serial fashion, one at a time. The `maximum` rate these multiplexing devices can go is the advertised sample rate `R0` divided by the number of channels: `R0/nchan`.

The shortest time it takes to digitize a sample is the `convert period` which is `1/R0`. However, when multiplexed inputs are switched it takes a small amount of time to allow charge from the previous sample to dissipate and the amplifier to settle to the new nominal charge level. The NI data sheet for your device will list the settle time (W) required to achieve a desired accuracy level for the voltage measurement. Enter the value from the data sheet into the ‘Settle microsecs’ box. For example, for the 6221, 7 us are required to reach the +/- 1 bit level. NI suggests adding a little margin to be safe (SpikeGLX multiplies your input W by 1.4). That makes the `safe rate = [1/(1/R0 + 1.4e-6 * W)]/nchan`.

#### Multiplexing Ghost Signals

If you’ve configured a multiplexing device to acquire from several channels but some of the listed inputs are unused/floating, then you will see ghost signals on the unused channels. This happens because the high impedance ADC input still sees residual charge from the last connected channel; and if the next channel in the multiplexing sequence isn’t connected to anything, that charge has nowhere to go, so it gets digitized again and assigned to the current channel. To avoid ghosts:

- Only configure analog channels you actually need.
- Connect something to each configured input.
- Cap otherwise unused inputs with 50 Ohm terminators.

### Internal Clock Step-down Factor

What sample rate can I actually program?

Digitizing hardware needs to be driven by a square wave: a `clock source` that can be generated by another external device or by the internal pulse counter (`Ctr0`) on-board the NI device.

External Source

If using an external clock, its rate is what it is. We allow you to directly set that value into the rate box.

Internal Source

When the internal source is selected, we program its rate by defining a task that counts a specified number of whole pulses of the device’s master timebase. That is, realizable rates are limited to: `timebase/integer`. In this case, you must enter the integer and we put the result into the rate box.

> SpikeGLX restricts rates to the range: [100,1M] Hz.

fin