Lab::Instrument::TDS2024B - Tektronix TDS2024B digital oscilloscope
version 3.651
use Lab::Instrument::TDS2024B; my $s = new Lab::Instrument::TDS2024B ( usb_serial => 'C12345', # usb_vendor and usb_product set automatically ); $s->set_channel(3); $s->set_scale(scale=>'20mV/div'); $s->set_display_persist(persist=>'5s'); $s->set_acquire_average(32); $s->set_acquire_state(state=>'RUN');
Many of the 'quantities' passed to the code can use scientific notation, order of magnitude suffixes ('u', 'm', etc) and unit suffixes. The routines can be called using positional parameters (check the documentation for order), or with keyword parameters.
There are a few 'big' routines that let you set many parameters in one call, use keyword parameters for those.
In general, keywords passed TO these routines are case-independent, with only the first few characters being significant. So, in the example above: state=>'Run', state=>'running', both work. In cases where the keywords distinguish an "on/off" situation (RUN vs STOP for acquistion, for example) you can use a Boolean quantity, and again, the Boolean values are flexible:
TRUE = 't' or 'y' or 'on' or number!=0
FALSE = 'f' or 'n' or 'off' or number ==0
(only the first part of these is checked, case independent)
The oscilloscope input 'channels' are CH1..CH4, but there are also MATH, REFA..REFD that can be displayed or manipulated. To perform operations on a channel, one should first $s->set_channel($chan); Channel can be specified as 1..4 for the input channels, and it will be translated to 'CH1..CH4'.
The state of the TDS2024B scope is cached only when the front-panel is in a 'locked' state, so that it cannot be changed by users fiddling with knobs.
my $s = new Lab::Instrument::TDS2024B( usb_serial => '...', );
serial only needed if multiple TDS2024B scopes are attached, it defaults to '*', which selects the first TDS2024B found. See Lab::Bus::USBtmc.pm documentation for more information.
$s->reset()
Reset the oscilloscope (*RST)
($code,$message) = $s->get_error();
Fetch an error from the device error queue
$status = $s->get_status(['statusbit']);
Fetches the scope status, and returns either the requested status bit (if a 'statusbit' is supplied) or a reference to a hash of status information. Reading the status register causes it to be cleared. A status bit 'ERROR' is combined from the other error bits.
Example: $s->get_status('OPC');
Example: $s->get_status()->{'DDE'};
Status bit names:
PON: Power on
URQ: User Request (not used)
CME: Command Error
EXE: Execution Error
DDE: Device Error
QYE: Query Error
RQC: Request Control (not used)
OPC: Operation Complete
ERROR: CME or EXE or DDE or QYE
$s->wait_done([$time[,$deltaT]);
$s->wait_done(timeout => $time, checkinterval=>$deltaT);
Wait for "operation complete". If the $time optional argument is given, it is the (max) number of seconds to wait for completion before returning, otherwise a timeout of 10 seconds is used. $time can be a simple number of seconds, or a text string with magnitude and unit suffix. (Ex: $time = "200ms"). If $time="INF" then this routine will run indefinitely until completion (or some I/O error).
If $deltaT is given, checks are performed in intervals of $deltaT seconds (again, number or text), except when $deltaT is less than $time. $deltaT defaults to 500ms.
Returns 1 if completed, 0 if timed out.
$busy = $s->test_busy();
Returns 1 if busy (waiting for trigger, etc), 0 if not busy.
$s->get_id()
Fetch the *IDN? string from device
$header = $s->get_header();
Fetch whether headers are included with query response; returns 0 or 1.
$s->save($n);
$s->save(setup=>$n);
Save the scope setup to a nonvolatile internal memory $n = 1..10
$s->recall($n);
$s->recall(setup=>$n);
Recall scope setup from internal memory location $n = 1..10
$s->set_header($boolean); $s->set_header(header=>$boolean);
Turns on or off headers in query replies; Boolean values described above.
$verb = $s->get_verbose();
Fetch boolean indicating whether query responses (headers, if enabled, and response keywords) are returned in 'long form'
$s->set_verbose($bool); $s->set_verbose(verbose=>$bool);
Sets the 'verbose' mode for replies, with the longer form of command headers (if enabled) and keyword values. Note that when using the get_* routines, the replies are processed before being returned as 'long' values, so this routine only affects the communication between the scope and this code.
$locked = $s->get_locked()
Get whether user front-panel controls are locked. Returns 1 (all controls locked) or 0 (no controls locked). Caching for most quantities is turned off when the controls are unlocked.
$s->set_locked($bool); $s->set_locked(locked=>$bool);
Lock or unlock front panel controls;
NOTE: locking the front panel enables the device_cache, and reinitializes cached values (other than the special ones that are not alterable from the front panel)
$setup = get_setup();
Get a long GPIB string that has the scope setup information
Note that the scope I am testing with generates a "300, Device-specific error; no alternate chosen" error when triggering on "AC LINE". Might be a firmware bug, so filtering it out.
$s->set_setup($setup);
$s->set_setup(setup=>$setup);
Send configuration to scope. The '$setup' string is of the form returned from get_setup(), but can be any valid command string for the scope. The setup string is processed into separate commands, and transmitted sequentially, to avoid communications timeouts.
$acqmode = $s->get_acquire_mode();
Fetches acquisition mode: SAMple,PEAKdetect,AVErage
$s->set_acquire_mode($mode); $s->set_acquire_mode(mode=>$mode);
Sets the acquire mode: SAMple, PEAKdetect or AVErage
$numacq = $s->get_acquire_numacq();
Fetch the number of acquisitions that have happened since starting acquisition.
$numavg = $s->get_acquire_numavg();
Fetch the number of waveforms specified for averaging
$s->set_acquire_numavg($n); $s->set_acquire_numavg(average=>$n);
Set the number of waveforms to average valid values are 4, 16, 64 and 128
$state = $s->get_acquire_state()
Fetch the acquisition state: STOP (stopped) or RUN (running) NOTE: to check if acq is complete: wait_done()
$s->set_acquire_state($state); $s->set_acquire_state(state=>$state);
$state = 'RUN' (or boolean 'true') starts acquisition 'STOP' (or boolean 'false') stops acquisition
$mode = $s->get_acquire_stopafter();
Fetch whether acquisition is in "RUNSop" mode (run until stopped) or "SEQuence" mode
$s->set_acquire_stopafter($mode); $s->set_acquire_stopafter(mode=>$mode);
Sets stopafter mode: RUNStop : run until stopped, or SEQuence: stop after some defined sequence (single trigger, pattern, etc)
%hashref = $s->get_acquire();
Get the "acquire" information in a hash; this is a combined "get_acquire_*" with the keywords that can be use for set_acquire()
$s->set_acquire(state=>$state, # RUN|STOP (or boolean) mode=>$mode, # SAM|PEAK|AVE stopafter=>$stopa # STOPAfter|SEQ average=>$navg); $s->set_acquire($hashref); # from get_acquire $s->set_acquire($state,$mode,$stopa,$navg);
Sets acquisition parameters
$arstate = $s->get_autorange_state()
Fetch the autorange state, boolean, indicating whether the scope is autoranging
$s->set_autorange_state(state=>$bool); $s->set_autorange_state($bool);
Set autoranging on or off.
$arset = $s->get_autorange_settings()
Fetch the autorange settings, returns value (HORizontal|VERTical|BOTH)
$s->set_autorange_settings(set=>$arset);
$s->set_autorange_settings($arset);
Set what is subject to autoranging: $arset = HORizontal, VERTical, BOTH
$s->do_autorange();
Causes scope to adjust horiz/vert, like pressing 'autoset' button This command may take some time to complete.
$sig = $s->get_autorange_signal()
returns the type of signal found by the most recent autoset, or NON if the autoset menu is not displayed.
$view = $s->get_autoset_view();
Fetch the menu display; view can be one of (depending on scope options): MULTICY SINGLECY FFT RISING FALLING FIELD ODD EVEN LINE LINEN DCLI DEF NONE
$s->set_autoset_view($view)
$s->set_autoset_view(view=>$view)
Set the menu display; view can be one of (depending on scope options): MULTICY SINGLECY FFT RISING FALLING FIELD ODD EVEN LINE LINEN DCLI DEF NONE
%hashref = $s->get_autorange();
get autorange settings as a hash
$chan = $s->get_channel();
Get the current channel selected for operations 1..4
$s->set_channel(channel=>$chan); $s->set_channel($chan);
sets the channel number (1..4) for operations with the set_chan_XXX and get_chan_YYY methods on oscilloscope channels
Channel can be specified as an integer 1..4, or Ch1, Ch2, etc., or 'MATH'.
$s->set_visible([$chan,[$vis]]);
$s->set_visible(channel=>$chan [, visible=>$vis]);
Set/reset channel visiblity.
If no channel is given, the current channel (set by set_channel ) is used. Otherwise $chan = CH1..4, REFA..D, MATH
If $vis is not specified, it defaults to "make channel visible".
To make turn off display of a channel, use $vis=(boolean false).
$vis = $s->get_visible($chan);
$vis = $s->get_visible(channel=>$chan);
Fetch boolean value for whether the channel (CH1..4, REFA..D, MATH) is being displayed. If channel is not specified, the current channel (from 'set_channel()') is used.
$bwlim = $s->get_chan_bwlimit()
Fetch whether the channel has bandwidth limited to 20MHz (boolean)
$s->set_chan_bwlimit(limit=>'on')
Turns on or off bandwith limiting (limit = boolean, true = 'limit')
$coupling = $s->get_chan_coupling()
Fetch the channel coupling (AC/DC/GND).
$s->set_coupling(coupling => $coupling);
Set the coupling to AC|DC|GND for an input channel
$iprobe = $s->get_chan_current_probe();
Get the probe scale factor. This does not mean that a current probe is in use, just what 'probe scale factor' would be applied if current probe use is selected.
$self->set_chan_current_probe(factor=>$x);
Set the current probe scale factor. Valid values are 0.2, 1, 2, 5, 10, 50, 100, 1000
$inv = $s->get_chan_invert();
fetch whether the channel is 'inverted' -> boolean
$s->set_chan_invert(invert=>$inv);
sets a channel to 'invert' mode if $inv is true, $inv=boolean
$p = $s->get_chan_position();
get the vertical position of "zero volts" for a channel The value is the number of graticule divisions from the center.
$s->set_chan_position(position=> -24)
Sets the trace 'zero' position, in graticule divisions from the center of the display. Note that the limits depend on the vertical scale, +/- 50V for >= 500mV/div, +/- 2V for < 500mV/div
$probe = $s->get_chan_probe();
Fetch the voltage probe attenuation.
$self->set_chan_probe(factor=>X);
Set the voltage probe scale factor. Valid values are 1, 10, 20, 50, 100, 500, 1000
$scale = $s->get_chan_scale();
Fetch the vertical scale for a channel, in V/div (or A/div when used with a current probe)
$self->set_chan_scale(scale=>$scale);
Set the vertical scale for a channel, in V/div or A/div. X can be a number, or a string with suffixes and units Ex: '2.0V/div' '100m'.
$scale = $s->get_chan_yunit();
Fetch the units for the vertical scale of a channel, returns either "V" or "A"
$self->set_chan_yunit(unit=>X);
Set the vertical scale units to either 'V' or 'A'
$hashref = $s->get_chan_setup([channel=>$chan])
Fetches channel settings and returns them as a hashref: =over 2 =item channel => channel selected (otherwise default from set_channel) =item probe => probefactor, =item postion => screen vertical position, in divisions =item scale => screen vertical scale, V/div or A/div =item coupling => (AC|DC|GND) =item bandwidth => (ON|OFF) =item yunit => (V|A) =item invert => ON|OFF =item probe => probe attentuation (for yunit=V) =item currentprobe => current probe factor (for yunit=A) =back
The hash is set up so that it can be passed to $s->set_channel($hashref)
$s->set_channel([channel=>1],scale=>...)
Can pass the hash returned from "get_chan_setup" to set a an oscilloscope channel to the desired state.
TODO: check current/voltage probe selection, adjust order of calls to avoid settings conflicts
The cursors can either be 'horizontal bars' (HBARS), attached to a particular trace, measuring amplitude; or 'vertical bars' (VBARS) that are measuring horizontally (time or frequency).
Since these names can be confusing, you can also use 'X' to select VBARS and 'Y' to select HBARS, since that gives a more natural indication of what you are measuring.
$cursor = $s->get_cursor_type([$opt]);
$cursor = $s->get_cursor_type([option=>$opt]);
Fetch cursor type: (OFF|HBARS|VBARS) default
cursor type returned as: (OFF|X|Y) if $opt = 'xy';
$s->set_cursor_type($type);
$s->set_cursor_type(type=>$type)
$type = OFF|HBAr|Y|VBAr|X
$units = $s->get_cursor_xunits()
gets the x (horizontal) units for the cursors (VBAR type), returns either SECONDS or HERTZ.
$self->get_cursor_yunits();
Fetch the units used for the cursor y positions (HBARS, or the waveform vertical position with VBARS).
The units returned can be: VOLTS, DIVISIONS, DECIBELS UNKNOWN AMPS VOLTSSQUARED AMPSSQUARED VOLTSAMPS.
$src = $s->get_cursor_source();
Fetch the source waveform being used with the cursors, determines the units of the cursor for horizontal bar (HBAR, Y) cursors.
$s->set_cursor_sourch($chan);
$s->set_cursor_source(channel => $chan);
$s->set_cursor_xunits($units);
$s->set_cursor_xunits(unit=>$units);
Set the units used for VBAR (x) cursor, for VBAR the possible units are (SEConds|s) or (HERtz|Hz). HBAR cursor units cannot be changed.
$delt = $s->get_cursor_dx();
Fetch the difference between x (VBAR) cursor positions.
$delt = $s->get_cursor_dy();
Fetch the difference between y (HBAR) cursor positions.
$pos = $s->get_cursor_x1();
Fetch the x position of cursor 1 (VBAR), typically in units of seconds.
$pos = $s->get_cursor_x2();
Fetch the x position of cursor 2 (VBAR), typically in units of seconds.
$pos = $s->get_cursor_y1();
Fetch the y position of cursor 1 (HBAR), typically in units of volts, but possibly other units
$pos = $s->get_cursor_y2();
Fetch the y position of cursor 2 (HBAR), typically in units of volts, but possibly other units.
$s->set_cursor_x1($location);
$s->set_cursor_x1(position => $location);
set cursor 1 x location (VBAR type cursor)
$s->set_cursor_x2($location);
$s->set_cursor_x2(position => $location);
set cursor 2 x location (VBAR type cursor)
$s->set_cursor_y1($location);
$s->set_cursor_y1(position => $location);
set cursor 1 y position (HBAR type)
$s->set_cursor_y2($location);
$s->set_cursor_y2(position => $location);
set cursor 2 y position (HBAR type)
$vcursor = $s->get_cursor_v1();
If using HBAR (y) cursors, get the vertical position of cursors; if using VBAR (x) cursors, get the waveform voltage (or other vertical unit) at the cursor1 position.
$vcursor = $s->get_cursor_v2();
If using HBAR (y) cursors, get the vertical position of cursors; if using VBAR (x) cursors, get the waveform voltage (or other vertical unit) at the cursor2 position.
$dv = $s->get_cursor_dv();
Get the vertical distance between the cursors (dy if HBAR cursors, dv2-dv1 if VBAR cursors)
Fetches cursor information and returns it in a hash, in a form that can be used with set_cursor()
$s->set_cursor( type=>$type, x1 => $x1, x2 => $x2, ...);
sets cursor information. If used with a hash from get_cursor, the entries that cannot be used to set the cursors are ignored
$cont = $s->get_display_contrast()
Fetches the display contrast: 1 .. 100
$s->set_display_contrast($cont)
(alternate set_display_contrast(contrast => number) ) Set the display contrast, percent 1..100
$form = $s->get_display_format()
Fetch the display format: YT or XY
$s->set_display_format($format);
$s->set_display_format(format => $format);
Where $format = XY or YT.
$pers = $s->get_display_persist()
Fetch the display persistance, values 1,2,5,INF,OFF Numbers are in seconds.
$s->set_display_persist($pers);
$s->set_display_persist(persist=>$pers);
Sets display persistence. $pers = 1,2,5 seconds, INF, or OFF
$style = $s->get_display_style()
Fetch the display style = 'DOTS' or 'VECTORS'
$s->set_display_style($style)l\;
$s->set_display_style(style=>$style);
Sets the display style: $style is DOTs or VECtors
$hashref = $s->get_display();
Fetch display settings (contrast, format, etc) in a hash, that can be used with "set_display".
$s->set_display(contrast=>$contrast, ...)
Set the display characteristics
$s->get_cwd();
Gets the current working directory on any USB flash drive plugged into the oscilloscope, or a null string ( '' ) if no drive is plugged in.
$s->set_cwd($cwd);
$s->set_cwd(cwd => $cwd);
Set the current working directory on the flash drive. The flash drive is on the "A:" drive, and the cwd uses "DOS" type syntax. For compatibility, forward slashes are translated to backslashes.
It would be a good idea to check for errors after this call.
$self->delete($file);
$self->delete(file => $file);
Delete a file from the USB filesystem; use DOS format, and note that the USB filesystem is on "A:\topdir\subdir..."
For ease of use, this routine translates forward slashes to backslashes. It would be a good idea to check for errors after calling this routine.
@files = $s->get_dir();
Get a list of filenames in the current (USB flash drive) directory.
$bytes = $s->get_freespace();
Get the amount of freespace on the USB flash.
$s->mkdir($dirname);
$s->mkdir(directory=>$dirname);
Create a directory on the flash drive, uses MSDOS file syntax, only on the A: drive.
Forward slashes are translated to backslashes for compatibility.
It is a good idea to check for errors after calling this routine.
$s->rename($old,$new);
$s->rename(old=>$old, new=>$new);
Rename $old filepath to $new filepath. Note that these are in MSDOS file syntax, all on the "A:" drive.
Forward slashes are translated to backslashes.
$s->rmdir($dir);
$s->rmdir(directory=>$rmdir);
Removes a directory from the USB flash drive. The directory name is in MSDOS syntax; forward slashes are translated to backslashes.
A directory must be empty before deletion; it is a good idea to check for errors after calling this routien.
$format = $s->get_hardcopy_format();
Fetch the hardcopy format, returns one of:
BMP BUBBLEJET DESKJET DPU3445 DPU411 DPU412 EPSC60 EPSC80 EPSIMAGE EPSON INTERLEAF JPEG LASERJET PCX RLE THINK TIFF
$s->set_hardcopy_format($format);
$s->set_hardcopy_format(format => $format);
Set the 'hardcopy' format, used for screen captures:
$layout = $s->get_hardcopy_layout();
Fetch the hardcopy layout: PORTRAIT or LANDSCAPE
$s->set_hardcopy_layout($layout);
$s->set_hardcopy_layout(layout => $layout);
Set the hardcopy layout: LANdscpe or PORTRait.
$port = $s->get_hardcopy_port();
Fetch the port used for hardcopy printing; for the TDS2024B, this should aways return 'USB'.
$s->set_hardcopy_port($port);
$s->set_hardcopy_port(port => $port);
Set the hardcopy port; for the TDS2024B, this should always be USB. Included for compatibility with other scopes.
$hashref = get_hardcopy();
Fetch hardcopy parameters (format, layout, port; although port is always 'USB') and return in a hashref.
$s->set_hardcopy(format=>$format, layout=>$layout, port=>$port);
Set hardcopy parameters; this can use a hashref returned from get_hardcopy();
$img = $s->get_image();
$img = $s->get_image($filename[, $force]);
$img = $s->get_image(file=>$filename, force=>$force, timeout=>$timeout, read_length=>$rlength, [hardcopy options]);
Fetch a screen-capture image of the scope, using the the current hardcopy options (format, layout). If the filename is specified, write to that filename (in addition to returning the image data); error if the file already exists, unless $force is true.
timeout (in seconds) and read_length (in bytes) are only passed with the "hash" form of the call.
$view = $s->get_horiz_view();
Fetch the horizontal view: MAIN, WINDOW, ZONE
WINDOW is a selection of the MAIN view; ZONE is the same as MAIN, but with vertical bar cursors to show the range displayed in WINDOW view.
$s->set_horiz_view($view);
$s->set_horiz_view(view=>$view);
Set the horizontal view to MAIn, WINDOW, or ZONE.
$pos = $s->get_horiz_position();
Fetch the horizontal position of the main view, in seconds; this is the difference between the trigger point and the horizontal center of the screen.
$s->set_horiz_position($t);
$s->set_horiz_position(time => $t);
Set the horizontal position, in seconds, for the main view. Positive time values puts the trigger point to the left of the center of the screen.
$time = $s->get_delay_position();
Fetch the delay time for the WINDOW view. Time is relative to the center of the screen.
$s->set_delay_position($time);
$s->set_delay_position(delaytime=>$time);
Set the postion of the WINDOW view horizontally. $time is in seconds, relative to the center of the screen.
$secdiv = $s->get_horiz_scale();
Fetch the scale (in seconds/division) for the 'main' view.
$s->set_horiz_scale($secdiv);
$s->set_horiz_scale(scale=>$secdiv);
Set the horizontal scale, main window, to $secdiv seconds/division.
$secdiv = $s->get_delay_scale();
Fetch the scale (in seconds/division) for the 'window' view.
$s->set_del_scale($secdiv);
$s->set_del_scale(delayscale=>$secdiv);
Set the horizontal scale, window view, to $secdiv seconds/division.
$samples = $s->get_recordlength();
Returns record length, in number of samples. For the TDS200B, this is always 2500, so a constant is returned.
$hashref = $s->get_horizontal();
Fetch a hashref, with entries that describe the horizontal setup, and can be passesd to set_horizontal
keys: view, time, delaytime, scale, delayscale, recordlength
$s->set_horizontal(time=>..., scale=>...);
Set the horizontal characteristics. See get_horizontal()
$string = $s->get_math_definition();
Fetch the definition used for the MATH waveform
$s->set_math_definition($string);
$s->set_math_definition(math => $string);
Define the 'MATH' waveform; the input is sufficiently complex that the user should check for errors after calling this routine.
Choices:
CH1+CH2 CH3+CH4 CH1-CH2 CH2-CH1 CH3-CH4 CH4-CH3 CH1*CH2 CH3*CH4 FFT (CHx[, <window>])
<window> is HANning, FLATtop, or RECTangular.
$y => $s->get_math_position();
Fetch the MATH trace vertical position, in divisions from the center of the screen.
$s->set_math_position($y);
$s->set_math_postition(position=>$y);
Set the MATH trace veritical position, in divisions from the center of the screen.
$pos = $s->get_fft_xposition();
Fetch FFT horizontal position, a percentage of the total FFT length, relative to the center of the screen.
$s->set_fft_xposition($percent);
$s->set_fft_xposition(fft_xposition=>$percent);
Set the horizontal position of the FFT trace; the "percent" of the trace is placed at the center of the screen.
$scale = $s->get_fft_xscale();
Fetch the horizontal zoom factor for FFT display, possible values are 1,2,5 and 10.
$s->set_fft_xscale($zoom);
$s->set_fft_xscale(fft_xscale => $zoom);
Set the FFT horizontal scale zoom factor: 1,2,5, or 10.
$divs = $s->get_fft_position();
Fetch the y position of the FFT display, in division from the screen center.
$s->set_fft_position($divs);
$s->set_fft_position(fft_position=>$divs);
Set the FFT trace y position, in screen divisions relative to the screen center.
$zoom = $s->get_fft_scale();
Fetch the FFT vertical zoom factor, returns one of 0.5, 1, 2, 5, 10
$s->set_fft_scale($zoom);
$s->set_fft_yscale(fft_scale => $zoom);
Set the fft vertical zoom factor, valid values are 0.5, 1, 2, 5, 10
The TDS2024B manual suggests using the 'IMMediate' measurements; when measurements 1..5 are used, it results in an on-screen display of the measurement results, because the on-screen display is update (at most) every 500ms. It would be a good idea to check for errors after calling get_measurement_value, because errors can result if the waveform is out of range. Also note that when the MATH trace is in FFT mode, 'normal' measurement is not possible.
The 'IMMediate' measurements cannot be accessed from the scope front panel, so will be cached even if the scope is in an 'unlocked' state. (see set_locked)
$type = $s->get_measurement_type($n);
$type = $s->get_measurement_type(measurement=>$n);
Fetch the measurement type for measurement $n = 'IMMediate' or 1..5 $n defaults to 'IMMediate'
returns one of: FREQuency | MEAN | PERIod | PHAse | PK2pk | CRMs | MINImum | MAXImum | RISe | FALL | PWIdth | NWIdth | NONE
$s->set_measurement_type($n,$type);
$s->set_measurement_type(measurement=>$n, type=>$type);
$s->set_measurement_type($type); (defaults to $n = 'IMMediate')
Set the measurement type, for measurement $n= 'IMMediate', 1..5
The type is one of: FREQuency | MEAN | PERIod | PHAse | PK2pk | CRMs | MINImum | MAXImum | RISe | FALL | PWIdth | NWIdth or NONE (only for $n=1..5).
$units = $s->get_measurement_units($n);
$units = $s->get_measurement_units(measurement=>$n);
Fetch the measurement units for measurement $n (IMMediate, 1..5) result: V, A, S, Hz, VA, AA, VV
If $n is missing or undefined, uses IMMediate.
$wfm = $s->get_measurement_source($n);
$wfm = $s->get_measurement_source(measurement=>$n);
Fetch the source waveform for measurements: CH1..CH4 or MATH for measurement $n = IMMediate, 1..5
If $n is undefined or missing, IMMediate is used.
$s->set_measurement_source($n,$wfm);
$s->set_measurement_source(measurement=>$n, measurement_source => $wfm);
Set the measurement source, CH1..CH4 or MATH for measurement $n = IMMediate, 1..5. If $n is undefined or missing uses IMMediate.
$val = $s->get_measurement_value($n);
$val = $s->get_measurement_value(measurement=>$n);
Fetch measurement value, measurement $n = IMMediate, 1..5 If $n is missing or undefined, use IMMediate.
$s->trigger();
Force a trigger, equivalent to pushing the "FORCE TRIGGE" button on front panel
$coupling = $s->get_trig_coupling();
returns $coupling = AC|DC|HFREJ|LFREJ|NOISEREJ
(only applies to 'EDGE' trigger)
$s->set_trig_coupling($coupling);
$s->set_trig_coupling(coupling=>$coupling);
Set trigger coupling, $coupling = AC|DC|HFRej|LFRej|NOISErej Only applies to EDGE trigger
$sl = $s->get_trig_slope();
Fetch the trigger slope, FALL or RISE only applies to EDGE trigger.
$s->set_trig_slope($sl);
$s->set_trig_slope(slope=>$sl);
Set the trigger slope: RISE|UP|POS|+ or FALL|DOWN|NEG|-
Only applies to EDGE trigger
$ch = $s->get_trig_source([$trigtype]);
$ch = $s->get_trig_source([type=>$trigtype]);
Fetch the trigger source, returns one of CH1..4, EXT, EXT5, LINE
(EXT5 is 'external source, attenuated by a factor of 5')
Trigger type is the "currently selected" trigger type, unless specified with the type parameter.
$s->set_trig_source($ch);
$s->set_trig_source(source=>$ch[, type=>$type]);
Set the trigger source to one of CH1..4, EXT, EXT5, LINE (or 'AC LINE') for the current trigger type, unless type=>$type is specified.
$f = $s->get_trig_frequency();
Fetch the trigger frequency in Hz. This function is not for use when in 'video' trigger type. If the frequcency is less than 10Hz, 1Hz is returned.
$hold = $s->get_trig_holdoff();
Fetch the trigger holdoff, in seconds
$s->set_trig_holdoff($time);
$s->set_trig_holdoff(holdoff=>$time);
Set the trigger holdoff. If $time is a number it is taken to be in seconds; text can be passed with the usual order-of-magnitude and unit suffixes.
holdoff can range from 500ns to 10s
$lev = $s->get_trig_level();
Fetch the trigger level, in volts
$s->set_trig_level($lev);
$s->set_trig_level(level => $lev);
Set the trigger level, in volts. The usual magnitude/suffix rules apply. This routine has no effect when the trigger ssource is set to 'AC LINE'
$mode = $s->get_trig_mode();
Fetch the trigger mode: AUTO or NORMAL
$s->set_trig_mode($mode);
$s->set_trig_mode(mode=>$mode);
Set the trigger mode: AUTO or NORMAL
$type = $s->get_trig_type();
Fetch the trigger type, returns EDGE or PULSE or VIDEO.
$s->set_trig_type($type);
$s->set_trig_type(type=>$type);
Set trigger type to EDGE, PULse or VIDeo.
$wid = $s->get_trig_pulse_width();
Fetch trigger pulse width for PULSE trigger type
$s->set_trig_pulse_width($wid);
$s->set_trig_pulse_width(width=>$wid);
Set the pulse width for PULSE type triggers, in seconds. Valid range is from 33ns to 10s.
$pol = $s->get_trig_pulse_polarity();
Fetch the polarity for the PULSE type trigger, returns POSITIVE or NEGATIVE
$s->set_trig_pulse_polarity($pol);
$s->set_trig_pulse_polarity(pulse_polarity=>$pol);
Set the polarity for PULSE type trigger.
$pol can be (Postive|P|+) or (Negative|N|M|-)
$when = $s->get_trig_pulse_when();
Fetch the "when" condition for pulse triggering, possible values are
EQUAL: triggers on trailing edge of specified width)
NOTEQUAL: triggers on trailing edge of pulse shorter than specified width, or if pulse continues longer than specified width.
INSIDE: triggers on the trailing edge of pulses that are less than the specified width.
OUTSIDE: triggers when a pulse continues longer than the specified width
$s->set_trig_pulse_when($when);
$s->set_trig_pulse_when(pulse_when=>$when);
Set the PULSE type trigger to trigger on the specified condition, relative to the pulse width.
EQ|EQUAL|= : trigger on trailing edge of pulse equal to 'width'.
NOTE|NOTEQUAL|NE|!=|<>: trigger on trailing edge of pulse that is shorter than specified width, or when the pulse exceeds the specified width.
IN|INSIDE|LT|< : trigger on trailing edge when less than specified width
OUT|OUTSIDE|GT|> : trigger when pulse width exceeds specified width.
The pulse width for this trigger is set by set_trig_pulse_width();
$line = $s->get_trig_vid_line();
Get the video line number for triggering when SYNC is set to LINENUM.
$s->set_trig_vid_line($line);
$s->set_trig_vid_line(vid_line => $line);
Set the video line number for triggering with video trigger, when SYNC is set to LINENUM.
$pol = $s->get_trig_vid_polarity();
Fetch the video trigger polarity: NORMAL or INVERTED
$s->set_trig_vid_polarity($pol);
$s->set_trig_vid_polarity(vid_polarity=>$pol);
Set the video trigger polarity: NORMal|-SYNC or INVerted|+SYNC
$std = $s->get_trig_vid_standard();
Fetch the video standard used for video-type triggering; returns NTSC or PAL (PAL = PAL or SECAM).
$s->set_trig_vid_standard($std);
$s->set_trig_vid_standard(vid_standard=>$std);
Set the video standard used for video triggering. $std = NTSC, PAL, SECAM (SECAM selects PAL triggering).
$sync = $s->get_trig_vid_sync();
Fetcht the syncronization used for video trigger, possible values are FIELD, LINE, ODD, EVEN and LINENUM.
$s->set_trig_vid_sync($sync);
$s->set_trig_vid_sync(vid_sync => $sync);
Set the synchronization used for video triggering; possible values are FIELD, LINE, ODD, EVEN, and LINENum.
$state = $s->get_trig_state();
Fetch the trigger state (warning: this is not a good way to determine if acquisition is completed). Possible values are:
ARMED: aquiring pretrigger information, triggers ignored
READY: ready to accept a trigger
TRIGGER: trigger has been accepted, scope is processing postrigger information.
AUTO: in auto mode, acquiring even without a trigger.
SAVE: acquisition stopped, or all channels off.
SCAN: scope is in scan mode
$nbytes = $s->get_data_width();
Fetch the number of bytes transferred per waveform sample, returns 1 or 2.
Note that only the MSB is used, unless the waveform is averaged or a MATH waveform.
$s->set_data_width($nbytes);
$s->set_data_width(nbytes=>$nbytes);
Set the number of bytes per waveform sample, either 1 or 2.
Note that only the MSB is used for waveforms that are not the result of averaging or MATH operations.
$enc = $s->get_data_encoding();
Fetch the encoding that is used to transfer waveform data from the scope.
returns one of
ASCII: numbers returned as ascii signed integers, comma separated
RIBINARY: signed integer binary, MSB transferred first (if width=2)
RPBINARY: unsigned integer binary, MSB first
SRIBINARY: signed integer binary, LSB first
SRPBINARY: unsigned integer binary, LSB first
RIBINARY is the fastest transfer mode, particularly with width=1, as is used for simple waveform traces, with values ranging from -128..127 with 0 corresponding to the center of the screen.
(width = 2 data range -32768 .. 32767 with center = 0)
For unsigned data, width=1, range is 0..255 with 127 at center, width=2 range is 0..65535.
In all cases the "lower limit" is one division below the bottom of the screen, and the "upper limit" is one division above the top of the screen.
$s->set_data_encoding($enc);
$s->set_data_encoding(encoding=>$enc);
Set the waveform transfer encoding, see get_waveform_encoding for possible values and their meanings.
$i = $s->get_data_start();
Fetch the index of the first waveform sample for transfers $i = 1..2500
$s->set_data_start($i);
$s->set_data_start(start=>$i);
Set the index of the first waveform sample for transfers, $i = 1..2500.
$i = $s->get_data_stop();
Fetch the index of the last waveform sample for transfers $i = 1..2500
$s->set_data_stop($i);
$s->set_data_stop(stop=>$i);
Set the index of the lat waveform sample for transfers, $i = 1..2500.
$dst = $s->get_data_destination();
Fetch the destination (REFA..REFD) for data transfered TO the scope.
$s->set_data_destination($dst);
$s->set_data_destination(destination=>$dst);
Set the destination ($dst = REFA..REFD) for waveforms transferred to the scope.
$s->set_data_init();
initialize all data parameters (source, destination, encoding, etc) to factory defaults
$src = $s->get_data_source();
Fetch the source of waveforms transferred FROM the scope.
Possible values are CH1..CH4, MATH, or REFA..REFD.
$s->set_data_source($src);
$s->set_data_source(source => $src);
Set the source of waveforms transferred from the scope. Possible values are CH1..CH4, MATH, or REFA..REFD.
$h = $s->get_data();
return a hash reference with data transfer information such as width, encoding, source, etc, suitable for use with the set_data($h) routine
$s->set_data(width=>$w, start=>$istart, ... );
set data transfer characteristics, call with a hash or hashref similar to what one gets from get_data()
$hashref = $s->get_waveform();
$hashref = $s->get_waveform( waveform=>$wfm, start=>$startbin, stop=>$stopbin, ...data parameters...);
Fetch waveform from specified channel; if parameters are not set, use the current setup from the scope (see get_data_source) The value of $wfm can be CH1..4, MATH, or REFA..D.
returns $hashref = { v=>[voltages], t=>[times], various x,y parameters };
Note that voltages and times are indexed starting at '1', or at the 'data_start' index (see set_data_start()) $hashref->{v}->[1] ...first voltage sample, default
Alternately: $s->set_data_start(33); ... $hashref->{v}->[33] ... first voltage sample The hashref contains keys DAT:STAR and DAT:STOP for start and stop sample numbers.
If you are going to alter the data in $hashref->{v}->[], make sure to delete($hashref->{rawdata}) before the waveform is transmitted to the scope, this will case the rawdata to be regenerated from the $hashref->{v}->[] entries.
$hwfd = $s->create_waveform();
$hwfd = $s->create_waveform($t0,$t1[,$n[,\&vfunc]]);
$hwfd = $s->create_waveform(tstart=>$t0, tstop=>$t1[, nbins=$n][, vfunc=\&vfunc]);
returns a hashref with an array of time values (useful for creating a waveform) starting at $t0 and ending at $t1 with $n bins. Please note that the TDS2024B can use $n=2500 at most, although this routine will work for larger values of $n. If $n is not specified $n=2500 for a simple waveform, and $n=1250 for an 'envelope' waveform.
$t0 and $t1 can be numbers, in seconds, or text with suffixes: $t1='33ms'
The bin numbers start with '1', matching the scope behavior: $hwfd->{t}->[1] = $t0 ... $hwfd->{t}->[$n] = $t1
If a "vfunc" is given, it is called with the time values:
$v = vfunc($t); # $t in seconds
If vfunc returns an array of two voltages, it is taken as "min,max" values for an 'ENVELOPE' style waveform:
($vmin,$vmax) = vfunc($t);
In either case, the result is analyzed to produce a 'rawdata' entry with 8 bit waveform data, filling in the parameters needed for transmitting the waveform to the scope.
If you do not provide a reference to a "vfunc" function, you will have to create and fill in an array: $hwfd->{v}->[$n] = voltage($n) If you do not specify the $t0 and $t1 times, then you will also have to create and fill in the $hwfd->{t}->[$n] = time($n) array.
To make use of an "envelope" waveform, fill in $hwfd->{vmin}->[$n] and $hwfd->{vmax}->[$n].
$s->put_waveform($hwfm);
$s->put_waveform(waveform=>$hwfm, [destination=>$dst, position=>$ypos, scale=>$yscale] )
Store waveform to one of the REFA..REFD traces. If not set explicitly in the call arguments, uses the location set in the scope (see get_data_destination).
The vertical position of the trace is set with $ypos = divisions from the screen center, and the vertical scale with $yscale = V/div.
If $hwfm->{rawdata} exists, it will be transmitted to the scope unchanged. Otherwise the $hwfm->{rawdata} entry will be regenerated from the $hwfm->{v}->[] (or $hwfm->{vmin|vmax}->[]) array(s).
The error/consistency checking is certainly not complete, so doing something 'tricky' with the $hwfm hash may give unexpected results.
$s->print_waveform($hwfm [,$IOhandle]);
$s->print_waveform(waveform=>$hwfm [,output=>$iohandle]);
print information from the waveform stored in a hasref $hwfm, taken from get_waveform();
This is mostly for diagnostic purposes.
This software is copyright (c) 2018 by the Lab::Measurement team; in detail:
Copyright 2016 Charles Lane 2017 Andreas K. Huettel
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Lab::Measurement, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lab::Measurement
CPAN shell
perl -MCPAN -e shell install Lab::Measurement
For more information on module installation, please visit the detailed CPAN module installation guide.