dsp.LogicAnalyzer System object

Package: dsp

Display transitions of signals over time

Description

The LogicAnalyzer object, hereafter referred to as the scope, displays the transitions in time-domain signals.

To display the transitions of signals in the Logic Analyzer:

  1. Define and set up your Logic Analyzer. See Construction.

  2. Call step to display the transitions of the signals in the Logic Analyzer figure. The behavior of step is specific to each object in the toolbox.

Use the MATLAB® clear function to close the Logic Analyzer figure window and clear its associated data. Use the hide method to hide the Logic Analyzer window and the show method to make it visible.

See the following sections for more information on the Logic Analyzer Graphical User Interface:

Construction

H = dsp.LogicAnalyzer creates a Logic Analyzer System object™, H. This object displays the transitions of signals.

H = dsp.LogicAnalyzer('Name',Value,...) creates a Logic Analyzer System object, H, with each specified property Name set to the specified value. You can specify NameValue arguments in any order.

Properties

BackgroundColor

Background color for display

Specify the background color of the display to be either 'Black' or 'White'.

This property is Tunable.

Default: 'Black'

DisplayChannelColor

Color for channels in the display

Specify the color for channels in the display to be one of the following options:

  • 'Black'

  • 'Blue'

  • 'Green'

  • 'Cyan'

  • 'Red'

  • 'Magenta'

  • 'White'

This property is Tunable.

Default: 'Cyan'

DisplayChannelFontSize

Font size for channels in the display

Specify as a scalar nonnegative integer the font size in points for values shown in the channels in the display.

This property is Tunable.

Default: 10

DisplayChannelFormat

Format for channels in the display

Specify as a string the wave format from one of the following options:

  • 'Analog' — Shows values as an analog plot

  • 'Digital' — Shows values as digital transitions

This property is Tunable.

Default: 'Digital'

DisplayChannelHeight

Height for channels in the display

Specify as a scalar integer the height of the channels in the display in units of 16 pixels.

This property is Tunable.

Default: 1

DisplayChannelRadix

Base of the enumeration used to display the values

Specify as a string the radix (i.e., base of the numeric system) from one of the following options:

  • 'Binary' — Displays values as 0s and 1s.

  • 'Hexadecimal' — Displays values as symbols from 0 to 9 and A to F

  • 'Octal' — Displays values as numbers from 0 to 7

    'Signed decimal' — Displays the signed, stored integer value

  • 'Unsigned decimal' — Displays the stored integer value

This property is applicable only to fixed-point (fi) values. This property is Tunable.

Default: 'Hexadecimal'

DisplayChannelSpacing

Spacing for channels in display

Specify as a positive scalar integer the spacing between channels in the display in units of 4 pixels.

This property is Tunable.

Default: 1

MaxNumTimeSteps

Maximum number of time steps

Specify as a finite numeric scalar the maximum number of samples for the input ports. The same maximum number of time steps is used for all inputs.

Default: 50000

Name

Caption to display on scope window

Specify as a string the caption to display on the scope window.

This property is Tunable.

Default: 'Logic Analyzer'

NumInputPorts

Number of input signals

Specify the number of input signals to the scope as a positive integer. You must invoke the step method with the same number of inputs as the value of this property.

Default: 1

Position

Scope window position in pixels

Specify, in pixels, the size and location of the scope window as a 4-element double vector of the form, [left bottom width height]. You can place the scope window in a specific position on your screen by modifying the values for this property.

This property is Tunable.

Default: The default depends on your screen resolution. By default, the scope window appears in the center of your screen with a width of 800 pixels and height of 600 pixels.

ReduceUpdates

Reduce updates to improve performance

When you set this property to true, the scope logs data for later use and updates the window periodically. When you set this property to false, the scope updates every time the step method is called. The simulation speed is faster when this property is set to true. This property is Tunable.

You can also modify this property from the scope figure. Opening the Playback menu and clearing the Reduce Updates to Improve Performance check box is the same as setting this property to false.

Default: true

SampleTime

Sample time of inputs

Specify as a finite numeric scalar the sampling time of the input ports, in seconds. The same sample time is used for all inputs.

Default: 1

TimeDisplayOffset

Time display offset

Specify the offset, in seconds, to apply to the x-axis (time-axis). This property can be either a numeric scalar or a vector of length equal to the number of input channels. If you specify this property as a scalar, then that value is the time display offset for all channels. If you specify a vector, each vector element is the time offset for the corresponding channel. For vectors with length less than the number of input channels, the scope sets the time display offsets for the remaining channels to 0. If a vector has a length greater than the number of input channels, the scope ignores extra vector elements. This property is Tunable.

See TimeSpan for information on the x-axis limits and time span settings.

Default: 0

TimeSpan

Specify the time span, in seconds, as a positive, numeric scalar value. The x-axis limits are calculated as follows.

Minimum x-axis limit = min(TimeDisplayOffset)
Maximum x-axis limit = max(TimeDisplayOffset) + TimeSpan

where TimeDisplayOffset and TimeSpan are the values of their respective properties.

This property is Tunable.

Default: 10

Methods

addCursorAdd cursor to display
addDividerAdd divider to display
addWaveAdd wave corresponding to specified input
cloneCreate scope object with same property values
deleteCursorDelete specified cursor
deleteDisplayChannelDelete specified display channel
getCursorInfoReturn settings for specified cursor
getCursorTagsReturn all cursor tags
getDisplayChannelInfoReturn settings for specified display channel
getDisplayChannelTagsReturn all display channel tags
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
hideHide scope window
isLockedLocked status for input attributes and nontunable properties
modifyCursorModify properties of specified cursor
modifyDisplayChannelModify properties of specified display channel
moveDisplayChannelMove position of specified display channel
releaseAllow property value and input characteristics changes
resetReset internal states of scope object
showMake scope window visible
stepDisplay signal in scope figure

Examples

The following examples illustrate how to use the Logic Analyzer object to view a variety of input signals in the time domain.

Example: Display Simple Ramp Signals

Construct a dsp.LogicAnalyzer object. Run the step method to display the signals.

hla1 = dsp.LogicAnalyzer('NumInputPorts', 3);
for ii = 1:20
    step(hla1, ii, 10*ii, 20*ii);
end

Run the release method to let property values and input characteristics change.

release(hla1);

Run the MATLAB clear function to close the scope window.

clear('hla1');

Example: Display Fixed-Point Signals

Construct a dsp.LogicAnalyzer object. Run the addWave method to add both floating-point and fixed-point wave channels. Run the step method to display the signals.

hla2 = dsp.LogicAnalyzer('NumInputPorts', 2); % 2 inputs
hla2.TimeSpan = 12;
addWave(hla2,'InputChannel',1,'Name','Index');
addWave(hla2,'InputChannel',2,'Name','Fi_hex','Radix','Hexadecimal');
addWave(hla2,'InputChannel',2,'Name','Fi_bin','Radix','Binary');
for ii = 1:20
    fival = fi(mod(ii-1, 16), 0, 4, 0);
    step(hla2, ii, fival);
end

Run therelease method to let property values and input characteristics change.

release(hla2);

Run the MATLAB clear function to close the scope window.

clear('hla2');

Example: Display Vectors, Complex and Enumerated Signals

First, define a WeekDaysInt object to hold an enumerated list of weekday values. Insert the following code into a text file and save it as WeekDaysInt.m

classdef WeekDaysInt < int32
   enumeration
      Monday(1), Tuesday(2), Wednesday(3), Thursday(4), Friday(5)
   end
end

Then, create and configure the vector, complex, and enumerated data signals. Construct a dsp.LogicAnalyzer object. Run the step method to display the signals.

s{1} = dsp.LogicAnalyzerWave('InputChannel',1,...
     'Name','Vector Digital');      
s{2} = dsp.LogicAnalyzerWave('InputChannel',2,...
     'Name','Vector Analog', 'Format','Analog',...
     'Height',5);  
s{3} = dsp.LogicAnalyzerWave('InputChannel',3,...
     'Name','Complex Digital');      
s{4} = dsp.LogicAnalyzerWave('InputChannel',4,...
     'Name','Complex Analog', 'Format','Analog',...
     'Height',5,'Color','Green'); 
s{5} = dsp.LogicAnalyzerWave('InputChannel',5,...
     'Name','Enum Digital');      
s{6} = dsp.LogicAnalyzerWave('InputChannel',6,...
     'Name','Enum Analog', 'Format','Analog',...
     'Height',5); 

hla3 = dsp.LogicAnalyzer('DisplayChannels',s,...
     'NumInputPorts',numel(s));

t=30;
for c = 1:t
    sinValVec = sin(c/t*2*pi);
    cosValVec = cos(c/t*2*pi);
    cosValVecOffset = cos((c+10)/t*2*pi);
    sinValReal = sin((c+2)/t*2*pi);
    cosValImag = cos((c+2)/t*2*pi);

    % Create a weekday enumerated value by wrapping the index
    day = WeekDaysInt(1+mod(c-1,5));
    
    step(hla3,...
        [c (c-(t/2))],...                         % digital vector
        [sinValVec cosValVec cosValVecOffset],... % analog vector
        complex((c-(t/2)),c),...                  % digital complex 
        complex(sinValReal, cosValImag),...       % analog complex
        day,...                                   % digital enum
        day...                                    % analog enum
        );
end

Run therelease method to let property values and input characteristics change.

release(hla2);

Run the MATLAB clear function to close the scope window.

clear('hla2');

Channel Display

Logic Analyzer uses the Time span and Time display offset properties to determine the time range. To change the channel display settings, modify these properties. For example, if you set the Time span to 25 seconds, the scope displays 25 seconds' worth of simulation data at a time. If you also set the Time display offset to 5 seconds, the scope displays values on the time-axis from 5 to 30 seconds.

To communicate the simulation time that corresponds to the current display, the scope uses the Simulation time indicators on the scope window. The following figure highlights these and other important aspects of the Logic Analyzer window.

Indicators

  • Display Channels — The scope displays on the y-axis a number of display channels. Each display channel may contain either a wave or a divider and is identified by a unique tag. The displayed values are the signal values for the sample period from one transition to another. To get the tags for an existing display channel, call the getDisplayChannelTags method. To get information about an existing display channel, call the getDisplayChannelInfo method. To modify the properties of an existing display channel, call the modifyDisplayChannel method. To move a display channel, call the moveDisplayChannel method. To delete a display channel, call the deleteDisplayChannel method.

    To select a display channel, click on its name. Use shift-click or control-click (command-click on the Mac OS X platform) to select or deselect multiple display channels. When one or more channels are selected, you can use the Edit menu or right-click and use the context menu to cut, copy, and paste channels. The right-click context menu also lets you add a wave or divider, and modify, move, or delete channels.

    • Wave — A wave is signal data in any format whose name and data are displayed on the y-axis. The display of a wave consists of its name, its value at the active cursor, and a visualization of its signal data over the time span. To add a new wave to the display, call the addWave method. Each wave uses default values for radix, format, and other wave properties. When one or more wave channels are selected, you can use Edit menu to cut, copy, and paste them. To change any of the properties, right-click on a wave name and select Modify or set the properties via the addWave method for that wave. You can also double-click on a channel name to open the Logic Analyzer — Modify display channel dialog box for that channel. If you choose a specific setting for a wave, that setting overrides the default setting.

    • Divider — The divider is a horizontal line that is intended to separate groups of signal data on the y-axis. To add a new divider to the display, call the addDivider method. When one or more divider channels are selected, you can use Edit menu to cut, copy, and paste them. To change any of the properties, right-click on a divider name and select Modify or set the properties via the addDivider method for that divider. You can also double-click on a divider name to open the Logic Analyzer — Modify display channel dialog box for that divider. If you choose a specific setting for a divider, that setting overrides the default setting.

  • Cursor — The scope displays on the time-axis a number of cursors. Cursors allow you to compare wave values at the same moment of time. To add a new cursor to the display channel, call the addCursor method. To modify the properties of an existing cursor, call the modifyCursor method. To delete a display channel, call the deleteCursor method or select the channel and use Edit > Cut.

    To move the cursor to the previous or next transition, select a display channel and use the Go to Previous Transition or Go to Next Transition toolbar button, respectively.

  • Simulation status — Provides the current status of the model simulation. The status can be either of the following conditions:

    • Processing — Occurs after you run the step method and before you run the release method.

    • Stopped — Occurs after you construct the scope object and before you first run the step method. This status also occurs after you run the release method.

    The Simulation status is part of the Status Bar in the scope window. You can choose to hide or display the entire Status Bar. From the scope menu, select View > Status Bar.

  • Simulation time — The amount of time that the Logic Analyzer has spent processing the input. Every time you call the step method, the simulation time increases by the number of rows in the input signal divided by the sample rate, as given by the following formula: . To set the sample rate, modify the SampleTime property.

    The Simulation time is part of the Status Bar in the scope window. You can choose to hide or display the entire Status Bar. From the scope menu, select View > Status Bar .

  • Minimum time-axis limit — The scope sets the minimum time-axis limit using the value of the Time display offset property.

  • Maximum time-axis limit — The scope sets the maximum time-axis limit by summing the value of Time display offset parameter with the value of the Time span parameter.

Toolbar

You can control whether the toolbar appears in the Logic Analyzer window. From the Logic Analyzer menu, select View > Toolbar. The Logic Analyzer toolbar contains the following buttons.

ButtonShortcut KeysDescription
n/aConfiguration Properties — Click this button to open the Visuals – Logic Analyzer Properties dialog.
n/aCursor — When this tool is active, you can place a cursor on the scope window. The cursor shows you the time and allows you to compare the values of the input signals at that time.
Left arrow, Right arrowPan — When this tool is active, you can pan on the scope window. To do so, click in the center of your area of interest, and drag your cursor to the left or right to move the position of the display. Alternatively, you can use the left and right arrows on your keyboard.
n/a

Zoom X — When this tool is active, you can zoom in on the time-axis. To do so, click inside the scope window, or click and drag your cursor along the time-axis over your area of interest.

+, iZoom In — Click this button to zoom in on the scope window. Use the Pan button to center the display on your area of interest before you zoom in.
, o, _Zoom Out — Click this button to zoom out on the scope window.
fAutoscale — Click this button to scale the x-axis in the active scope window.
n/aGo to Previous Transition — Click this button to move the cursor in the selected display channel to the previous transition.
n/aGo to Next Transition — Click this button to move the cursor in the selected display channel to the next transition.

Visuals — Logic Analyzer Properties

The Visuals — Logic Analyzer Properties dialog box controls the visual configuration default settings of the Logic Analyzer display. From the Logic Analyzer menu, select View > Configuration Properties to open this dialog box. Any changes you make using the Modify display channel or Modify display channels dialog box affect only the selected channels and these Visuals — Logic Analyzer Properties dialog box default settings do no apply.

Background Color

Specify the background color of the display to be either 'Black' or 'White'.

Radix

Specify as a string the radix (i.e., base of the numeric system) from one of the following options:

  • 'Binary' — Displays values as 0s and 1s.

  • 'Hexadecimal' — Displays values as symbols from 0 to 9 and A to F

  • 'Octal' — Displays values as numbers from 0 to 7

    'Signed decimal' — Displays the signed, stored integer value

  • 'Unsigned decimal' — Displays the stored integer value

Height

Specify as a scalar integer the height of the channels in the display in units of 16 pixels.

Color

Specify the color for channels in the display to be one of the following options:

  • 'Black'

  • 'Blue'

  • 'Green'

  • 'Cyan'

  • 'Red'

  • 'Magenta'

  • 'White'

Format

Specify as a string the wave format from one of the following options:

  • 'Analog' — Shows values as an analog plot

  • 'Digital' — Shows values as digital transitions

Font Size

Specify as a scalar nonnegative integer the font size in points for values shown in the channels in the display.

Spacing

Specify as a positive scalar integer the spacing between channels in the display in units of 4 pixels.

Logic Analyzer — Modify display channel

The Logic Analyzer — Modify display channel dialog box controls the visual configuration settings of the selected channel wave or divider. You open this dialog box for a specific wave or divider by double-clicking on the wave or divider name. You can also open this dialog box by selecting a channel wave or divider, right-clicking to open the context menu, and then, selecting Modify. To open the dialog box for more than one wave or divider, shift-click or control-click to select the desired waves and dividers and then, select Modify from the right-click context menu. Any changes you make using this dialog override the Visuals — Logic Analyzer Properties dialog box default settings.

If you select only one channel wave or divider, the dialog box shows these fields.

If you select more than one channel wave or divider, the dialog box shows only these fields.

If you select more than one channel wave or divider with different property values, No change is displayed for that property. Selecting a value applies that value to all selected channels.

Input Channel

Select the input data source for the channel. This field is displayed only if you selected a single channel or divider.

Name

Specify the name to display for the selected channel or divider. This field is displayed only if you selected a single channel or divider.

Radix

Select the radix (base of the numeric system) from one of the following options:

  • Default — Uses the default value specified in the Visuals — Logic Analyzer Properties dialog box.

  • Hexadecimal — Displays values as symbols from 0 to 9 and A to F

  • Octal — Displays values as numbers from 0 to 7

  • Binary — Displays values as 0s and 1s.

  • Signed decimal — Displays the signed, stored integer value

  • Unsigned decimal — Displays the stored integer value

Color

Select the color for channels in the display to be one of the following options:

  • Default — Uses the default color specified in the Visuals — Logic Analyzer Properties dialog box.

  • Black

  • Blue

  • Green

  • Cyan

  • Red

  • Magenta

  • Yellow

  • White

Height

Specify as a scalar integer the height of the selected channel in the display in units of 16 pixels. Setting the height to 0 uses the default value specified in the Visuals — Logic Analyzer Properties dialog box. If you have selected more than one channel, specify a scalar integer to apply the same height to all channels or a vector of integer heights to apply different heights to each selected channel.

Font Size

Specify as a scalar integer the font size of the selected channel in the display in units of 16 pixels. Setting the font size to 0 uses the default value specified in the Visuals — Logic Analyzer Properties dialog box. If you have selected more than one channel, specify a scalar integer to apply the same font size to all channels or a vector of font sizes to apply different font sizes to each selected channel.

Format

Select the wave format from one of the following options:

  • Default — Uses the default format specified in the Visuals — Logic Analyzer Properties dialog box.

  • Digital — Shows values as digital transitions

  • Analog — Shows values as an analog plot

Was this topic helpful?