ps2000pg En-10
ps2000pg En-10
PC Oscilloscopes
Programmer's Guide
ps2000pg.en r10
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide I
Contents
1 Introduction....................................................................................................................................1
1 Overview ........................................................................................................................................1
........................................................................................................................................1
2 Minimum system requirements
3 Legal information ........................................................................................................................................2
4 Trademarks ........................................................................................................................................3
5 Warranty ........................................................................................................................................3
6 Company details ........................................................................................................................................3
2 Product information
....................................................................................................................................4
1 System requirements........................................................................................................................................4
........................................................................................................................................4
2 Installation instructions
3 Programming
....................................................................................................................................5
the 2000 Series Oscilloscopes
1 General procedure ........................................................................................................................................5
2 Driver ........................................................................................................................................5
3 Voltage ranges ........................................................................................................................................5
4 Triggering ........................................................................................................................................6
5 Signal generator ........................................................................................................................................6
6 AC/DC coupling ........................................................................................................................................6
7 Oversampling ........................................................................................................................................6
8 Scaling ........................................................................................................................................6
4 Sampling modes
....................................................................................................................................7
1 Block mode ........................................................................................................................................7
......................................................................................................................................................................7
1 Using block mode
2 Streaming mode ........................................................................................................................................8
......................................................................................................................................................................8
1 Compatible streaming mode
2 Fast streaming......................................................................................................................................................................9
mode
........................................................................................................................................10
3 ETS (Equivalent Time Sampling)
......................................................................................................................................................................10
1 Using ETS mode
5 Combining....................................................................................................................................11
several oscilloscopes
6 API Functions
....................................................................................................................................12
1 ps2000_close_unit ........................................................................................................................................13
2 ps2000_flash_led ........................................................................................................................................14
........................................................................................................................................15
3 ps2000_get_streaming_last_values
........................................................................................................................................16
4 ps2000_get_streaming_values
........................................................................................................................................18
5 ps2000_get_streaming_values_no_aggregation
........................................................................................................................................20
6 ps2000_get_timebase
........................................................................................................................................21
7 ps2000_get_times_and_values
........................................................................................................................................23
8 ps2000_get_unit_info
9 ps2000_get_values ........................................................................................................................................24
........................................................................................................................................25
10 ps2000_last_button_press
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
II Contents
11 ps2000_open_unit........................................................................................................................................26
........................................................................................................................................27
12 ps2000_open_unit_async
........................................................................................................................................28
13 ps2000_open_unit_progress
........................................................................................................................................29
14 ps2000_overview_buffer_status
15 ps2000_ready ........................................................................................................................................30
16 ps2000_run_block........................................................................................................................................31
........................................................................................................................................32
17 ps2000_run_streaming
........................................................................................................................................33
18 ps2000_run_streaming_ns
........................................................................................................................................34
19 ps2000SetAdvTriggerChannelConditions
......................................................................................................................................................................35
1 PS2000_TRIGGER_CONDITIONS structure
........................................................................................................................................36
20 ps2000SetAdvTriggerChannelDirections
........................................................................................................................................37
21 ps2000SetAdvTriggerChannelProperties
......................................................................................................................................................................38
1 PS2000_TRIGGER_CHANNEL_PROPERTIES structure
........................................................................................................................................39
22 ps2000SetAdvTriggerDelay
........................................................................................................................................40
23 ps2000_set_channel
24 ps2000_set_ets ........................................................................................................................................41
25 ps2000_set_light ........................................................................................................................................42
26 ps2000_set_led ........................................................................................................................................43
........................................................................................................................................44
27 ps2000SetPulseWidthQualifier
......................................................................................................................................................................45
1 PS2000_PWQ_CONDITIONS structure
........................................................................................................................................46
28 ps2000_set_sig_gen_arbitrary
........................................................................................................................................48
29 ps2000_set_sig_gen_built_in
30 ps2000_set_trigger........................................................................................................................................50
........................................................................................................................................51
31 ps2000_set_trigger2
32 ps2000_stop ........................................................................................................................................52
........................................................................................................................................53
33 my_get_overview_buffers
7 Programming
....................................................................................................................................55
examples
1C ........................................................................................................................................55
2 Visual Basic ........................................................................................................................................56
3 Delphi ........................................................................................................................................56
4 Excel ........................................................................................................................................56
5 LabVIEW ........................................................................................................................................56
8 Driver error
....................................................................................................................................57
codes
9 Glossary ....................................................................................................................................58
Index ....................................................................................................................................61
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 1
1 Introduction
1.1 Overview
The PicoScope 2000 Series PC Oscilloscopes are low-cost , high-performance
instruments that are fully USB 2.0-capable and also backwards-compatible with
USB 1.1. There is no need for an additional power supply, as power is taken from the
USB port.
This manual explains how to develop your own programs for collecting and analyzing
data from the PicoScope 2000 Series oscilloscopes. This manual describes the
application programming interface (API) for the devices shown below.
Drivers and example code are available on the Pico Technology Software and
Reference CD-ROM and on our website at www.picotech.com.
The oscilloscopes are also supplied with the ready-to-use PicoScope oscilloscope
software and PicoLog data logging software, which include their own on-line User's
Guides.
Please read the important information in this introductory section and then proceed to
the Installation instructions.
Please note the PicoScope software is not installed as part of the SDK.
Item Specification
Operating Windows XP (SP3), Windows Vista, Windows 7, Windows 8
system (Not Windows RT)
32 bit and 64 bit versions supported
Processor
Memory As required by Windows
* The oscilloscope will run slowly on a USB 1.1 port. This configuration is not
recommended.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
2 Introduction
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 (software, documents, etc.) contained in this SDK except the example
programs. You may copy and distribute the SDK without restriction, as long as you do
not remove any Pico Technology copyright statements. The example programs in the
SDK may be modified, copied and distributed for the purpose of developing programs
to collect data using Pico products.
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.
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 28 days of purchase for a full refund.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 3
1.4 Trademarks
Pico Technology Limited and PicoScope are internationally registered trademarks.
1.5 Warranty
Pico Technology warrants upon delivery, and for a period of 5 years unless otherwise
stated from the date of delivery, that the Goods will be free from defects in material
and workmanship.
Pico Technology shall not be liable for a breach of the warranty if the defect has been
caused by fair wear and tear, wilful damage, negligence, abnormal working conditions
or failure to follow Pico Technology's spoken or written advice on the storage,
installation, commissioning, use or maintenance of the Goods or (if no advice has
been given) good trade practice; or if the Customer alters or repairs such Goods
without the written consent of Pico Technology.
Email:
Technical Support: [email protected]
Sales: [email protected]
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
4 Product information
2 Product information
2.1 System requirements
General requirements
See Minimum PC requirements.
USB
The ps2000 driver offers several methods of recording data, all of which support both
USB 1.1 and USB 2.0, although the fastest transfer rates are achieved using USB 2.0.
The driver is also compatible with USB 3.0, with which it will run at the same speed as
USB 2.0.
Install the software by following the steps in the printed Installation Guide supplied
with your oscilloscope. You must install the PicoScope 6 PC Oscilloscope software
even if you do not intend to use it, as it includes the driver and API DLL that you
will need to write your own software.
Connect the oscilloscope's USB port to the PC using the USB cable supplied. There
is no need for an additional power supply, as the oscilloscope obtains its power
from the PC.
Once you have installed the software, ensure that the oscilloscope is connected to the
PC and then start the PicoScope software. PicoScope should show a small 50 Hz or
60 Hz mains signal in the oscilloscope window when you touch the probe tip with your
finger.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 5
Numerous sample programs are included in the SDK. These show how to use the
functions of the driver software in each of the modes available.
3.2 Driver
Important
Ensure the PicoScope driver is installed by one of the following methods.
Before plugging the oscilloscope into your computer for the first time, either:
1) Install (or already have installed) the PicoScope software, which includes the driver
for the PicoScope PC Oscilloscope.
Note: Once you have installed the PicoScope software, Windows will automatically
install the driver when you plug in the oscilloscope for the first time.
Or
2) If you do not want or need an installation of PicoScope, manually run the required
dpinst.exe which can be found in the system\amd64 or system\x86 folder of the
SDK.
Note: For an x86 operating system you will also need to copy picopp.inf to
SYSTEMROOT\inf and picopp.sys to SYSTEMROOT\system32\drivers.
The Windows XP, Windows Vista, Windows 7 and Windows 8 32-bit driver,
picopp.sys, is installed under the control of an information file, picopp.inf.
If you do plug in an oscilloscope before installing the driver, Windows will designate
the device as Unknown. You will then need to manually delete the device using the
Device Manager before you can install the correct driver.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
6 Programming the 2000 Series Oscilloscopes
3.4 Triggering
PicoScope 2000 Series PC Oscilloscopes can either start collecting data immediately,
or be programmed to wait for a trigger event to occur. In both cases you need to use
the ps2000_set_trigger() function or, for scopes that support advanced triggering,
the ps2000SetAdvTriggerChannelConditions() function. A trigger event can occur on
any of the conditions available in the simple and advanced triggering modes.
Applicability Available in block mode and fast streaming mode only. Calls to the
ps2000_set_trigger() and
ps2000SetAdvTriggerChannelConditions() functions have no effect
in compatible streaming mode.
3.7 Oversampling
When the oscilloscope is operating at sampling rates less than the maximum, it is
possible to oversample. Oversampling is taking more than one measurement during
a time interval and returning an average. If the signal contains a small amount of
noise, this technique can increase the effective vertical resolution of the oscilloscope
by the amount given by the equation below:
3.8 Scaling
The driver normalises all readings to 16 bits, regardless of the vertical resolution of
the oscilloscope. The following table shows the relationship between the reading from
the driver and the signal level.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 7
4 Sampling modes
PicoScope 2000 Series PC Oscilloscopes can run in various sampling modes.
Block mode. At the highest sampling rates, the oscilloscope collects data much
faster than a PC can read it. In this case, the oscilloscope stores a block of data in
an internal memory buffer, delaying transfer to the PC until the required number of
data points have been sampled.
Streaming modes. At all but the highest sampling rates, these modes allow
accurately timed data to be transferred back to the PC without gaps. The computer
instructs the oscilloscope to start collecting data. The oscilloscope then transfers
data back to the PC without storing it in its own memory, so the size of the data
set is limited only by the size of the PC's memory. Sampling intervals from less
than one microsecond (depending on model) to 60 seconds are possible. There are
two streaming modes:
Compatible streaming mode
Fast streaming mode
The maximum number of values depends upon the size of the oscilloscope's memory.
A PicoScope 2000 Series oscilloscope can sample at a number of different rates that
correspond to the maximum sampling rate divided by 1, 2, 4, 8 and so on.
There is a separate memory buffer for each channel. When a channel is unused, its
memory can be borrowed by the enabled channels. This feature is handled
transparently by the driver.
The driver normally performs a number of setup operations before collecting each
block of data. This can take up to 50 milliseconds. If it is necessary to collect data with
the minimum time interval between blocks, avoid calling setup functions between calls
to ps2000_run_block(), ps2000_ready(), ps2000_stop() and ps2000_get_values().
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
8 Sampling modes
In streaming mode, the computer prompts the oscilloscope to start collecting data.
The data is then transferred back to the PC without being stored in the oscilloscope's
memory. Data can be sampled with a period between 1 µs or less and 60 s, and the
maximum number of samples is limited only by the amount of free space on the PC's
hard disk.
The oscilloscope's driver transfers data to a computer program using either normal or
windowed mode. In normal mode, any data collected since the last data transfer
operation is returned in its entirety. Normal mode is useful if the computer program
requires fresh data on every transfer. In windowed mode, a fixed number of samples
is returned, where the oldest samples may have already been returned before.
Windowed mode is useful when the program requires a constant time period of data.
Once the oscilloscope is collecting data in streaming mode, any setup changes (for
example, changing a channel range or AC/DC setting) will cause a restart of the data
stream. The driver can buffer up to 32 K samples of data per channel, but the user
must ensure that the ps2000_get_values() function is called frequently enough to
avoid buffer overrun.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 9
Fast streaming mode also provides data aggregation, which allows your application to
zoom in and out of the data with the minimum of effort.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
10 Sampling modes
Because of the high sensitivity of ETS mode to small time differences, you must set up
the trigger to provide a stable waveform that varies as little as possible from one
capture to the next.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 11
To begin, call ps2000_open_unit() to obtain a handle for each oscilloscope. All the
other functions require this handle for oscilloscope identification. For example, to
collect data from two oscilloscopes at the same time:
handle1 = ps2000_open_unit()
handle2 = ps2000_open_unit()
ps2000_set_channel(handle1)
... set up unit 1
ps2000_run_block(handle1)
ps2000_set_channel(handle2)
... set up unit 2
ps2000_run_block(handle2)
ready = FALSE
while not ready
ready = ps2000_ready(handle1)
ready &= ps2000_ready(handle2)
ps2000_get_values(handle1)
ps2000_get_values(handle2)
It is not possible to synchronise the collection of data between multiple 2000 Series
oscilloscopes.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
12 API Functions
6 API Functions
The PicoScope 2000 Series API exports the following functions for you to use in your
own applications:
ps2000_close_unit
ps2000_flash_led
ps2000_get_streaming_last_values
ps2000_get_streaming_values
ps2000_get_streaming_values_no_aggregation
ps2000_get_timebase
ps2000_get_times_and_values
ps2000_get_unit_info
ps2000_get_values
ps2000_last_button_press
ps2000_open_unit
ps2000_open_unit_async
ps2000_open_unit_progress
ps2000_overview_buffer_status
ps2000_ready
ps2000_run_block
ps2000_run_streaming
ps2000_run_streaming_ns
ps2000SetAdvTriggerChannelConditions
ps2000SetAdvTriggerChannelDirections
ps2000SetAdvTriggerChannelProperties
ps2000SetAdvTriggerDelay
ps2000_set_channel
ps2000_set_ets
ps2000_set_led
ps2000_set_light
ps2000SetPulseWidthQualifier
ps2000_set_sig_gen_arbitrary
ps2000_set_sig_gen_built_in
ps2000_set_trigger
ps2000_set_trigger2
ps2000_stop
my_get_overview_buffers
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 13
6.1 ps2000_close_unit
short ps2000_close_unit (
short handle
)
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
14 API Functions
6.2 ps2000_flash_led
short ps2000_flash_led (
short handle
)
Flashes the LED on the front of the oscilloscope (or in the pushbutton, for the
PicoScope 2104 and 2105 oscilloscopes) three times and returns within one second.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 15
6.3 ps2000_get_streaming_last_values
short ps2000_get_streaming_last_values (
short handle
GetOverviewBuffersMaxMin lpGetOverviewBuffersMaxMin
)
This function is used to collect the next block of values while fast streaming is
running. You must call ps2000_run_streaming_ns beforehand to set up fast
streaming.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
16 API Functions
6.4 ps2000_get_streaming_values
unsigned long ps2000_get_streaming_values (
short handle,
double *start_time,
short *pbuffer_a_max,
short *pbuffer_a_min,
short *pbuffer_b_max,
short *pbuffer_b_min,
short *pbuffer_c_max,
short *pbuffer_c_min,
short *pbuffer_d_max,
short *pbuffer_d_min,
short *overflow,
unsigned long *triggerAt,
short *triggered,
unsigned long no_of_values,
unsigned long noOfSamplesPerAggregate
)
This function is used after the driver has finished collecting data in fast streaming
mode. It allows you to retrieve data with different aggregation ratios, and thus zoom
in to and out of any region of the data.
Before calling this function, first capture some data in fast streaming mode, stop fast
streaming by calling ps2000_stop(), then allocate sufficient buffer space to receive the
requested data. The function will store the data in your buffer with values in the
range PS2000_MIN_VALUE to PS2000_MAX_VALUE. The special value
PS2000_LOST_DATA is stored in the buffer when data could not be collected because
of a buffer overrun. (See Scaling for more on data values.)
Each sample of aggregated data is created by processing a block of raw samples. The
aggregated sample is stored as a pair of values: the minimum and the maximum
values of the block.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 17
Bit 0: Ch A overflow
Bit 1: Ch B overflow
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
18 API Functions
6.5 ps2000_get_streaming_values_no_aggregation
unsigned long ps2000_get_streaming_values_no_aggregation (
short handle,
double *start_time,
short *pbuffer_a,
short *pbuffer_b,
short *pbuffer_c,
short *pbuffer_d,
short *overflow,
unsigned long *triggerAt,
short *trigger,
unsigned long no_of_values
)
This function retrieves raw streaming data from the driver's data store after fast
streaming has stopped.
Before calling the function, capture some data using fast streaming, stop streaming
using ps2000_stop(), and then allocate sufficient buffer space to receive the requested
data. The function will store the data in your buffer with values in the range
PS2000_MIN_VALUE to PS2000_MAX_VALUE. The special value PS2000_LOST_DATA
is stored in the buffer when data could not be collected because of a buffer overrun.
(See Scaling for more details of data values.)
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 19
Bit 0 - Ch A overflow
Bit 1 - Ch B overflow
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
20 API Functions
6.6 ps2000_get_timebase
short ps2000_get_timebase (
short handle,
short timebase,
long no_of_samples,
long *time_interval,
short *time_units,
short oversample,
long *max_samples
)
This function discovers which timebases are available on the oscilloscope. You should
set up the channels using ps2000_set_channel() and, if required, ETS mode using
ps2000_set_ets() first. Then call this function with increasing values of timebase,
starting from 0, until you find a timebase with a sampling interval and sample count
close enough to your requirements.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 21
6.7 ps2000_get_times_and_values
long ps2000_get_times_and_values (
short handle
long *times,
short *buffer_a,
short *buffer_b,
short *buffer_c,
short *buffer_d,
short *overflow,
short time_units,
long no_of_values
)
This function is used to get values and times in block mode after calling
ps2000_run_block().
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
22 API Functions
Applicability Block mode only. It will not return any valid times if the
oscilloscope is in streaming mode.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 23
6.8 ps2000_get_unit_info
short ps2000_get_unit_info (
short handle,
char *string,
short string_length,
short line
)
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
24 API Functions
6.9 ps2000_get_values
long ps2000_get_values (
short handle
short *buffer_a,
short *buffer_b,
short *buffer_c,
short *buffer_d,
short *overflow,
long no_of_values
)
This function is used to get values in compatible streaming mode after calling
ps2000_run_streaming(), or in block mode after calling ps2000_run_block().
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 25
6.10 ps2000_last_button_press
short ps2000_last_button_press (
short handle
)
This function returns the last registered state of the pushbutton on the PicoScope
2104 or 2105 PC Oscilloscope and then resets the status to zero.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
26 API Functions
6.11 ps2000_open_unit
short ps2000_open_unit (
void
)
This function opens a PicoScope 2000 Series oscilloscope. The driver can support up to
64 oscilloscopes.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 27
6.12 ps2000_open_unit_async
short ps2000_open_unit_async (
void
)
This function opens a PicoScope 2000 Series oscilloscope without waiting for the
operation to finish. You can find out when it has finished by periodically calling
ps2000_open_unit_progress() until that function returns a non-zero value and a valid
oscilloscope handle.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
28 API Functions
6.13 ps2000_open_unit_progress
short ps2000_open_unit_progress (
short *handle,
short *progress_percent
)
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 29
6.14 ps2000_overview_buffer_status
short ps2000_overview_buffer_status (
short handle,
short *previous_buffer_overrun
)
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
30 API Functions
6.15 ps2000_ready
short ps2000_ready (
short handle
)
This function checks to see if the oscilloscope has finished the last data collection
operation.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 31
6.16 ps2000_run_block
short ps2000_run_block (
short handle,
long no_of_samples,
short timebase,
short oversample,
long *time_indisposed_ms
)
This function tells the oscilloscope to start collecting data in block mode.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
32 API Functions
6.17 ps2000_run_streaming
short ps2000_run_streaming (
short handle,
short sample_interval_ms,
long max_samples,
short windowed
)
This function tells the oscilloscope to start collecting data in compatible streaming
mode. If this function is called when a trigger has been enabled, the trigger settings
will be ignored.
For streaming with the PicoScope 2203, 2204, 2204A, 2205 and 2205A variants, use
ps2000_run_streaming_ns() instead.
windowed: if this is 0, only the values taken since the last call to
ps2000_get_values() are returned. If this is 1, the number of values
requested by ps2000_get_values() are returned, even if they have
already been read by ps2000_get_values().
Returns non-zero: if streaming has been enabled correctly.
0: if a problem occurred or a value was out of range.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 33
6.18 ps2000_run_streaming_ns
short ps2000_run_streaming_ns (
short handle,
unsigned long sample_interval,
PS2000_TIME_UNITS time_units,
unsigned long max_samples,
short auto_stop,
unsigned long noOfSamplesPerAggregate,
unsigned long overview_buffer_size
)
This function tells the oscilloscope to start collecting data in fast streaming mode. It
returns immediately without waiting for data to be captured. After calling it, you
should next call ps2000_get_streaming_last_values() to copy the data to your
application's buffer.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
34 API Functions
6.19 ps2000SetAdvTriggerChannelConditions
short ps2000SetAdvTriggerChannelConditions(
short handle,
PS2000_TRIGGER_CONDITIONS *conditions,
short nConditions
)
This function sets up trigger conditions on the scope's inputs. The trigger is defined by
a PS2000_TRIGGER_CONDITIONS structure.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 35
Remarks
The channels that are set to CONDITION_TRUE or CONDITION_FALSE must all meet
their conditions simultaneously to produce a trigger. Channels set to
CONDITION_DONT_CARE are ignored.
The oscilloscope can use only a single input channel (either channel A or channel B)
for the trigger source. Therefore you may define CONDITION_TRUE or
CONDITION_FALSE for only one of these channels at a time. You can, optionally, set
up the pulse width qualifier in combination with one of the input channels.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
36 API Functions
6.20 ps2000SetAdvTriggerChannelDirections
short ps2000SetAdvTriggerChannelDirections(
short handle,
PS2000_THRESHOLD_DIRECTION channelA,
PS2000_THRESHOLD_DIRECTION channelB,
PS2000_THRESHOLD_DIRECTION channelC,
PS2000_THRESHOLD_DIRECTION channelD,
PS2000_THRESHOLD_DIRECTION ext
)
This function sets the direction of the trigger for each channel.
PS2000_THRESHOLD_DIRECTION constants
ABOVE for gated triggers: above a threshold
BELOW for gated triggers: below a threshold
RISING for threshold triggers: rising edge
FALLING for threshold triggers: falling edge
RISING_OR_FALLING for threshold triggers: either edge
INSIDE for window-qualified triggers: inside window
OUTSIDE for window-qualified triggers: outside window
ENTER for window triggers: entering the window
EXIT for window triggers: leaving the window
ENTER_OR_EXIT for window triggers: either entering or leaving the window
NONE no trigger
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 37
6.21 ps2000SetAdvTriggerChannelProperties
short ps2000SetAdvTriggerChannelProperties(
short handle,
PS2000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,
short nChannelProperties,
long autoTriggerMilliseconds
)
This function is used to enable or disable triggering and set its parameters.
channelProperties: a pointer to a
PS2000_TRIGGER_CHANNEL_PROPERTIES structure describing the
requested properties. If NULL, triggering is switched off.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
38 API Functions
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 39
6.22 ps2000SetAdvTriggerDelay
short ps2000SetAdvTriggerDelay(
short handle,
unsigned long delay,
float preTriggerDelay
)
This function sets the pre-trigger and post-trigger delays. The default action, when
both these delays are zero, is to start capturing data beginning with the trigger event
and to stop a specified time later. The start of capture can be delayed by using a non-
zero value of delay. Alternatively, the start of capture can be advanced to a time
before the trigger event by using a negative value of preTriggerDelay. If both
arguments are non-zero then their effects are added together.
Applicability All modes. PicoScope 2202, 2204, 2204A, 2205 and 2205A only
Arguments handle: the handle of the required oscilloscope.
Example 1: Example 2:
delay = 0, delay = 1 ms,
preTriggerDelay = –50% preTriggerDelay = –50%
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
40 API Functions
6.23 ps2000_set_channel
short ps2000_set_channel (
short handle,
short channel,
short enabled,
short dc,
short range
)
Specifies if a channel is to be enabled, the AC/DC coupling mode and the input range.
range: a code between 1 and 10. See the table below, but note
that each oscilloscope variant supports only a subset of these
ranges.
Returns 0: if unsuccessful, or if one or more of the arguments are out of
range
non-zero: if successful
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 41
6.24 ps2000_set_ets
long ps2000_set_ets (
short handle,
short mode,
short ets_cycles,
short ets_interleave
)
This function is used to enable or disable ETS (equivalent time sampling) and to set
the ETS parameters.
mode:
PS2000_ETS_OFF (0) - disables ETS
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
42 API Functions
6.25 ps2000_set_light
short ps2000_set_light (
short handle,
short state
)
This function controls the white light that illuminates the probe tip on a handheld
oscilloscope.
state:
0: light off
1: light on
Returns 0: the function failed, for example if a PicoScope 2000 Series
oscilloscope was not found.
non-zero: success.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 43
6.26 ps2000_set_led
short ps2000_set_led (
short handle,
short state
)
This function turns the LED on the oscilloscope on and off, and controls its colour.
state:
3: off
1: red
2: green
Returns 0: the function failed, for example if a PicoScope 2000 Series
oscilloscope was not found.
non-zero: success.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
44 API Functions
6.27 ps2000SetPulseWidthQualifier
short ps2000SetPulseWidthQualifier(
short handle,
PS2000_PWQ_CONDITIONS *conditions,
short nConditions,
PS2000_THRESHOLD_DIRECTION direction,
unsigned long lower,
unsigned long upper,
PS2000_PULSE_WIDTH_TYPE type
)
This function sets up pulse width qualification, which can be used on its own for pulse
width triggering or combined with other triggering to produce more complex triggers.
The pulse width qualifier is set by defining a conditions structure.
upper: the upper limit of the pulse width counter. This parameter
is used only when the type is set to PW_TYPE_IN_RANGE or
PW_TYPE_OUT_OF_RANGE.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 45
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
46 API Functions
6.28 ps2000_set_sig_gen_arbitrary
short ps2000_set_sig_gen_arbitrary (
short handle,
long offsetVoltage,
unsigned long pkToPk,
unsigned long startDeltaPhase,
unsigned long stopDeltaPhase,
unsigned long deltaPhaseIncrement,
unsigned long dwellCount,
unsigned char *arbitraryWaveform,
long arbitraryWaveformSize,
PS2000_SWEEP_TYPE sweepType,
unsigned long sweeps
)
This function programs the signal generator to produce an arbitrary waveform.
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 generator steps through the waveform by adding a deltaPhase value between 1
and phaseAccumulatorSize-1 to the phase accumulator every ddsPeriod (1 /
ddsFrequency). If the deltaPhase is constant, the generator produces a waveform at a
constant frequency that can be calculated as follows:
Parameter Value
phaseAccumulatorSize 232
awgBufferSize 4096
ddsFrequency 48 MHz
ddsPeriod (= 1/ddsFrequency) 20.833 ns (= 1/48 MHz)
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 47
Applicability All modes. PicoScope 2203, 2204, 2204A, 2205 and 2205A only.
Arguments
handle: the handle of the required oscilloscope
startDeltaPhase: the initial value added to the phase counter as the generator
begins to step through the waveform buffer
stopDeltaPhase: the final value added to the phase counter before the generator
restarts or reverses the sweep
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.
sweeps: the number of times to sweep the frequency after a trigger event,
according to sweepType.
Returns 0: if one of the parameters is out of range.
non-zero: if successful.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
48 API Functions
6.29 ps2000_set_sig_gen_built_in
short ps2000_set_sig_gen_built_in (
short handle,
long offsetVoltage,
unsigned long pkToPk,
PS2000_WAVE_TYPE waveType,
float startFrequency,
float stopFrequency,
float increment,
float dwellTime,
PS2000_SWEEP_TYPE sweepType,
unsigned long sweeps
)
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 oscilloscope will
sweep either up, down or up and down.
waveType: the type of waveform to be generated by the oscilloscope. See the table
below.
startFrequency: the frequency at which the signal generator should begin. For
allowable values see ps2000.h.
increment: the amount by which the frequency rises or falls every dwellTime
seconds in sweep mode
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 49
waveType values
PS2000_SINE sine wave
PS2000_SQUARE square wave
PS2000_TRIANGLE triangle wave
PS2000_RAMP_UP rising sawtooth
PS2000_RAMP_DOWN falling sawtooth
PS2000_DC_VOLTAGE DC voltage
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
50 API Functions
6.30 ps2000_set_trigger
short ps2000_set_trigger (
short handle,
short source,
short threshold,
short direction,
short delay,
short auto_trigger_ms
)
This function is used to enable or disable basic triggering and its parameters.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 51
6.31 ps2000_set_trigger2
short ps2000_set_trigger2 (
short handle,
short source,
short threshold,
short direction,
float delay,
short auto_trigger_ms
)
This function is used to enable or disable triggering and its parameters. It has the
same behaviour as ps2000_set_trigger(), except that the delay parameter is a
floating-point value.
Applicability Triggering is available in block mode and fast streaming mode only.
Arguments handle, the handle of the required oscilloscope.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
52 API Functions
6.32 ps2000_stop
short ps2000_stop (
short handle
)
Call this function to stop the oscilloscope sampling data. If this function is called
before a trigger event occurs, the oscilloscope may not contain valid data.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 53
6.33 my_get_overview_buffers
void my_get_overview_buffers (
short **overviewBuffers,
short overflow,
unsigned long triggeredAt,
short triggered,
short auto_stop,
unsigned long nValues
)
This is the callback function in your application that receives data from the driver in
fast streaming mode. You pass a pointer to this function to
ps2000_get_streaming_last_values(), which then calls it back when the data is ready.
Your callback 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.
For an example of a suitable callback function, see the C sample code included in the
PicoScope 2000 Series SDK.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
54 API Functions
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 55
7 Programming examples
7.1 C
There are two C example programs: a simple GUI application, and a more
comprehensive console mode program that demonstrates all of the facilities of the
driver.
GUI example
The GUI example program is a generic Windows application - that is, it does not use
Borland AppExpert or Microsoft AppWizard. To compile the program, create a new
project for an Application containing the following files:
ps2000.c
resource.h
and
ps2000.rch
ps2000.h
and the following file must be in the same directory as the executable.
ps2000.dll
Console example
The console example program is also a generic Windows application - that is, it does
not use Borland AppExpert or Microsoft AppWizard. To compile the program, create a
new project for an Application containing the following files:
ps2000con.c
and
ps2000.h
and the following file must be in the same directory as the executable.
ps2000.dll
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
56 Programming examples
Return values
The functions that return a TRUE/FALSE value return 0 for FALSE and 1 for TRUE,
whereas Visual Basic expects 65535 for TRUE. To avoid this problem, check for > 0
rather than = TRUE.
7.3 Delphi
The program ps2000.dpr demonstrates how to operate PicoScope 2000 Series PC
Oscilloscopes. The file ps2000.inc contains procedure prototypes that you can
include in your own programs. Other required files include:
ps2000.res
ps2000fm.dfm
ps2000fm.pas
7.4 Excel
1. Load the spreadsheet ps2000.xls
2. Select Tools | Macro
3. Select GetData
4. Select Run
Note: the Excel Macro language is similar to Visual Basic. The functions which return
a TRUE/FALSE value, return 0 for FALSE and 1 for TRUE, whereas Visual Basic
expects 65 535 for TRUE. Check for > 0 rather than = TRUE.
7.5 LabVIEW
The ps2000.vi example in the Examples subdirectory shows how to access the
driver functions using LabVIEW. It was tested using version 6.1 of LabVIEW for
Windows. To use the example, copy these files to your LabVIEW directory:
ps2000.vi
open_unit.vi
set_channel.vi
setup_data_collection.vi
ps2000.dll
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 57
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
58 Glossary
9 Glossary
Aggregation. In fast streaming mode, the PicoScope 2000 driver can use a method
called aggregation to reduce the amount of data your application needs to process.
This means that for every block of consecutive samples, it stores only the minimum
and maximum values. You can set the number of samples in each block, called the
aggregation parameter, when you call ps2000_run_streaming_ns() for real-time
capture, and when you call ps2000_get_streaming_values() to obtain post-processed
data.
Analog bandwidth. The input frequency at which the signal amplitude has fallen by
3 dB, or by half the power, from its nominal value.
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 is the best mode to use
when the input signal being sampled contains high frequencies. To avoid aliasing
effects, the sampling rate must be greater than twice the maximum frequency in the
input signal.
Buffer size. The size of the oscilloscope's buffer memory. The oscilloscope uses this
to store data temporarily so that it can sample data independently of the speed at
which it can transfer data to the computer.
Driver. A piece of software that controls a hardware device. The driver for the
PicoScope 2000 Series PC Oscilloscopes is supplied in the form of a 32-bit Windows
DLL, which contains functions that you can call from your application.
ETS. Equivalent time sampling. Some PicoScope 2000 Series oscilloscopes can collect
data over a number of cycles of a repetitive waveform to give a higher effective
sampling rate than is possible for a single cycle. Equivalent time sampling allows the
oscilloscope to use faster timebases than those available in real-time mode.
Maximum sampling rate. A figure indicating the maximum number of samples the
oscilloscope is capable of acquiring per second. Maximum sample rates are usually
given in MS/s (megasamples per second) or GS/s (gigasamples per second). The
higher the sampling speed of the oscilloscope, the more accurate the representation of
the high-frequency details in a fast signal.
Overview buffer. A buffer in the PC's memory in which the PicoScope 2000 Series
driver temporarily stores data on its way from the oscilloscope to the application's
buffer.
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 59
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 suitable
when the input signal being sampled contains only low frequencies.
Timebase. A number that is supplied to the driver to specify a sampling rate for the
oscilloscope. Each oscilloscope model has a different range of possible sampling
frequencies, as specified in the User's Guide for that model.
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.
Vertical resolution. A value, in bits, that indicates the number of input voltage levels
that the oscilloscope can distinguish. Calculation techniques can improve the effective
resolution.
Voltage range. The range of input voltages that the oscilloscope will measure in a
given mode.
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
PicoScope 2000 Series Programmer's Guide 61
Index ps2000_get_streaming_last_values
ps2000_get_streaming_values 16
15
ps2000_get_streaming_values_no_aggregation
18
A ps2000_get_timebase 20
ps2000_get_times_and_values 21
AC/DC switch 6, 40 ps2000_get_unit_info 23
Advanced triggering 34, 36, 37, 44 ps2000_get_values 24
Aggregation 9, 16, 33 ps2000_last_button_press 25
Aliasing 6 ps2000_open_unit 26
Arbitrary wveform generator 46 ps2000_open_unit_async 27
AWG 46 ps2000_open_unit_progress 28
ps2000_overview_buffer_status 29
B ps2000_ready 30
ps2000_run_block 31
Block mode 6, 7, 10, 31
ps2000_run_streaming 32
C ps2000_run_streaming_ns
ps2000_set_channel 40
33
F Installation 4
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
62 Index
Light 4, 42 windowed 8
Sweep 6
M System requirements, minimum 1
Macros in Excel
Memory in scope
56
7
T
Multi-unit operation 11 Threshold voltage 6
Time interval 6, 10
N Timebase 20, 31
Trademarks 3
Normal mode 8
Trigger delay 39
Triggering 6, 10, 50, 51
O
One-shot signal 10 U
Opening a unit 26, 27, 28 USB 1
Oversampling 6 cable 4
Overview buffer 29 hub 11
P V
PC Oscilloscope 1
Vertical resolution 6
PicoLog software 1 Visual Basic example code 56
picopp.inf 5
picopp.sys 5
PicoScope 2000 Series 1, 11, 57
W
PicoScope software 1, 5, 57 Warranty 3
Post-trigger delay 39 Windowed mode 8
Pre-trigger 6
Pre-trigger delay 39
Probe 4
PS2000_PWQ_CONDITIONS structure 45
PS2000_THRESHOLD_DIRECTION constants 36
PS2000_TRIGGER_CHANNEL_PROPERTIES
structure 38
PS2000_TRIGGER_CONDITIONS structure 35
R
Resolution, vertical 6
S
Sampling modes 7
Sampling rate 10
Signal generator 6, 7
arbitrary waveforms 46
built-in waveforms 48
Spectrum analyser 1
Stopping sampling 52
Streaming mode
compatible 8
fast 9
normal 8
ps2000pg.en r10 Copyright © 2006-2013 Pico Technology Ltd. All rights reserved.
PicoScope 2000 Series Programmer's Guide 63
Copyright © 2006-2013 Pico Technology Ltd. All rights reserved. ps2000pg.en r10
Pico Technology
James House
Colmworth Business Park
ST. NEOTS
Cambridgeshire
PE19 8YP
United Kingdom
Tel: +44 (0) 1480 396 395
Fax: +44 (0) 1480 396 296
www.picotech.com