Contributions:PicoscopeADC
Synopsis
This source module streams analog data from PicoScope 5000A series oscilloscopes using the official ps5000a API from Pico Technology. It supports 1–4 analog channels (A…D) depending on model and resolution, and integrates with BCI2000’s SourceFilter framework.
Location
http://www.bci2000.org/svn/trunk/src/contrib/SignalSource/PicoScopeADC
Versioning
Authors
Nicholas Luczak
Version History
Revision rXXXX 2025/10/24: Initial streaming implementation for 5000A series; added parameter set (Coupling/Range/Resolution), µV scaling via SourceChGain, friendly Pico error messages via optional helper.
Revision rXXXX 2025/10/24: CMake updates to link against ps5000a.lib and support local SDK inc/lib folders or PICOSDK_INC/PICOSDK_LIB env vars.
Revision rXXXX 2025/10/24: Parameter definitions aligned with BCI2000 wiki reference; added basic preflight validation.
Source Code Revisions
Initial development: rXXXX
Tested under: rXXXX (Windows x64)
Known to compile under: rXXXX
Broken since: --
Functional Description
This module opens a PicoScope 5000A-series device, applies user-selected coupling, input range, and ADC resolution, and starts streaming acquisition using the ps5000a driver’s RunStreaming/GetStreamingLatestValues API. Data are buffered in per-channel FIFOs and emitted as raw ADC counts; BCI2000 scales to µV using SourceChGain which is set automatically from the selected input range and the device’s maximum ADC code for the chosen resolution.
Modes implemented: Streaming
Not implemented (this revision): rapid block, ETS, advanced triggering, per-channel ranges (a single global range/coupling is applied to enabled channels in this version).
Installation
The module requires Pico Technology’s ps5000a SDK:
Runtime ps5000a.dll available on PATH or copied next to the executable This can be found in Program Files/Picoscope
Parameters
SampleBlockSize, SamplingRate, SourceCh, SourceChGain, SourceChOffset, ChannelNames
These parameters behave as in other BCI2000 source modules.
SamplingRate: Requested sampling frequency. The Pico driver will quantize to an achievable interval; the effective interval is returned by the driver when streaming starts.
SampleBlockSize: Number of samples delivered per block. Choose based on desired block time (e.g., 1024 at 10 kHz ≈ 102.4 ms).
SourceCh: Number of analog channels (1..4). Some 5000A models limit enabled channel count at higher resolutions (15/16-bit).
SourceChGain: Auto-filled per channel to convert raw A/D counts to µV (computed from selected Range and device max code for the chosen Resolution).
SourceChOffset: Typically 0.
ChannelNames: Auto-filled to PSA, PSB, PSC, PSD for enabled channels.
Coupling
PicoScope:Setup Coupling (list): DC (default) or AC. Applies to all enabled channels in this revision.
Range
PicoScope:Setup Range (list): 10mV, 20mV, 50mV, 100mV, 200mV, 500mV, 1V, 2V, 5V, 10V, 20V, 50V. This sets the per-channel full-scale input. A single value is applied to all enabled channels in this revision.
Resolution
PicoScope:Setup Resolution (list): 8bit, 12bit, 14bit, 15bit, 16bit. Note that at 15-/16-bit, hardware may limit the number of simultaneously enabled channels. If the driver returns a resolution-related error (e.g., PICO_INVALID_NUMBER_CHANNELS_FOR_RESOLUTION), reduce SourceCh or select a lower resolution.
States
PicoScopeADCAsyncTriggers (event stream; reserved)
PicoScopeADCSyncTriggers (state channel; reserved) This revision does not populate hardware trigger states; the stream exists for future extension.
Streams
Main signal stream: N analog channels (1..4) plus the sync trigger state channel (reserved, currently 0). Signals are raw A/D counts with scaling provided via SourceChGain.
Troubleshooting
Meaningful Pico errors This module can print human-readable names/descriptions for Pico status codes by including a small helper header (PicoStatusText.h) that maps PICO_STATUS values (from PicoStatus.h) to text. Typical message format:
PicoScope: ps5000aRunStreaming failed: PICO_INVALID_NUMBER_CHANNELS_FOR_RESOLUTION (0x00000121) The number of channels that can be enabled is limited in 15 and 16-bit modes...
Power/USB handling If ps5000aOpenUnit or streaming calls return power/USB conditions (e.g., PICO_POWER_SUPPLY_NOT_CONNECTED, PICO_USB3_0_DEVICE_NON_USB3_0_PORT), the module requests ps5000aChangePowerSource() and retries.
No samples arriving Ensure the requested SamplingRate is achievable for the chosen Resolution and SourceCh. The driver quantizes the interval; if starved, try reducing rate or channels.
Link errors Verify you are linking the x64 ps5000a.lib and the DLL is found at runtime (PATH or next to the executable). Confirm header/lib versions match.
Notes and Limitations
Global (single) Range and Coupling are applied to all enabled channels in this revision.
Triggering/ETS/rapid block are not implemented.
Downsampling/aggregation modes are not exposed as parameters (driver default is no downsample in streaming).