Picoscope 2000 Series A API Programmers Guide
Picoscope 2000 Series A API Programmers Guide
Programmer's Guide
ps2000apg.en-12
PicoScope 2000 Series (A API) Programmer's Guide Contents
Contents
1 Introduction .............................................................................................................................. 7
1 Overview ............................................................................................................................................................................ 7
2 PC requirements .............................................................................................................................................................. 8
3 Legal information ............................................................................................................................................................. 9
2 Concepts ................................................................................................................................. 10
1 Driver ................................................................................................................................................................................ 10
2 General procedure ......................................................................................................................................................... 10
3 Voltage ranges ............................................................................................................................................................... 11
4 MSO digital data ............................................................................................................................................................ 12
5 Triggering ........................................................................................................................................................................ 13
6 Sampling modes ............................................................................................................................................................ 14
1 Block mode ....................................................................................................................................................... 15
2 Rapid block mode ............................................................................................................................................ 18
3 ETS (Equivalent Time Sampling) ................................................................................................................. 23
4 Streaming mode .............................................................................................................................................. 25
5 Retrieving stored data .................................................................................................................................... 27
7 Timebases ...................................................................................................................................................................... 28
8 MSO digital connector .................................................................................................................................................. 29
9 Combining oscilloscopes ............................................................................................................................................ 29
1 Introduction
1.1 Overview
The PicoScope 2000 Series PC Oscilloscopes from Pico Technology are high-speed real-time measuring
instruments. They obtain their power from the USB port so do not need an additional power supply. With a built-in
arbitrary waveform generator, these scopes contain everything you need in a convenient, portable unit.
This manual explains how to develop your own programs for collecting and analyzing data from the PicoScope
2000 Series oscilloscopes. It applies to all devices supported by the ps2000a application programming interface
(API), as listed below:
The Pico Software Development Kit (PicoSDK) is available free of charge from www.picotech.com/downloads.
This download includes support for all PicoScope oscilloscopes including the ps2000a API described in this
manual, as well as the original ps2000 API for older oscilloscopes in the PicoScope 2000 Series.
Example code is available from repositories under the "picotech" organization on GitHub.
1.2 PC requirements
To ensure that your PicoScope 2000 Series PC Oscilloscope operates correctly with the SDK, you must have a
computer with at least the minimum system requirements to run one of the supported operating systems, as
shown in the following table. The performance of the oscilloscope will be better with a more powerful PC, and will
benefit from a multi-core processor.
Item Specification
Windows 7, 8 or 10
Operating system
32-bit or 64-bit
Processor
Memory As required by Windows
Free disk space
USB 2.0 or USB 3.0 port
Ports*
USB 1.1 port (absolute minimum)
* PicoScope oscilloscopes will operate slowly on a USB 1.1 port. Not recommended.
USB 3.0 connections will run at about the same speed as USB 2.0.
Access. The licensee agrees to allow access to this software only to persons who have been informed of these
conditions and agree to abide by them.
Usage. The software in this release is for use only with Pico products or with data collected using Pico products.
Copyright. Pico Technology Ltd. claims the copyright of, and retains the rights to, all material contained in this
SDK. You may copy and distribute the SDK without restriction, as long as you do not remove any Pico Technology
copyright statements.
Liability. Pico Technology and its agents shall not be liable for any loss, damage or injury, howsoever caused,
related to the use of Pico Technology equipment or software, unless excluded by statute.
Fitness for purpose. As no two applications are the same, Pico Technology cannot guarantee that its equipment
or software is suitable for a given application. It is your responsibility, therefore, to ensure that the product is
suitable for your application.
Mission-critical applications. This software is intended for use on a computer that may be running other software
products. For this reason, one of the conditions of the licence is that it excludes use in mission-critical
applications, for example life support systems.
Viruses. This software was continuously monitored for viruses during production, but you are responsible for
virus-checking the software once it is installed.
Support. If you are dissatisfied with the performance of this software, please contact our technical support staff,
who will try to fix the problem within a reasonable time. If you are still dissatisfied, please return the product and
software to your supplier within 14 days of purchase for a full refund.
Upgrades. We provide upgrades, free of charge, from our web site at www.picotech.com. We reserve the right to
charge for updates or replacements sent out on physical media.
Trademarks. Windows is a trademark or registered trademark of Microsoft Corporation. Pico Technology Limited
and PicoScope are internationally registered trademarks.
2 Concepts
2.1 Driver
Your application will communicate with a PicoScope 2000 (A API) driver called ps2000a.dll, which is supplied
in 32-bit and 64-bit versions. The driver exports the ps2000a function definitions in standard C format, but this
does not limit you to programming in C. You can use the API with any programming language that supports
standard C calls.
The API driver depends on another DLL, picoipp.dll (which is supplied in 32-bit and 64-bit versions) and a
low-level driver called WinUsb.sys. These are installed by the SDK and configured when you plug the
oscilloscope into each USB port for the first time. Your application does not call these drivers directly.
Many example programs are available on GitHub. These demonstrate how to use the functions of the driver
software in each of the modes available.
Example
1. Call ps2000aSetChannel() with
range set to PS2000A_1V.
A PicoScope MSO has two 8-bit digital ports—PORT0 and PORT1—containing a total of 16 digital channels.
The data from each port is returned in a separate buffer that is set up by the ps2000aSetDataBuffer() and
ps2000aSetDataBuffers() functions. For compatibility with the analog channels, each buffer is an array of
16-bit words. The 8-bit port data occupies the lower 8 bits of the word, and the upper 8 bits of the word are
undefined.
2.5 Triggering
PicoScope oscilloscopes can either start collecting data immediately or be programmed to wait for a trigger
event.
· ps2000aSetSimpleTrigger()
For more complex trigger setups, call the three individual trigger functions:
· ps2000aSetTriggerChannelConditions()
· ps2000aSetTriggerChannelDirections()
· ps2000aSetTriggerChannelProperties()
A trigger event can occur when one of the signal or trigger input channels crosses a threshold voltage on either a
rising or a falling edge. It is also possible to combine two inputs using the logic trigger function.
To set up pulse width, delay and dropout triggers, you can also call the pulse width qualifier function:
· ps2000aSetPulseWidthQualifier()
· Block mode. In this mode, the scope stores data in internal buffer memory and then transfers it to the PC.
When the data has been collected it is possible to examine the data, with an optional downsampling factor.
The data is lost when a new run is started in the same segment, the settings are changed, or the scope is
powered down.
· ETS mode. In this mode, it is possible to increase the effective sampling rate of the scope when capturing
repetitive signals. It is a modified form of block mode.
· Rapid block mode. This is a variant of block mode that allows you to capture more than one waveform at a
time with a minimum of delay between captures. You can use downsampling in this mode if you wish.
· Streaming mode. In this mode, data is passed directly to the PC without being stored in the scope's internal
buffer memory. This enables long periods of data collection for chart recorder and data-logging applications.
Streaming mode supports downsampling and triggering, while providing fast streaming at typical rates of 1 to
10 MS/s, as specified in the data sheet for your device.
In all sampling modes, the driver returns data asynchronously using a callback. This is a call to one of the
functions in your own application. When you request data from the scope, you pass to the driver a pointer to your
callback function. When the driver has written the data to your buffer, it makes a callback (calls your function) to
signal that the data is ready. The callback function then signals to the application that the data is available.
Because the callback is called asynchronously from the rest of your application, in a separate thread, you must
ensure that it does not corrupt any global variables while it runs.
For compatibility with programming environments not supporting C-style callback functions, polling of the driver is
available in block mode.
· Block size. The maximum number of values depends upon the size of the oscilloscope's memory. The
memory buffer is shared between the enabled channels, so if two channels are enabled, each receives half
the memory, and if three or four channels are enabled, each receives a quarter of the memory. This
partitioning is handled transparently by the driver. The block size also depends on the number of memory
segments in use – see ps2000aMemorySegments().
Note: The PicoScope MSO models behave differently. If only the two analog channels or only the two digital
ports are enabled, each receives half the memory. If any combination of one or two analog channels and one
or two digital ports is enabled, each receives a quarter of the memory.
· Sampling rate. A PicoScope 2000 Series oscilloscope can sample at different rates according to the selected
timebase and the combination of enabled channels. See the Timebases section for the specifications that
apply to your scope model.
· Setup time. The driver normally performs a number of setup operations, which can take up to 50 milliseconds,
before collecting each block of data. If you need to collect data with the minimum time interval between
blocks, use rapid block mode and avoid calling setup functions between calls to ps2000aRunBlock(),
ps2000aStop() and ps2000aGetValues().
· Downsampling. When the data has been collected, you can set an optional downsampling factor and examine
the data. Downsampling is a process that reduces the amount of data by combining adjacent samples. It is
useful for zooming in and out of the data without having to repeatedly transfer the entire contents of the
scope's buffer to the PC.
· Memory segmentation. The scope's internal memory can be divided into segments so that you can capture
several waveforms in succession. Configure this using ps2000aMemorySegments().
· Data retention. The data is lost when a new run is started in the same segment, the settings are changed, or
the scope is powered down.
Note: Use the * steps when using the digital ports on MSO models.
Rapid block mode allows you to sample several waveforms in succession with minimal time between
waveforms. It reduces the gap from milliseconds to less than 2 microseconds (on the fastest timebase). Each
waveform is stored in a separate buffer segment.
Note: Use the * steps when using the digital ports on the mixed-signal (MSO) models.
Without aggregation
1. Open the oscilloscope using ps2000aOpenUnit().
2. Select channel ranges and AC/DC coupling using ps2000aSetChannel().
3. [MSOs only] Set the digital port using ps2000aSetDigitalPort().
4. Set the number of memory segments equal to or greater than the number of captures required using
ps2000aMemorySegments(). Use ps2000aSetNoOfCaptures() before each run to specify the
number of waveforms to capture.
5. Using ps2000aGetTimebase(), select timebases from zero upwards until the required number of
nanoseconds per sample is located.
6. Use the trigger setup functions ps2000aSetTriggerChannelConditions(),
ps2000aSetTriggerChannelDirections() and
ps2000aSetTriggerChannelProperties() to set up the trigger if required.
7. [MSOs only] Use the trigger setup functions ps2000aSetTriggerDigitalPortProperties() and
ps2000aSetTriggerChannelConditions() to set up the digital trigger if required.
8. Start the oscilloscope running using ps2000aRunBlock().
9. Wait until the oscilloscope is ready using the ps2000aIsReady() or wait on the callback function.
10. Use ps2000aSetDataBuffer() to tell the driver where your memory buffers are. Call the function once
for each channel/segment combination for which you require data. For greater efficiency, these calls can
be made outside the loop, between steps 7 and 8.
11. Transfer the blocks of data from the oscilloscope using ps2000aGetValuesBulk().
12. Retrieve the time offset for each data segment using
ps2000aGetValuesTriggerTimeOffsetBulk64().
13. Display the data.
14. Repeat steps 8 to 13 if you wish to capture more data.
15. Stop the oscilloscope using ps2000aStop().
16. Call ps2000aCloseUnit().
With aggregation
To use rapid block mode with aggregation, follow steps 1 to 9 above and then:
10a. Call ps2000aSetDataBuffer() or (ps2000aSetDataBuffers()) to set up one pair of buffers for
every waveform segment required.
11a. Call ps2000aGetValuesBulk() for each pair of buffers.
12a. Retrieve the time offset for each data segment using
ps2000aGetValuesTriggerTimeOffsetBulk64().
Continue from step 13.
pParameter = false;
ps2000aRunBlock
(
handle,
0, // noOfPreTriggerSamples
MAX_SAMPLES, // noOfPostTriggerSamples
1, // timebase to be used
1,
&timeIndisposedMs,
0, // segment index
lpReady,
&pParameter
);
Comment: these variables have been set as an example and can be any valid value. pParameter will be set true
by your callback function lpReady.
Comments: buffer has been created as a two-dimensional array of pointers to int16_t, which will contain 1000
samples as defined by MAX_SAMPLES. There are only 10 buffers set, but it is possible to set up to the number of
captures you have requested.
ps2000aGetValuesBulk
(
handle,
&noOfSamples, // set to MAX_SAMPLES on entering the function
10, // fromSegmentIndex
19, // toSegmentIndex
1, // downsampling ratio
PS2000A_RATIO_MODE_NONE, // downsampling ratio mode
overflow // an array of size 10 int16_t
)
Comments: See the earlier snippets for code to set up the segment buffers.
ps2000aGetValuesTriggerTimeOffsetBulk64
(
handle,
times,
timeUnits,
10,
19
)
Comments: the above segments start at 10 and finish at 19 inclusive. It is possible for the fromSegmentIndex
to wrap around to the toSegmentIndex, if the fromSegmentIndex is set to 28 and the
toSegmentIndex to 7.
pParameter = false;
ps2000aRunBlock
(
handle,
0, // noOfPreTriggerSamples,
MAX_SAMPLES, // noOfPostTriggerSamples,
1, // timebase to be used,
1,
&timeIndisposedMs,
1, // SegmentIndex
lpReady,
&pParameter
);
Comments: the set-up for running the device is exactly the same whether or not aggregation will be used when
you retrieve the samples.
Comments: since only one waveform will be retrieved at a time, you only need to set up one pair of buffers; one
for the maximum samples and one for the minimum samples. Again, the buffer sizes are 1000 (MAX_SAMPLES)
samples.
ps2000aGetValues
(
handle,
0,
&noOfSamples, // set to MAX_SAMPLES on entering
10,
&downSampleRatioMode, //set to RATIO_MODE_AGGREGATE
index,
overflow
);
ps2000aGetTriggerTimeOffset64
(
handle,
&time,
&timeUnits,
index
);
Comments: each waveform is retrieved one at a time from the driver with an aggregation of 10.
· Overview. ETS works by capturing several cycles of a repetitive waveform, then combining them to produce a
composite waveform that has a higher effective sampling rate than the individual captures. The scope
hardware accurately measures the delay, which is a small fraction of a single sampling interval, between each
trigger event and the subsequent sample. The driver then shifts each capture slightly in time and overlays
them so that the trigger points are exactly lined up. The result is a larger set of samples spaced by a small
fraction of the original sampling interval. The maximum effective sampling rates that can be achieved with
this method are listed in the User's Guide for the scope device. Other scopes do not contain special ETS
hardware, so the composite waveform is created by software.
· Trigger stability. Because of the high sensitivity of ETS mode to small time differences, the trigger must be
set up to provide a stable waveform that varies as little as possible from one capture to the next.
· Callback. ETS mode calls the ps2000aBlockReady() callback function when a new waveform is ready for
collection. The ps2000aGetValues() function needs to be called for the waveform to be retrieved.
Aggregation
The driver returns aggregated readings while the device is streaming. If aggregation is set to 1, only one buffer is
used per channel. When aggregation is set above 1, two buffers (maximum and minimum) per channel are used.
Note: Please use the * steps when using the digital ports on the mixed-signal (MSO) models.
2.7 Timebases
The ps2000a API allows you to select any of 232 different timebases based on the maximum sampling rate† of
your oscilloscope. The timebases allow slow enough sampling in block mode to overlap the streaming sample
intervals, so that you can make a smooth transition between block mode and streaming mode. Calculate the
timebase using ps2000aGetTimebase().
† The fastest available sampling rate may depend on which channels are enabled, and on the sampling
mode. Refer to the oscilloscope data sheet for sampling rate specifications. In streaming mode the sampling rate may
additionally be limited by the speed of the USB port.
* Available only in single-channel mode.
** Not available when channel B active, nor when channel A and both digital ports active.
ETS mode
In ETS mode the sample time is not set according to the above tables but is instead calculated and returned by
ps2000aSetEts().
CALLBACK ps2000aBlockReady(...)
// define callback function specific to application
handle1 = ps2000aOpenUnit()
handle2 = ps2000aOpenUnit()
ps2000aSetChannel(handle1)
// set up unit 1
ps2000aSetDigitalPort(handle1) // only when using MSO
ps2000aRunBlock(handle1)
ps2000aSetChannel(handle2)
// set up unit 2
ps2000aSetDigitalPort(handle2) // only when using MSO
ps2000aRunBlock(handle2)
ready = FALSE
while not ready
ready = handle1_ready
ready &= handle2_ready
3 API functions
The ps2000a API exports a number of functions for you to use in your own applications. All functions are C
functions using the standard call naming convention (__stdcall). They are all exported with both decorated
and undecorated names.
This callback function is part of your application. You register it with the ps2000a driver using
ps2000aRunBlock(), and the driver calls it back when block-mode data is ready. The callback function may
check that data is available or detect that an error has occurred, but should not attempt to retrieve captured data
by calling other ps2000a functions. After the callback function has returned, another part of your application can
download the data using ps2000aGetValues().
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* pParameter, a void pointer passed from ps2000aRunBlock(). Your callback function can write to this
location to send any data, such as a status flag, back to your application.
Returns nothing
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_HANDLE_INVALID
PICO_USER_CALLBACK
PICO_DRIVER_FUNCTION
This is a callback function that you write to collect data from the driver. You supply a pointer to the function when
you call ps2000aGetValuesAsync, and the driver calls your function back when the data is ready.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
overflow, a set of flags that indicates whether an overvoltage has occurred and on which channels. It is a bit
field with bit 0 representing Channel A.
* pParameter, a void pointer passed from ps2000aGetValuesAsync(). The callback function can write
to this location to send any data, such as a status flag, back to the application. The data type is defined by the
application programmer.
Returns nothing
This function counts the number of unopened PicoScope 2000 Series (A API) units connected to the computer
and returns a list of serial numbers as a string. It does not detect units that already have a handle assigned to
them by the driver.
Arguments
* count, on exit, the number of ps2000a units found.
* serials, on exit, a list of serial numbers separated by commas and terminated by a final null.
Example: AQ005/139,VDR61/356,ZOR14/107
* serialLth, on entry, the length of the char buffer pointed to by serials; on exit, the length of the string
written to serials
Returns PICO_OK
PICO_BUSY
PICO_NULL_PARAMETER
PICO_FW_FAIL
PICO_CONFIG_FAIL
PICO_MEMORY_FAIL
PICO_CONFIG_FAIL_AWG
PICO_INITIALISE_FPGA
This function flashes the LED on the front of the scope without blocking the calling thread. Calls to
ps2000aRunStreaming() and ps2000aRunBlock() cancel any flashing started by this function. It is not
possible to set the LED to be constantly illuminated, as this state is used to indicate that the scope has not been
initialized.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_HANDLE_INVALID
PICO_BUSY
PICO_DRIVER_FUNCTION
PICO_NOT_RESPONDING
This function is used to get the maximum and minimum allowable analog offset for a specific voltage range.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
range, the voltage range to be used when gathering the min and max information.
* maximumVoltage, output: maximum voltage allowed for the range. Pointer will be ignored if NULL. If device
does not support analog offset, zero will be returned.
* minimumVoltage, output: minimum voltage allowed for the range. Pointer will be ignored if NULL. If device
does not support analog offset, zero will be returned.
If both maximumVoltage and minimumVoltage are NULL, the driver will return PICO_NULL_PARAMETER.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_INVALID_VOLTAGE_RANGE
PICO_NULL_PARAMETER
Arguments
handle, device identifier returned by ps2000aOpenUnit().
info, the type of information required. The following value is currently supported:
PS2000A_CI_RANGES
* ranges, an array that will be populated with available PS2000A_RANGE values for the given info. If NULL,
length is set to the number of ranges available.
* length, input: length of ranges array; output: number of elements written to ranges array.
Returns PICO_OK
PICO_HANDLE_INVALID
PICO_BUSY
PICO_DRIVER_FUNCTION
PICO_NOT_RESPONDING
PICO_NULL_PARAMETER
PICO_INVALID_CHANNEL
PICO_INVALID_INFO
This function returns the maximum downsampling ratio that can be used for a given number of samples in a
given downsampling mode.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NO_SAMPLES_AVAILABLE
PICO_NULL_PARAMETER
PICO_INVALID_PARAMETER
PICO_SEGMENT_OUT_OF_RANGE
PICO_TOO_MANY_SAMPLES
This function returns the maximum number of segments allowed for the opened variant. Refer to
ps2000aMemorySegments() for specific figures.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_NULL_PARAMETER
This function finds out how many captures are available in rapid block mode after ps2000aRunBlock() has
been called. It can be called during data capture, or after the normal end of collection, or after data collection was
terminated by ps2000aStop(). The returned value (* nCaptures) can then be used to iterate through the
number of segments using ps2000aGetValues(), or in a single call to ps2000aGetValuesBulk() where
it is used to calculate the toSegmentIndex parameter.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* nCaptures, output: the number of available captures that has been collected from calling
ps2000aRunBlock().
Returns PICO_OK
PICO_DRIVER_FUNCTION
PICO_INVALID_HANDLE
PICO_NOT_RESPONDING
PICO_NO_SAMPLES_AVAILABLE
PICO_NULL_PARAMETER
PICO_INVALID_PARAMETER
PICO_SEGMENT_OUT_OF_RANGE
PICO_TOO_MANY_SAMPLES
This function finds out how many captures in rapid block mode have been processed after
ps2000aRunBlock() has been called and the collection is either still in progress, completed, or interrupted by
a call to ps2000aStop().
It is mainly intended for use while capture is still in progress and you are collecting data using
ps2000aGetValuesOverlappedBulk(). The returned value (* nCaptures) indicates how many captures
have been completed and therefore how many buffer segments have been filled.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* nCaptures, output: the number of available captures resulting from the call to ps2000aRunBlock().
Returns PICO_OK
PICO_DRIVER_FUNCTION
PICO_INVALID_HANDLE
PICO_NO_SAMPLES_AVAILABLE
PICO_NULL_PARAMETER
PICO_INVALID_PARAMETER
PICO_SEGMENT_OUT_OF_RANGE
PICO_TOO_MANY_SAMPLES
This function instructs the driver to return the next block of values to your ps2000aStreamingReady()
callback function. You must have previously called ps2000aRunStreaming() beforehand to set up streaming.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* pParameter, a void pointer that will be passed to the ps2000aStreamingReady() callback function.
The callback function may optionally use this pointer to return information to the application.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NO_SAMPLES_AVAILABLE
PICO_INVALID_CALL
PICO_BUSY
PICO_NOT_RESPONDING
PICO_DRIVER_FUNCTION
This function calculates the sampling rate and maximum number of samples for a given timebase under the
specified conditions. The result depends on the number of channels enabled by the last call to
ps2000aSetChannel().
This function is provided for use with programming languages that do not support the float data type. The value
returned in the timeIntervalNanoseconds argument is restricted to integers. If your programming language
supports the float type, we recommend that you use ps2000aGetTimebase2() instead.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* timeIntervalNanoseconds, on exit, the time interval between readings at the selected timebase. Use
NULL if not required. In ETS mode this argument is not valid; use the sample time returned by
ps2000aSetEts() instead.
* maxSamples, on exit, the maximum number of samples available. The scope allocates a certain amount
of memory for internal overheads and this may vary depending on the number of segments, number of channels
enabled, and the timebase chosen. Use NULL if not required.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_TOO_MANY_SAMPLES
PICO_INVALID_CHANNEL
PICO_INVALID_TIMEBASE
PICO_INVALID_PARAMETER
PICO_SEGMENT_OUT_OF_RANGE
PICO_DRIVER_FUNCTION
This function is an upgraded version of ps2000aGetTimebase(), and returns the time interval as a float
rather than a long. This allows it to return sub-nanosecond time intervals. See ps2000aGetTimebase() for a
full description.
Arguments
* timeIntervalNanoseconds, a pointer to the time interval between readings at the selected timebase. If a
null pointer is passed, nothing will be written here.
This function retrieves the time offset, as lower and upper 32-bit values, for a waveform obtained in block mode
or rapid block mode. The time offset of a waveform is the delay from the trigger sampling instant to the time at
which the driver estimates the waveform to have crossed the trigger threshold. You can add this offset to the
time of each sample in the waveform to reduce trigger jitter. Without using the time offset, trigger jitter can be up
to 1 sample period; adding the time offset reduces jitter to a small fraction of a sample period.
Call it after block-mode data has been captured or when data has been retrieved from a previous block-mode
capture. A 64-bit version of this function, ps2000aGetTriggerTimeOffset64(), is also available.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* timeUpper, on exit, the upper 32 bits of the time at which the trigger point occurred
* timeLower, on exit, the lower 32 bits of the time at which the trigger point occurred
* timeUnits, returns the time units in which timeUpper and timeLower are measured. The allowable
values are:
PS2000A_FS
PS2000A_PS
PS2000A_NS
PS2000A_US
PS2000A_MS
PS2000A_S
segmentIndex, the number of the memory segment for which the information is required.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DEVICE_SAMPLING
PICO_SEGMENT_OUT_OF_RANGE
PICO_NOT_USED_IN_THIS_CAPTURE_MODE
PICO_NOT_RESPONDING
PICO_NULL_PARAMETER
PICO_NO_SAMPLES_AVAILABLE
PICO_DRIVER_FUNCTION
This function retrieves the time offset for a waveform obtained in block mode or rapid block mode. The time
offset of a waveform is the delay from the trigger sampling instant to the time at which the driver estimates the
waveform to have crossed the trigger threshold. You can add this offset to the time of each sample in the
waveform to reduce trigger jitter. Without using the time offset, trigger jitter can be up to 1 sample period; adding
the time offset reduces jitter to a small fraction of a sample period.
Call it after block-mode data has been captured or when data has been retrieved from a previous block-mode
capture. A 32-bit version of this function, ps2000aGetTriggerTimeOffset(), is also available.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* timeUnits, on exit, the time units in which time is measured. The possible values are:
PS2000A_FS
PS2000A_PS
PS2000A_NS
PS2000A_US
PS2000A_MS
PS2000A_S
segmentIndex, the number of the memory segment for which the information is required.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DEVICE_SAMPLING
PICO_SEGMENT_OUT_OF_RANGE
PICO_NOT_USED_IN_THIS_CAPTURE_MODE
PICO_NOT_RESPONDING
PICO_NULL_PARAMETER
PICO_NO_SAMPLES_AVAILABLE
PICO_DRIVER_FUNCTION
This function retrieves information about the specified oscilloscope. If the device fails to open, or no device is
opened only the driver version is available.
Arguments
handle, device identifier returned by ps2000aOpenUnit(). If an invalid handle is passed, only the driver
versions can be read.
* string, on exit, the unit information string selected specified by the info argument. If string is NULL,
only requiredSize is returned.
info, a number specifying what information is required. The possible values are listed in the table below.
info Example
0 PICO_DRIVER_VERSION 1.0.0.1
Version number of PicoScope 2000A DLL
1 PICO_USB_VERSION 2.0
Type of USB connection to device: 1.1 or 2.0
2 PICO_HARDWARE_VERSION 1
Hardware version of device
3 PICO_VARIANT_INFO 2206
Variant number of device
4 PICO_BATCH_AND_SERIAL KJL87/006
Batch and serial number of device
5 PICO_CAL_DATE 30Sep09
Calibration date of device
6 PICO_KERNEL_VERSION 1.0
Version of kernel driver
7 PICO_DIGITAL_HARDWARE_VERSION 1
Hardware version of the digital section
8 PICO_ANALOGUE_HARDWARE_VERSION 1
Hardware version of the analog section
9 PICO_FIRMWARE_VERSION_1 1.0.0.0
10 PICO_FIRMWARE_VERSION_2 1.0.0.0
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NULL_PARAMETER
PICO_INVALID_INFO
PICO_INFO_UNAVAILABLE
PICO_DRIVER_FUNCTION
This function retrieves block-mode data, either with or without downsampling, starting at the specified sample
number. It is used to get the stored data from the scope after data collection has stopped, and store it in a user
buffer previously passed to ps2000aSetDataBuffer() or ps2000aSetDataBuffers(). It blocks the
calling function while retrieving data.
If multiple channels are enabled, a single call to this function is sufficient to retrieve data for all channels.
Note that if you are using block mode and call this function before the oscilloscope is ready, no capture will be
available and the driver will return PICO_NO_SAMPLES_AVAILABLE.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
startIndex, a zero-based index that indicates the start point for data collection. It is measured in sample
intervals from the start of the buffer.
* noOfSamples, on entry, the number of samples required. On exit, the actual number retrieved. The number
of samples retrieved will not be more than the number requested, and the data retrieved starts at startIndex.
downSampleRatio, the downsampling factor that will be applied to the raw data.
AGGREGATE, AVERAGE, DECIMATE are single-bit constants that can be ORed to apply multiple
downsampling modes to the same data.
segmentIndex, the zero-based number of the memory segment where the data is stored.
* overflow, on exit, a set of flags that indicate whether an overvoltage has occurred on any of the channels.
It is a bit field with bit 0 denoting Channel A.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NO_SAMPLES_AVAILABLE
PICO_DEVICE_SAMPLING
PICO_NULL_PARAMETER
PICO_SEGMENT_OUT_OF_RANGE
PICO_STARTINDEX_INVALID
PICO_ETS_NOT_RUNNING
PICO_BUFFERS_NOT_SET
PICO_INVALID_PARAMETER
PICO_TOO_MANY_SAMPLES
PICO_DATA_NOT_AVAILABLE
PICO_STARTINDEX_INVALID
PICO_INVALID_SAMPLERATIO
PICO_INVALID_CALL
PICO_NOT_RESPONDING
PICO_MEMORY
PICO_RATIO_MODE_NOT_SUPPORTED
PICO_DRIVER_FUNCTION
You specify the downsampling mode when you call one of the data collection functions such as
ps2000aGetValues(). The following modes are available:
1. Call ps2000aStop().
2. Set up a data buffer for each channel using ps2000aSetDataBuffer() with the ratio mode set to
PS2000A_RATIO_MODE_NONE.
This function returns data either with or without downsampling, starting at the specified sample number. It is
used to get the stored data from the scope after data collection has stopped. It returns the data using a callback
so as not to block the calling function. It can also be used in streaming mode to retrieve data from the driver, but
in this case it blocks the calling function.
If multiple channels are enabled, a single call to this function is sufficient to retrieve data for all channels.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* lpDataReady, a pointer to the user-supplied function that will be called when the data is ready. This will be
a ps2000aDataReady() function for block-mode data or a ps2000aStreamingReady() function for
streaming-mode data.
* pParameter, a void pointer that will be passed to the callback function. The data type is determined by the
application.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NO_SAMPLES_AVAILABLE
PICO_DEVICE_SAMPLING
PICO_NULL_PARAMETER
PICO_STARTINDEX_INVALID
PICO_SEGMENT_OUT_OF_RANGE
PICO_INVALID_PARAMETER
PICO_DATA_NOT_AVAILABLE
PICO_INVALID_SAMPLERATIO
PICO_INVALID_CALL
PICO_DRIVER_FUNCTION
This function retrieves waveforms captured using rapid block mode. The waveforms must have been collected
sequentially and in the same run.
If multiple channels are enabled, a single call to this function is sufficient to retrieve data for all channels.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* noOfSamples, on entry, the number of samples required; on exit, the actual number retrieved. The number
of samples retrieved will not be more than the number requested. The data retrieved always starts with the first
sample captured.
fromSegmentIndex, the first segment from which the waveform should be retrieved.
toSegmentIndex, the last segment from which the waveform should be retrieved.
* overflow, an array of integers equal to or larger than the number of waveforms to be retrieved. Each
segment index has a corresponding entry in the overflow array, with overflow[0] containing the flags for
the segment numbered fromSegmentIndex and the last element in the array containing the flags for the
segment numbered toSegmentIndex. Each element in the array is a bit field as described under
ps2000aGetValues().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_PARAMETER
PICO_INVALID_SAMPLERATIO
PICO_ETS_NOT_RUNNING
PICO_BUFFERS_NOT_SET
PICO_TOO_MANY_SAMPLES
PICO_SEGMENT_OUT_OF_RANGE
PICO_NO_SAMPLES_AVAILABLE
PICO_NOT_RESPONDING
PICO_DRIVER_FUNCTION
This function allows you to make a deferred data-collection request in block mode. The request will be executed,
and the arguments validated, when you call ps2000aRunBlock(). The advantage of this function is that the
driver makes contact with the scope only once, when you call ps2000aRunBlock(), compared with the two
contacts that occur when you use the conventional ps2000aRunBlock(), ps2000aGetValues() calling
sequence. This slightly reduces the dead time between successive captures in block mode.
After calling ps2000aRunBlock(), you can optionally use ps2000aGetValues() to request further copies
of the data. This might be required if you wish to display the data with different data reduction settings.
If multiple channels are enabled, a single call to this function is sufficient to retrieve data for all channels.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* noOfSamples, on entry, the number of raw samples to be collected before any downsampling is applied.
On exit, the actual number stored in the buffer. The number of samples retrieved will not be more than the number
requested, and the data retrieved starts at startIndex.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_PARAMETER
PICO_DRIVER_FUNCTION
3. Using ps2000aGetTimebase(), select timebases until the required nanoseconds per sample is located.
5. Wait until the oscilloscope is ready using the ps2000aBlockReady() callback (or poll using
ps2000aIsReady()).
6. Use ps2000aSetDataBuffer() to tell the driver where your memory buffer is.
7. Set up the transfer of the block of data from the oscilloscope using ps2000aGetValuesOverlapped().
A similar procedure can be used with rapid block mode and ps2000aGetValuesOverlappedBulk().
This function allows you to make a deferred data-collection request, which will later be executed, and the
arguments validated, when you call ps2000aRunBlock() in rapid block mode. The advantage of this method is
that the driver makes contact with the scope only once, when you call ps2000aRunBlock(), compared with
the two contacts that occur when you use the conventional ps2000aRunBlock(),
ps2000aGetValuesBulk() calling sequence. This slightly reduces the dead time between successive
captures in rapid block mode.
After calling ps2000aRunBlock(), you can optionally use ps2000aGetValues() to request further copies
of the data. This might be required if you wish to display the data with different data reduction settings.
If multiple channels are enabled, a single call to this function is sufficient to retrieve data for all channels.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_PARAMETER
PICO_DRIVER_FUNCTION
This function retrieves the time offsets, as lower and upper 32-bit values, for waveforms obtained in rapid block
mode. The time offset of a waveform is the delay from the trigger sampling instant to the time at which the driver
estimates the waveform to have crossed the trigger threshold. You can add this offset to the time of each sample
in the waveform to reduce trigger jitter. Without using the time offset, trigger jitter can be up to 1 sample period;
adding the time offset reduces jitter to a small fraction of a sample period.
This function is provided for use in programming environments that do not support 64-bit integers. If your
programming environment supports this data type, it is easier to use
ps2000aGetValuesTriggerTimeOffsetBulk64().
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* timesUpper, an array of integers. On exit, the most significant 32 bits of the time offset for each requested
segment index. times[0] will hold the fromSegmentIndex time offset and the last times index will hold
the toSegmentIndex time offset. The array must be long enough to hold the number of requested times.
* timesLower, an array of integers. On exit, the least significant 32 bits of the time offset for each requested
segment index. times[0] will hold the fromSegmentIndex time offset and the last times index will hold
the toSegmentIndex time offset. The array size must be long enough to hold the number of requested times.
* timeUnits, an array of integers. The array must be long enough to hold the number of requested times. On
exit, timeUnits[0] will contain the time unit for fromSegmentIndex and the last element will contain the
time unit for toSegmentIndex. Refer to ps2000aGetTriggerTimeOffset() for allowable values.
fromSegmentIndex, the first segment for which the time offset is required.
toSegmentIndex, the last segment for which the time offset is required. If toSegmentIndex is less than
fromSegmentIndex then the driver will wrap around from the last segment to the first.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NOT_USED_IN_THIS_CAPTURE_MODE
PICO_NOT_RESPONDING
PICO_NULL_PARAMETER
PICO_DEVICE_SAMPLING
PICO_SEGMENT_OUT_OF_RANGE
PICO_NO_SAMPLES_AVAILABLE
PICO_DRIVER_FUNCTION
This function retrieves the 64-bit time offsets for waveforms captured in rapid block mode.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* times, an array of integers. On exit, this will hold the time offset for each requested segment index.
times[0] will hold the time offset for fromSegmentIndex, and the last times index will hold the time
offset for toSegmentIndex. The array must be long enough to hold the number of times requested.
* timeUnits, an array of integers long enough to hold the number of requested times. timeUnits[0] will
contain the time unit for fromSegmentIndex, and the last element will contain the toSegmentIndex. Refer
to ps2000aGetTriggerTimeOffset64() for specific figures.
fromSegmentIndex, the first segment for which the time offset is required. The results for this segment will
be placed in times[0] and timeUnits[0].
toSegmentIndex, the last segment for which the time offset is required. The results for this segment will be
placed in the last elements of the times and timeUnits arrays. If toSegmentIndex is less than
fromSegmentIndex then the driver will wrap around from the last segment to the first.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NOT_USED_IN_THIS_CAPTURE_MODE
PICO_NOT_RESPONDING
PICO_NULL_PARAMETER
PICO_DEVICE_SAMPLING
PICO_SEGMENT_OUT_OF_RANGE
PICO_NO_SAMPLES_AVAILABLE
PICO_DRIVER_FUNCTION
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
This function may be used instead of a callback function to receive data from ps2000aRunBlock(). To use
this method, pass a NULL pointer as the lpReady argument to ps2000aRunBlock(). You must then poll the
driver to see if it has finished collecting the requested samples.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* ready, output: indicates the state of the collection. If zero, the device is still collecting. If non-zero, the device
has finished collecting and ps2000aGetValues() can be used to retrieve the data.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_NULL_PARAMETER
PICO_NO_SAMPLES_AVAILABLE
PICO_CANCELLED
PICO_NOT_RESPONDING
3.27 ps2000aIsTriggerOrPulseWidthQualifierEnabled() –
get trigger status
PICO_STATUS ps2000aIsTriggerOrPulseWidthQualifierEnabled
(
int16_t handle,
int16_t * triggerEnabled,
int16_t * pulseWidthQualifierEnabled
)
Applicability Call after setting up the trigger, and just before calling either ps2000aRunBlock() or
ps2000aRunStreaming().
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* triggerEnabled, on exit, indicates whether the trigger will successfully be set when
ps2000aRunBlock() or ps2000aRunStreaming() is called. A non-zero value indicates that the trigger is
set, zero that the trigger is not set.
* pulseWidthQualifierEnabled, on exit, indicates whether the pulse width qualifier will successfully be
set when ps2000aRunBlock() or ps2000aRunStreaming() is called. A non-zero value indicates that the
pulse width qualifier is set, zero that the pulse width qualifier is not set.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NULL_PARAMETER
PICO_DRIVER_FUNCTION
This function returns the maximum ADC count returned by calls to the GetValues functions.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_USER_CALLBACK
PICO_INVALID_HANDLE
PICO_TOO_MANY_SEGMENTS
PICO_MEMORY
PICO_DRIVER_FUNCTION
This function sets the number of memory segments that the scope will use.
When the scope is opened, the number of segments defaults to 1, meaning that each capture fills the scope's
available memory. This function allows you to divide the memory into a number of segments so that the scope
can store several waveforms sequentially.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
nSegments, the number of segments required. Minimum: 1. Maximum: varies according to oscilloscope model
– refer to datasheet.
* nMaxSamples, on exit, the number of samples available in each segment. This is the total number over all
channels, so if two channels or 8-bit MSO ports are in use, the number of samples available to each channel is
nMaxSamples divided by 2; and for 3 or 4 channels or MSO ports divide by 4.
Returns PICO_OK
PICO_USER_CALLBACK
PICO_INVALID_HANDLE
PICO_TOO_MANY_SEGMENTS
PICO_MEMORY
PICO_DRIVER_FUNCTION
This function returns the minimum ADC count returned by calls to the GetValues functions.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_USER_CALLBACK
PICO_INVALID_HANDLE
PICO_TOO_MANY_SEGMENTS
PICO_MEMORY
PICO_DRIVER_FUNCTION
This function returns the number of raw samples stored in the driver after data collection in streaming mode. Call
it after calling ps2000aStop().
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NULL_PARAMETER
PICO_NO_SAMPLES_AVAILABLE
PICO_NOT_USED
PICO_BUSY
PICO_DRIVER_FUNCTION
This function opens a PicoScope 2000 Series (A API) scope attached to the computer. The maximum number of
units that can be opened depends on the operating system, the kernel driver and the computer.
Arguments
* handle, on exit, the result of the attempt to open a scope:
–1 : if the scope fails to open
0 : if no scope is found
> 0 : a number that uniquely identifies the scope
If a valid handle is returned, it must be used in all subsequent calls to API functions to identify this scope.
* serial, on entry, a null-terminated string containing the serial number of the scope to be opened. If
serial is NULL then the function opens the first scope found; otherwise, it tries to open the scope that matches
the string.
Returns PICO_OK
PICO_OS_NOT_SUPPORTED
PICO_OPEN_OPERATION_IN_PROGRESS
PICO_EEPROM_CORRUPT
PICO_KERNEL_DRIVER_TOO_OLD
PICO_FPGA_FAIL
PICO_MEMORY_CLOCK_FREQUENCY
PICO_FW_FAIL
PICO_MAX_UNITS_OPENED
PICO_NOT_FOUND (if the specified unit was not found)
PICO_NOT_RESPONDING
PICO_MEMORY_FAIL
PICO_ANALOG_BOARD
PICO_CONFIG_FAIL_AWG
PICO_INITIALISE_FPGA
This function opens a scope without blocking the calling thread. You can find out when it has finished by
periodically calling ps2000aOpenUnitProgress() until that function returns a non-zero value.
Arguments
* status, a status code:
0 if the open operation was disallowed because another open operation is in progress
1 if the open operation was successfully started
Returns PICO_OK
PICO_OPEN_OPERATION_IN_PROGRESS
PICO_OPERATION_FAILED
This function checks on the progress of a request made to ps2000aOpenUnitAsync() to open a scope.
Arguments
* handle, see ps2000aOpenUnit(). This handle is valid only if the function returns PICO_OK.
* progressPercent, on exit, the percentage progress towards opening the scope. 100% implies that the
open operation is complete.
Returns PICO_OK
PICO_NULL_PARAMETER
PICO_OPERATION_FAILED
This function can be used to check that the already opened device is still connected to the USB port and
communication is successful.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_BUSY
PICO_NOT_RESPONDING
This function obtains the state of the edge-detect flag, which is described in
ps2000aSetOutputEdgeDetect().
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
This function starts collecting data in block mode. For a step-by-step guide to this process, see Using block
mode.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
timebase, a number in the range 0 to 23 2 –1. See the guide to calculating timebase values. This argument is
ignored in ETS mode, when ps2000aSetEts() selects the timebase instead.
* timeIndisposedMs, on exit, the time, in milliseconds, that the scope will spend collecting samples. This
does not include any auto trigger timeout. It is not valid in ETS capture mode. The pointer can be set to null if a
value is not required.
lpReady, a pointer to the ps2000aBlockReady() callback function that the driver will call when the data
has been collected. To use the ps2000aIsReady() polling method instead of a callback function, set this
pointer to NULL.
* pParameter, a void pointer that is passed to the ps2000aBlockReady() callback function. The
callback can use this pointer to return arbitrary data to the application.
Returns PICO_OK
PICO_BUFFERS_NOT_SET (in Overlapped mode)
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_SEGMENT_OUT_OF_RANGE
PICO_INVALID_CHANNEL
PICO_INVALID_TRIGGER_CHANNEL
PICO_INVALID_CONDITION_CHANNEL
PICO_TOO_MANY_SAMPLES
PICO_INVALID_TIMEBASE
PICO_NOT_RESPONDING
PICO_CONFIG_FAIL
PICO_INVALID_PARAMETER
PICO_NOT_RESPONDING
PICO_TRIGGER_ERROR
PICO_DRIVER_FUNCTION
PICO_FW_FAIL
PICO_NOT_ENOUGH_SEGMENTS (in Bulk mode)
PICO_PULSE_WIDTH_QUALIFIER
PICO_SEGMENT_OUT_OF_RANGE (in Overlapped mode)
PICO_STARTINDEX_INVALID (in Overlapped mode)
PICO_INVALID_SAMPLERATIO (in Overlapped mode)
PICO_CONFIG_FAIL
This function tells the oscilloscope to start collecting data in streaming mode. When data has been collected
from the device it is downsampled if necessary and then delivered to the application. Call
ps2000aGetStreamingLatestValues() to retrieve the data. See Using streaming mode for a step-by-step
guide to this process.
The function always starts collecting data immediately, regardless of the trigger settings. Whether a trigger is set
or not, the total number of samples stored in the driver is always maxPreTriggerSamples +
maxPostTriggerSamples. If autoStop is false, the scope will collect data continuously using the buffer as
a first-in first-out (FIFO) memory.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* sampleInterval, on entry, the requested time interval between samples; on exit, the actual time interval
used.
sampleIntervalTimeUnits, the unit of time used for sampleInterval. Use one of these values:
PS2000A_FS
PS2000A_PS
PS2000A_NS
PS2000A_US
PS2000A_MS
PS2000A_S
maxPreTriggerSamples, the maximum number of raw samples before a trigger event for each enabled
channel.
maxPostTriggerSamples, the maximum number of raw samples after a trigger event for each enabled
channel.
autoStop, a flag that specifies if the streaming should stop when all of maxSamples =
maxPreTriggerSamples + maxPostTriggerSamples have been captured. This can only happen after a
trigger event.
overviewBufferSize, the size of the overview buffers. These are temporary buffers used for storing the
data before returning it to the application. The size is the same as the bufferLth value passed to
ps2000aSetDataBuffer().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_ETS_MODE_SET
PICO_USER_CALLBACK
PICO_NULL_PARAMETER
PICO_INVALID_PARAMETER
PICO_STREAMING_FAILED
PICO_NOT_RESPONDING
PICO_TRIGGER_ERROR
PICO_INVALID_SAMPLE_INTERVAL
PICO_INVALID_BUFFER
PICO_DRIVER_FUNCTION
PICO_FW_FAIL
PICO_MEMORY
This function specifies whether an input channel is to be enabled, its input coupling type, voltage range, analog
offset.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
analogOffset, a voltage to add to the input channel before digitization. The allowable range of offsets can be
obtained from ps2000aGetAnalogueOffset() and depends on the input range selected for the channel.
This argument is ignored if the device is a PicoScope 2205 MSO.
Returns PICO_OK
PICO_USER_CALLBACK
PICO_INVALID_HANDLE
PICO_INVALID_CHANNEL
PICO_INVALID_VOLTAGE_RANGE
PICO_INVALID_COUPLING
PICO_INVALID_ANALOGUE_OFFSET
PICO_DRIVER_FUNCTION
This function tells the driver where to store the data, either unprocessed or downsampled, that will be returned
after the next call to one of the ps2000aGetValues...() functions. The function only allows you to specify a
single buffer, so for aggregation mode, which requires two buffers, you need to call
ps2000aSetDataBuffers() instead.
You must allocate memory for the buffer before calling this function.
Applicability Block, rapid block and streaming modes. All downsampling modes except aggregation.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
channel, the channel you want to use with the buffer. Use one of these values:
PS2000A_CHANNEL_A
PS2000A_CHANNEL_B
PS2000A_CHANNEL_C
PS2000A_CHANNEL_D
PS2000A_DIGITAL_PORT0 = 0x80 (MSO models only)
PS2000A_DIGITAL_PORT1 = 0x81 (MSO models only)
buffer, pointer to the buffer. Each sample written to the buffer will be a 16-bit ADC count scaled according to
the selected voltage range.
mode, the downsampling mode. See ps2000aGetValues() for the available modes, but note that a single
call to ps2000aSetDataBuffer() can only associate one buffer with one downsampling mode. If you intend
to call ps2000aGetValues() with more than one downsampling mode activated, then you must call
ps2000aSetDataBuffer() several times to associate a separate buffer with each downsampling mode.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_CHANNEL
PICO_RATIO_MODE_NOT_SUPPORTED
PICO_SEGMENT_OUT_OF_RANGE
PICO_DRIVER_FUNCTION
PICO_INVALID_PARAMETER
This function tells the driver the location of one or two buffers for receiving data. You need to allocate memory for
the buffers before calling this function. If you do not need two buffers because you are not using aggregate
mode, you can optionally use ps2000aSetDataBuffer() instead.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
channel, the channel for which you want to set the buffers. Use one of these constants:
PS2000A_CHANNEL_A
PS2000A_CHANNEL_B
PS2000A_CHANNEL_C
PS2000A_CHANNEL_D
PS2000A_DIGITAL_PORT0 = 0x80 (MSO models only)
PS2000A_DIGITAL_PORT1 = 0x81 (MSO models only)
bufferMax, a user-allocated buffer to receive the maximum data values in aggregation mode, or the non-
aggregated values otherwise. Each value is a 16-bit ADC count scaled according to the selected voltage range.
bufferMin, a user-allocated buffer to receive the minimum data values in aggregation mode. Not normally
used in other modes, but you can direct the driver to write non-aggregated values to this buffer by setting
bufferMax to NULL. To enable aggregation, the downsampling ratio and mode must be set appropriately when
calling one of the ps2000aGetValues...() functions.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_CHANNEL
PICO_RATIO_MODE_NOT_SUPPORTED
PICO_SEGMENT_OUT_OF_RANGE
PICO_DRIVER_FUNCTION
PICO_INVALID_PARAMETER
Mixed-signal (MSO) models in this series have two independent triggers, one for the analog input channels and
another for the digital inputs. This function defines how the two triggers are combined.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_NOT_USED
PICO_INVALID_PARAMETER
This function is used to enable the digital ports of an MSO and set the logic level (the voltage point at which the
state transitions from 0 to 1).
Arguments
handle, device identifier returned by ps2000aOpenUnit().
enabled, whether or not to enable the port. Enabling a digital port allows the scope to collect data from the port
and to trigger on the port. Enabling a digital port may also increase the memory usage of the scope (see Block
mode). The values are:
TRUE: enable
FALSE: do not enable
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_CHANNEL
PICO_RATIO_MODE_NOT_SUPPORTED
PICO_SEGMENT_OUT_OF_RANGE
PICO_DRIVER_FUNCTION
PICO_INVALID_PARAMETER
This function is used to enable or disable ETS (equivalent-time sampling) and to set the ETS parameters. See
ETS overview for an explanation of ETS mode.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
etsCycles, the number of cycles to store. The computer can then select etsInterleave cycles to give the
most uniform spread of samples. Maximum values are:
500 for the PicoScope 2206B, 2206B MSO, 2207B, 2207B MSO, 2208B, 2208B MSO, 2405A, 2406B, 2407B,
2408B
PS2206_MAX_ETS_CYCLES for the PicoScope 2206, 2206A
PS2207_MAX_ETS_CYCLES for the PicoScope 2207, 2207A
PS2208_MAX_ETS_CYCLES for the PicoScope 2208, 2208A
etsInterleave, the number of waveforms to combine into a single ETS capture. Maximum values are:
40 for the PicoScope 2206B, 2206B MSO, 2207B, 2207B MSO, 2208B, 2208B MSO, 2405A, 2406B, 2407B,
2408B
PS2206_MAX_INTERLEAVE for the PicoScope 2206, 2206A
PS2207_MAX_INTERLEAVE for the PicoScope 2207, 2207A
PS2208_MAX_INTERLEAVE for the PicoScope 2208, 2208A
* sampleTimePicoseconds, on exit, the effective sampling interval of the ETS data. For example, if the
captured sample time is 4 ns and etsInterleave is 10, then the effective sample time in ETS mode is 400 ps.
Returns PICO_OK
PICO_USER_CALLBACK
PICO_INVALID_HANDLE
PICO_INVALID_PARAMETER
PICO_DRIVER_FUNCTION
This function tells the driver where to find your application's ETS time buffers. These buffers contain the 64-bit
timing information for each ETS sample after you run a block-mode ETS capture.
If your programming language does not support 64-bit data, use the 32-bit version
ps2000aSetEtsTimeBuffers() instead.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* buffer, an array of 64-bit words, each representing the time in femtoseconds (10–15 s) at which the sample
was captured.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NULL_PARAMETER
PICO_DRIVER_FUNCTION
This function tells the driver where to find your application's ETS time buffers. These buffers contain the timing
information for each ETS sample after you run a block-mode ETS capture. There are two buffers containing the
upper and lower 32-bit parts of the timing information, to allow programming languages that do not support 64-bit
data to retrieve the timings.
If your programming language supports 64-bit data then you can use
ps2000aSetEtsTimeBuffer() instead.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
* timeUpper, an array of 32-bit words, each representing the upper 32 bits of the time in femtoseconds (10–
15 s) at which the sample was captured
* timeLower, an array of 32-bit words, each representing the lower 32 bits of the time in femtoseconds (10–
15 s) at which the sample was captured
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NULL_PARAMETER
PICO_DRIVER_FUNCTION
This function sets the number of captures to be collected in one run of rapid block mode. If you do not call this
function before a run, the driver will capture only one waveform. Once a value has been set, the value remains
constant unless changed.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_INVALID_PARAMETER
PICO_DRIVER_FUNCTION
This function tells the device whether or not to wait for an edge on the trigger input when one of the 'level' or
'window' trigger types is in use. By default the device waits for an edge on the trigger input before firing the trigger.
If you switch off edge detect mode, the device will trigger continually for as long as the trigger input remains in
the specified state.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
This function will set the individual digital channels' pulse-width trigger directions. Each trigger direction consists
of a channel name and a direction. If the channel is not included in the array of
PS2000A_DIGITAL_CHANNEL_DIRECTIONS the driver assumes the digital channel's pulse-width trigger
direction is PS2000A_DIGITAL_DONT_CARE.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
nDirections, the number of digital channel directions being passed to the driver.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_INVALID_DIGITAL_CHANNEL
PICO_INVALID_DIGITAL_TRIGGER_DIRECTION
This function sets up pulse-width qualification, which can be used on its own for pulse-width triggering or
combined with threshold triggering, level triggering or window triggering to produce more complex triggers. The
pulse-width qualifier is set by defining one or more structures that are then ORed together. Each structure is itself
the AND of the states of one or more of the inputs. This AND-OR logic allows you to create any possible Boolean
function of the scope's inputs.
Note: The oscilloscope contains a single pulse-width counter. It is possible to include multiple channels in a
pulse-width qualifier but the same pulse-width counter will apply to all of them. The counter starts when your
selected trigger condition occurs, and the scope then triggers if the trigger condition ends after a time that
satisfies the pulse-width condition.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
nConditions, the number of elements in the conditions array. If nConditions is zero then the pulse-
width qualifier is not used.
Range: 0 to PS2000A_MAX_PULSE_WIDTH_QUALIFIER_COUNT.
direction, the direction of the signal required for the pulse width trigger to fire. See
PS2000A_THRESHOLD_DIRECTION constants for the list of possible values. Each channel of the oscilloscope
(except the EXT input, if present) has two thresholds for each direction—for example, PS2000A_RISING and
PS2000A_RISING_LOWER— so that one can be used for the pulse-width qualifier and the other for the level
trigger. The driver will not let you use the same threshold for both triggers; so, for example, you cannot use
PS2000A_RISING as the direction argument for both ps2000aSetTriggerConditions() and
ps2000aSetPulseWidthQualifier() at the same time. There is no such restriction when using window
triggers.
lower, the lower limit of the pulse-width counter, measured in sample periods
upper, the upper limit of the pulse-width counter, measured in sample periods. This parameter is used only
when the type is set to PS2000A_PW_TYPE_IN_RANGE or PS2000A_PW_TYPE_OUT_OF_RANGE.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_CONDITIONS
PICO_PULSE_WIDTH_QUALIFIER
PICO_DRIVER_FUNCTION
A structure of this type is passed to ps2000aSetPulseWidthQualifier in the conditions argument to specify the
pulse-width qualifier conditions for all the trigger sources. Each structure is the logical AND of the states of the
scope's inputs. The ps2000aSetPulseWidthQualifier function can OR together a number of these structures to
produce the final pulse width qualifier, which can therefore be any possible Boolean function of the scope's
inputs.
The structure is byte-aligned. In C++, for example, you should specify this using the #pragma pack()
instruction.
Elements
channelA, channelB, channelC, channelD, external: the type of condition that should be applied
to each channel. Use these constants:
PS2000A_CONDITION_DONT_CARE
PS2000A_CONDITION_TRUE
PS2000A_CONDITION_FALSE
The channels that are set to PS2000A_CONDITION_TRUE or PS2000A_CONDITION_FALSE must all meet
their conditions simultaneously to produce a trigger. Channels set to PS2000A_CONDITION_DONT_CARE are
ignored.
The arbitrary waveform generator uses direct digital synthesis (DDS). It maintains a 32-bit phase accumulator
that indicates the present location in the waveform. The top bits of the phase accumulator are used as an index
into a buffer containing the arbitrary waveform. The remaining bits act as the fractional part of the index, enabling
high-resolution control of output frequency and allowing the generation of lower frequencies.
The phase accumulator initially increments by startDeltaPhase. If the AWG is set to sweep mode, the phase
increment is increased at specified intervals until it reaches stopDeltaPhase. The easiest way to obtain the
values of startDeltaPhase and stopDeltaPhase necessary to generate the desired frequency is to call
ps2000aSigGenFrequencyToPhase(). Alternatively, see Calculating deltaPhase below for more
information on how to calculate these values.
Set up the signal generator before starting data acquisition, particularly if you require it to be triggered during data
acquisition.
This document provides some useful guidance on how to call the API functions in order to trigger the signal
generator output.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
startDeltaPhase, the initial value added to the phase accumulator as the generator begins to step through
the waveform buffer. Calculate this value from the information above, or use
ps2000aSigGenFrequencyToPhase().
stopDeltaPhase, the final value added to the phase accumulator before the generator restarts or reverses the
sweep. When frequency sweeping is not required, set equal to startDeltaPhase.
deltaPhaseIncrement, the amount added to the delta phase value every time the dwellCount period
expires. This determines the amount by which the generator sweeps the output frequency in each dwell period.
When frequency sweeping is not required, set to zero.
* arbitraryWaveform, a buffer that holds the waveform pattern as a set of samples equally spaced in time.
Each sample is scaled to an output voltage as follows:
arbitraryWaveformSize, the size of the arbitrary waveform buffer, in samples, in the range:
[minArbitraryWaveformSize, maxArbitraryWaveformSize]
where minArbitraryWaveformSize and maxArbitraryWaveformSize are the values returned
by ps2000aSigGenArbitraryMinMaxValues().
operation, the type of waveform to be produced, specified by one of the following enumerated types:
PS2000A_ES_OFF, normal AWG operation using the waveform buffer.
PS2000A_WHITENOISE, the signal generator produces white noise and ignores all settings except
offsetVoltage and pkToPk.
PS2000A_PRBS, produces a random bitstream with a bit rate specified by the phase accumulator.
indexMode, specifies how the signal will be formed from the arbitrary waveform data. Single and dual index
modes are possible. Use one of these constants:
PS2000A_SINGLE
PS2000A_DUAL
shots,
0: sweep the frequency as specified by sweeps
1...PS2000A_MAX_SWEEPS_SHOTS: the number of cycles of the waveform to be produced after a
trigger event. sweeps must be zero.
PS2000A_SHOT_SWEEP_TRIGGER_CONTINUOUS_RUN: start and run continuously after trigger occurs
(not PicoScope 2205 MSO)
sweeps,
0: produce number of cycles specified by shots
1..PS2000A_MAX_SWEEPS_SHOTS: the number of times to sweep the frequency after a trigger event,
according to sweepType. shots must be zero.
PS2000A_SHOT_SWEEP_TRIGGER_CONTINUOUS_RUN: start a sweep and continue after trigger occurs
(not PicoScope 2205 MSO)
triggerType, the type of trigger that will be applied to the signal generator:
PS2000A_SIGGEN_RISING trigger on rising edge
PS2000A_SIGGEN_FALLING trigger on falling edge
PS2000A_SIGGEN_GATE_HIGH run while trigger is high
PS2000A_SIGGEN_GATE_LOW run while trigger is low
A trigger event causes the signal generator to produce the specified number of shots or sweeps.
When triggering is enabled (trigger source set to something other than P2000A_SIGGEN_NONE), either
shots or sweeps, but not both, must be non-zero.
Returns PICO_OK
PICO_AWG_NOT_SUPPORTED
PICO_BUSY
PICO_INVALID_HANDLE
PICO_SIG_GEN_PARAM
PICO_SHOTS_SWEEPS_WARNING
PICO_NOT_RESPONDING
PICO_WARNING_EXT_THRESHOLD_CONFLICT
PICO_NO_SIGNAL_GENERATOR
PICO_SIGGEN_OFFSET_VOLTAGE
PICO_SIGGEN_PK_TO_PK
PICO_SIGGEN_OUTPUT_OVER_VOLTAGE
PICO_DRIVER_FUNCTION
PICO_SIGGEN_WAVEFORM_SETUP_FAILED
It is also possible to sweep the frequency by continually modifying the deltaPhase. This is done by setting up a
deltaPhaseIncrement that the oscilloscope adds to the deltaPhase at intervals specified by dwellCount.
This function sets up the signal generator to produce a signal from a list of built-in waveforms. If different start
and stop frequencies are specified, the device will sweep either up, down, or up and down.
Set up the signal generator before starting data acquisition, particularly if you require it to be triggered during data
acquisition.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Note: if the signal voltages described by the combination of offsetVoltage and pkToPk extend outside the
voltage range of the signal generator, the output waveform will be clipped.
startFrequency, the frequency that the signal generator will initially produce. Allowable values are between
one of these constants:
PS2000A_MIN_FREQUENCY
PS2000A_PRBS_MIN_FREQUENCY
stopFrequency, the frequency at which the sweep reverses direction or returns to the initial frequency
dwellTime, the time for which the sweep stays at each frequency, in seconds
sweepType, whether the frequency will sweep from startFrequency to stopFrequency, or in the
opposite direction, or repeatedly reverse direction. Use one of these constants:
PS2000A_UP
PS2000A_DOWN
PS2000A_UPDOWN
PS2000A_DOWNUP
operation, the type of waveform to be produced, specified by one of the following enumerated types:
PS2000A_ES_OFF, normal signal generator operation specified by waveType.
PS2000A_WHITENOISE, the signal generator produces white noise and ignores all settings except pkToPk
and offsetVoltage.
PS2000A_PRBS, produces a pseudorandom binary sequence at the specified frequency or frequency range
(not available on PicoScope 2205 MSO).
Returns PICO_OK
PICO_BUSY
PICO_INVALID_HANDLE
PICO_SIG_GEN_PARAM
PICO_SHOTS_SWEEPS_WARNING
PICO_NOT_RESPONDING
PICO_WARNING_AUX_OUTPUT_CONFLICT
PICO_WARNING_EXT_THRESHOLD_CONFLICT
PICO_NO_SIGNAL_GENERATOR
PICO_SIGGEN_OFFSET_VOLTAGE
PICO_SIGGEN_PK_TO_PK
PICO_SIGGEN_OUTPUT_OVER_VOLTAGE
PICO_DRIVER_FUNCTION
PICO_SIGGEN_WAVEFORM_SETUP_FAILED
PICO_NOT_RESPONDING
This function sets up the signal generator. It differs from ps2000aSetSigGenBuiltIn() in having double-
precision arguments instead of floats, giving greater resolution when setting the output frequency.
This document provides some useful guidance on how to call the API functions in order to trigger the signal
generator output.
Arguments
See ps2000aSetSigGenBuiltIn()
This function reprograms the arbitrary waveform generator. All values can be reprogrammed while the signal
generator is waiting for a trigger.
Arguments
See ps2000aSetSigGenArbitrary().
This function reprograms the signal generator. Values can be changed while the signal generator is waiting for a
trigger.
Arguments
See ps2000aSetSigGenBuiltIn().
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 100
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function simplifies arming the trigger. It supports only the LEVEL trigger types on analog channels, and does
not allow more than one channel to have a trigger applied to it. Any previous pulse width qualifier is canceled. The
trigger threshold includes a small, fixed amount of hysteresis.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
enable, zero to disable the trigger; any non-zero value to set the trigger.
direction, the direction in which the signal must move to cause a trigger. The following directions are
supported: ABOVE, BELOW, RISING, FALLING and RISING_OR_FALLING.
delay, the time between the trigger occurring and the first sample being taken. For example, if delay=100,
the scope would wait 100 sample periods before sampling.
autoTrigger_ms, the number of milliseconds the device will wait if no trigger occurs. If this is set to zero, the
scope device will wait indefinitely for a trigger.
Returns PICO_OK
PICO_INVALID_CHANNEL
PICO_INVALID_PARAMETER
PICO_MEMORY
PICO_CONDITIONS
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_DRIVER_FUNCTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 101
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function sets up trigger conditions on the scope's analog and digital inputs. The trigger is defined by one or
more PS2000A_TRIGGER_CONDITIONS structures that are then ORed together. Each structure is itself the
AND of the states of one or more of the inputs. This AND–OR logic allows you to create any possible Boolean
function of the scope's inputs. (The 16 digital inputs of an MSO count as a unit for the purposes of this function.)
Arguments
handle, device identifier returned by ps2000aOpenUnit().
nConditions, the number of elements in the conditions array. If nConditions is zero, triggering is
switched off.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_CONDITIONS
PICO_MEMORY
PICO_DRIVER_FUNCTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 102
PicoScope 2000 Series (A API) Programmer's Guide API functions
Each structure is the logical AND of the states of the scope's inputs. The
ps2000aSetTriggerChannelConditions() function can OR together a number of these structures to
produce the final trigger condition, which can be any possible Boolean function of the scope's inputs. (The 16
digital inputs of an MSO count as a unit for the purposes of this function.)
The structure is byte-aligned. In C++, for example, you should specify this using the #pragma pack()
instruction.
Elements
channelA, channelB, channelC, channelD, external, pulseWidthQualifier, digital:
the type of condition that should be applied to each channel. Use these constants:
PS2000A_CONDITION_DONT_CARE
PS2000A_CONDITION_TRUE
PS2000A_CONDITION_FALSE
The channels that are set to PS2000A_CONDITION_TRUE or PS2000A_CONDITION_FALSE must all meet
their conditions simultaneously to produce a trigger. Channels set to PS2000A_CONDITION_DONT_CARE are
ignored.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 103
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function sets the direction of the trigger for each channel.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
channelA, channelB, channelC, channelD, ext, the direction in which the signal must pass
through the threshold to activate the trigger. See the table below for allowable values. If using a level trigger in
conjunction with a pulse-width trigger, see the description of the direction argument to
ps2000aSetPulseWidthQualifier() for more information.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_INVALID_PARAMETER
PS2000A_THRESHOLD_DIRECTION constants
Constant Trigger type Direction
PS2000A_ABOVE gated above the upper threshold
PS2000A_ABOVE_LOWER gated above the lower threshold
PS2000A_BELOW gated below the upper threshold
PS2000A_BELOW_LOWER gated below the lower threshold
PS2000A_RISING threshold rising edge, using upper threshold
PS2000A_RISING_LOWER threshold rising edge, using lower threshold
PS2000A_FALLING threshold falling edge, using upper threshold
PS2000A_FALLING_LOWER threshold falling edge, using lower threshold
PS2000A_RISING_OR_FALLING threshold either edge
PS2000A_INSIDE window-qualified inside window
PS2000A_OUTSIDE window-qualified outside window
PS2000A_ENTER window entering the window
PS2000A_EXIT window leaving the window
PS2000A_ENTER_OR_EXIT window entering or leaving the window
PS2000A_NONE none none
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 104
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function is used to enable or disable triggering on the analog channels and set its parameters.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
nChannelProperties, the length of the channelProperties array. If zero, triggering on analog channels
is switched off.
autoTriggerMilliseconds, the number of milliseconds for which the scope device will wait for a trigger
before timing out. If this argument is set to zero, the scope device will wait indefinitely for a trigger. In block
mode, the capture cannot finish until a trigger event or auto-trigger timeout has occurred. In streaming mode the
device always starts collecting data as soon as ps2000aRunStreaming() is called but does not start
counting post-trigger samples until it detects a trigger event or auto-trigger timeout.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_TRIGGER_ERROR
PICO_MEMORY
PICO_INVALID_TRIGGER_PROPERTY
PICO_DRIVER_FUNCTION
PICO_INVALID_PARAMETER
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 105
PicoScope 2000 Series (A API) Programmer's Guide API functions
The structure is byte-aligned. In C++, for example, you should specify this using the #pragma pack()
instruction.
Hysteresis
Each trigger threshold (upper and lower) has an accompanying parameter called hysteresis. This defines a
second threshold at a small offset from the main threshold. The trigger fires when the signal crosses the trigger
threshold, but will not fire again until the signal has crossed the hysteresis threshold and then returned to cross
the trigger threshold. The double-threshold mechanism prevents noise on the signal from causing unwanted
trigger events.
For a rising-edge trigger the hysteresis threshold is below the trigger threshold. After one trigger event, the signal
must fall below the hysteresis threshold before the trigger is enabled for the next event. Conversely, for a falling-
edge trigger, the hysteresis threshold is always above the trigger threshold. After a trigger event, the signal must
rise above the hysteresis threshold before the trigger is enabled for the next event.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 106
PicoScope 2000 Series (A API) Programmer's Guide API functions
Elements
thresholdUpper, the upper threshold at which the trigger fires. This is scaled in 16-bit ADC counts at the
currently selected range for that channel.
thresholdUpperHysteresis, the distance between the upper trigger threshold and the upper hysteresis
threshold, scaled in 16-bit counts.
channel, the channel to which the properties apply. This can be one of the four input channels listed under
ps2000aSetChannel(), or PS2000A_TRIGGER_EXT for the EXT input fitted to some models.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 107
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function sets the post-trigger delay, which causes capture to start a defined time after the trigger event.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
delay, the time between the trigger occurring and the first sample. For example, if delay=100 then the scope
would wait 100 sample periods before sampling. At a timebase of 1 GS/s, or 1 ns per sample, the total delay
would then be 100 x 1 ns = 100 ns.
Range: 0 to MAX_DELAY_COUNT.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_DRIVER_FUNCTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 108
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function sets trigger directions for one or more digital channels.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
nDirections, the number of digital channel directions being passed to the driver.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
PICO_INVALID_DIGITAL_CHANNEL
PICO_INVALID_DIGITAL_TRIGGER_DIRECTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 109
PicoScope 2000 Series (A API) Programmer's Guide API functions
pragma pack(1)
typedef struct tPS2000ADigitalChannelDirections
{
PS2000A_DIGITAL_CHANNEL channel;
PS2000A_DIGITAL_DIRECTION direction;
} PS2000A_DIGITAL_CHANNEL_DIRECTIONS;
#pragma pack()
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 110
PicoScope 2000 Series (A API) Programmer's Guide API functions
The structure is byte-aligned. In C++, for example, you should specify this using the #pragma pack()
instruction.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 111
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function returns the range of possible sample values and waveform buffer sizes that can be supplied to
ps2000aSetSigGenArbitrary() for setting up the arbitrary waveform generator (AWG). These values may
vary between models.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_NOT_SUPPORTED_BY_THIS_DEVICE, if the device does not have an arbitrary
waveform generator
PICO_NULL_PARAMETER, if all the parameter pointers are NULL
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 112
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function converts a frequency to a phase count for use with the arbitrary waveform generator setup
functions ps2000aSetSigGenArbitrary() and ps2000aSetSigGenPropertiesArbitrary(). The
value returned depends on the length of the buffer, the index mode passed and the device model.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
phase, on exit, the deltaPhase argument to be sent to the AWG setup function.
Returns PICO_OK
PICO_NOT_SUPPORTED_BY_THIS_DEVICE, if the device does not have an AWG
PICO_SIGGEN_FREQUENCY_OUT_OF_RANGE, if the frequency is out of range
PICO_NULL_PARAMETER, if phase is a NULL pointer
PICO_SIG_GEN_PARAM, if indexMode or bufferLength is out of range
PICO_INVALID_HANDLE
PICO_DRIVER_FUNCTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 113
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function causes a trigger event, or starts and stops gating, for the signal generator. Use it as follows:
2. (a) If you set the signal generator triggerType to edge triggering (PS2000A_SIGGEN_RISING or
PS2000A_SIGGEN_FALLING), call ps2000aSigGenSoftwareControl() once to trigger the signal
generator.
(b) If you set the signal generator triggerType to gated-low triggering (PS2000A_SIGGEN_GATE_LOW),
call ps2000aSigGenSoftwareControl() with state=0 to start the sweep and then again with
state=1 to stop it.
(c) If you set the signal generator triggerType to gated-high triggering
(PS2000A_SIGGEN_GATE_HIGH), call ps2000aSigGenSoftwareControl() with state=1 to start
the sweep and then again with state=0 to stop it.
· Trying to set a specific number of shots and then attempting to use a gate will cause the call to
ps2000aSetSigGenBuiltIn() or ps2000aSetSigGenArbitrary() to return an error.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
state, specifies whether to start or stop the sweep (see note 2 above). Effective only when the signal
generator triggerType is set to PS2000A_SIGGEN_GATE_HIGH or PS2000A_SIGGEN_GATE_LOW.
Ignored for other trigger types.
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_NO_SIGNAL_GENERATOR
PICO_SIGGEN_TRIGGER_SOURCE
PICO_DRIVER_FUNCTION
PICO_NOT_RESPONDING
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 114
PicoScope 2000 Series (A API) Programmer's Guide API functions
This function stops the scope device while it is waiting for a trigger or capturing data.
· In block mode, you can optionally call ps2000aStop() to terminate the current capture. Any data in the
buffer will be invalid.
· In rapid block mode, you can optionally call ps2000aStop() to terminate the sequence of captures. Any
completed captures will contain valid data but no further captures will be made.
· In streaming mode, calling ps2000aStop() is the usual way to terminate data capture. If this function is
called before a trigger event occurs, the oscilloscope may not contain valid data. If capture has already
started, the buffer will contain valid data.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
Returns PICO_OK
PICO_INVALID_HANDLE
PICO_USER_CALLBACK
PICO_DRIVER_FUNCTION
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 115
PicoScope 2000 Series (A API) Programmer's Guide API functions
This callback function is part of your application. You register it with the driver using
ps2000aGetStreamingLatestValues(), and the driver calls it back when streaming-mode data is ready.
You can then download the data using the ps2000aGetValuesAsync() function.
The function should do nothing more than copy the data to another buffer within your application. To maintain the
best application performance, the function should return as quickly as possible without attempting to process or
display the data.
Arguments
handle, device identifier returned by ps2000aOpenUnit().
startIndex, an index to the first valid sample in the buffer. This is the buffer that was previously passed to
ps2000aSetDataBuffer().
overflow, returns a set of flags that indicate whether an overvoltage has occurred on any of the channels. It
is a bit pattern with bit 0 corresponding to Channel A.
triggerAt, an index to the buffer indicating the location of the trigger point relative to startIndex. The
trigger point is therefore at StartIndex + triggerAt. This parameter is valid only when triggered is
non-zero.
triggered, a flag indicating whether a trigger occurred. If non-zero, a trigger occurred at the location indicated
by triggerAt.
Returns nothing
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 116
PicoScope 2000 Series (A API) Programmer's Guide API functions
The source code contained in the Wrapper projects contains a description of the functions and the input and
output parameters.
Below we explain the sequence of calls required to capture data in streaming mode using the wrapper API
functions.
The ps2000aWrap.dll wrapper DLL has a callback function for streaming data collection that copies data
from the driver buffer specified to a temporary application buffer of the same size. To do this it must be
registered with the wrapper and the channel must be specified as being enabled. You should process the data in
the temporary application buffer accordingly, for example by copying the data into a large array.
Procedure:
1. Open the oscilloscope using ps2000aOpenUnit().
1a. Inform the wrapper of the number of channels on the device by calling setChannelCount.
2a. Inform the wrapper which channels have been enabled by calling setEnabledChannels.
3a. [MSOs only] Inform the wrapper which digital ports have been enabled by calling
setEnabledDigitalPorts.
4. Use the appropriate trigger setup functions. For programming languages that do not support structures, use
the wrapper's advanced trigger setup functions.
6a. Register the data buffer(s) with the wrapper and set the application buffer(s) into which the data will be
copied.
8. Loop and call GetStreamingLatestValues and IsReady to get data and flag when the wrapper is
ready for data to be retrieved.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 117
PicoScope 2000 Series (A API) Programmer's Guide API functions
8a. Call the wrapper’s AvailableData function to obtain information on the number of samples collected and
the start index in the buffer.
8b. Call the wrapper’s IsTriggerReady function for information on whether a trigger has occurred and the
trigger index relative to the start index in the buffer.
10. Call AutoStopped if the autoStop parameter has been set to TRUE in the call to
ps2000aRunStreaming().
11. Repeat steps 8 to 10 until AutoStopped returns true or you wish to stop data collection.
12. Call ps2000aStop, even if the autoStop parameter was set to TRUE.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 118
PicoScope 2000 Series (A API) Programmer's Guide Further information
4 Further information
4.1 Driver status codes
Every function in the ps2000a driver returns a driver status code from the list of PICO_STATUS values in
PicoStatus.h, which is included in the inc folder of the PicoSDK installation.
int16_t 16 signed
uint16_t 16 unsigned
enum 32 enumerated
int32_t 32 signed
uint32_t 32 unsigned
int64_t 64 signed
uint64_t 64 unsigned
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 119
PicoScope 2000 Series (A API) Programmer's Guide Glossary
5 Glossary
AC/DC control. Each channel can be set to either AC coupling or DC coupling. With DC coupling, the voltage
displayed on the screen is equal to the true voltage of the signal. With AC coupling, any DC component of the
signal is filtered out, leaving only the variations in the signal (the AC component).
Aggregation. This is the data-reduction method used by the PicoScope 2000 Series (A API) scopes. For each
block of consecutive samples, the scope transmits only the minimum and maximum samples over the USB port
to the PC. In streaming mode you can set the number of samples in each block, called the downsampling ratio,
when you call ps2000aRunStreaming() for real-time capture, and when you call
ps2000aGetStreamingLatestValues() to obtain post-processed data. In block mode you can specify the
downsampling ratio when calling ps2000aGetValues(). In rapid block mode you can specify the ratio when
calling ps2000aGetValuesBulk().
Block mode. A sampling mode in which the computer prompts the oscilloscope to collect a block of data into its
internal memory before stopping the oscilloscope and transferring the whole block into computer memory. This
mode of operation is effective when the input signal being sampled contains high frequencies. Note: To avoid
aliasing effects, the maximum input frequency must be less than half the sampling rate.
Buffer size. The size, in samples, of the oscilloscope buffer memory. The buffer memory is used by the
oscilloscope to temporarily store data before transferring it to the PC.
Callback. A call made by the ps2000a driver to a function in your application. It indicates that data is ready for
collection.
ETS. Equivalent Time Sampling. ETS constructs a picture of a repetitive signal by accumulating information over
many similar wave cycles. This means the oscilloscope can capture fast-repeating signals that have a higher
frequency than the maximum sampling rate. Note: ETS cannot be used for one-shot or non-repetitive signals.
External trigger. This is the BNC socket marked EXT on some PicoScope oscilloscopes. A pulse fed into this
input can be used to start data capture.
Maximum sampling rate. A figure indicating the maximum number of samples the oscilloscope is capable of
acquiring per second. Maximum sample rates are given in MS/s (megasamples per second) or GS/s
(gigasamples per second). The higher the sampling capability of the oscilloscope, the more accurate the
representation of the high frequencies in a fast signal.
MSO (mixed-signal oscilloscope). An oscilloscope that has both analog and digital inputs.
Signal generator. This is a feature of some oscilloscopes that can generate a signal for test purposes. The signal
generator output is the BNC socket marked AWG or GEN on the oscilloscope. If you connect a BNC cable
between this and one of the channel inputs, you can send a signal into one of the channels. It can generate a
sine, square, triangle or arbitrary wave of fixed or swept frequency.
Streaming mode. A sampling mode in which the oscilloscope samples data and returns it to the computer in an
unbroken stream. This mode of operation is effective when the input signal being sampled contains only low
frequencies.
Timebase. A function within the PicoScope device that controls the time between samples. This time is
programmable.
USB 1.1. An early version of the Universal Serial Bus standard found on older PCs. Although your PicoScope will
work with a USB 1.1 port, it will operate much more slowly than with a USB 2.0 or 3.0 port.
USB 2.0. Universal Serial Bus (High Speed). A standard port used to connect external devices to PCs. The high-
speed data connection provided by a USB 2.0 port enables your PicoScope to achieve its maximum performance.
USB 3.0. A faster version of the Universal Serial Bus standard. Your PicoScope is fully compatible with USB 3.0
ports and will operate with the same performance as on a USB 2.0 port.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 120
PicoScope 2000 Series (A API) Programmer's Guide Glossary
Vertical resolution. A value, in bits, indicating the degree of precision with which the oscilloscope can turn input
voltages into digital values.
Voltage range. The voltage range is the difference between the maximum and minimum voltages that can be
accurately captured by the oscilloscope.
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 121
PicoScope 2000 Series (A API) Programmer's Guide Index
modes 50
Index Driver 10
status codes 119
A E
Access 9
Enabling channels 76
ADC count 63, 65 Enumerated types 119
Aggregation 25 Enumerating oscilloscopes 33
Analog offset 35, 76 ETS
Arbitrary waveform generator 90, 93 mode 14
overview 23
B setting time buffers 82, 83
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 123
PicoScope 2000 Series (A API) Programmer's Guide Index
Functions
ps2000aOpenUnitProgress 69
ps2000aPingUnit 70
M
Memory buffer 15
ps2000aQueryOutputEdgeDetect 71
ps2000aRunBlock 72 Memory segmentation 15, 16, 25, 64
ps2000aRunStreaming 74 Mission-critical applications 9
ps2000aSetChannel 11, 76 MSO digital connector 29
ps2000aSetDataBuffer 77 Multi-unit operation 29
ps2000aSetDataBuffers 78
ps2000aSetDigitalAnalogTriggerOperand 79 N
ps2000aSetEts 23, 81 Numeric data types 119
ps2000aSetEtsTimeBuffer 82
ps2000aSetEtsTimeBuffers 83
ps2000aSetNoOfCaptures 84 O
ps2000aSetOutputEdgeDetect 85 One-shot signals 23
ps2000aSetPulseWidthDigitalPortProperties 86 Opening a unit 67
ps2000aSetPulseWidthQualifier 87 checking progress 69
ps2000aSetSigGenArbitrary 90 without blocking 68
ps2000aSetSigGenBuiltIn 95 Oversampling 50
ps2000aSetSigGenBuiltInV2 98
ps2000aSetSigGenPropertiesArbitrary 99
ps2000aSetSigGenPropertiesBuiltIn 100
P
ps2000aSetSimpleTrigger 13, 101 PC Oscilloscope 7, 120
PC requirements 8
ps2000aSetTriggerChannelConditions 13, 102
PICO_STATUS enum type 119
ps2000aSetTriggerChannelDirections 13, 104
PicoScope 2000 Series 7
ps2000aSetTriggerChannelProperties 13, 105
PicoScope software 7, 10, 119
ps2000aSetTriggerDelay 108
ps2000aSetTriggerDigitalPortProperties 109 Programming
general procedure 10
ps2000aSigGenSoftwareControl 114
ps2000aStop 17, 115 ps2000a.dll 10
PS2000A_CONDITION_ constants 89, 103
ps2000aStreamingReady 116
PS2000A_LEVEL constant 106, 110
PS2000A_PWQ_CONDITIONS structure 89
H PS2000A_RATIO_MODE_AGGREGATE 50
Hysteresis 106, 110 PS2000A_RATIO_MODE_AVERAGE 50
PS2000A_RATIO_MODE_DECIMATE 50
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 124
PicoScope 2000 Series (A API) Programmer's Guide Index
T
Time buffers
setting for ETS 82, 83
Timebase 28, 120
calculating 42, 44
Trademarks 9
Trigger
channel properties 86, 105, 109
combining analog and digital 79
conditions 102, 103
delay 108
digital port pulse width 86
digital ports 109
directions 104
edge detection, querying 71
edge detection, setting 85
external 11
ps2000apg.en-12 Copyright © 2011–2022 Pico Technology Ltd. All rights reserved. 125
United Kingdom global United States r egional A s ia-Pac if ic r egional
headquar ter s : of f ic e: of f ic e:
Pico Technology Pico Technology Pico Technology
James House 320 N Glenwood Blvd Room 2252, 22/F, Centro
Colmworth Business Park Tyler 568 Hengfeng Road
St. Neots TX 75702 Zhabei District
Cambridgeshire United States Shanghai 200070
PE19 8YP PR China
United Kingdom
Tel: +44 (0) 1480 396 395 Tel: +1 800 591 2796 Tel: +86 21 2226-5152
www.picotech.com
ps2000apg.en-12
Copyright © 2011–2022 Pico Technology Ltd. All rights reserved.