Main Content

dsp.LogicAnalyzer

Visualize, measure, and analyze transitions and states over time

Description

The Logic Analyzer System object™ displays the transitions in time-domain signals. Using dsp.LogicAnalyzer, you can:

  • Debug and analyze models

  • Trace and correlate 96 signals simultaneously

  • Detect and analyze timing violations

  • Trace system execution

  • Detect signal changes using triggers

To display the transitions of signals in the Logic Analyzer:

  1. Create the dsp.LogicAnalyzer object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

For more information about how to configure and customize the Logic Analyzer, see Logic Analyzer.

Creation

Description

scope = dsp.LogicAnalyzer creates a Logic Analyzer System object, scope.

scope = dsp.LogicAnalyzer(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in single quotes. For example, scope = dsp.LogicAnalyzer('BackgroundColor','White','NumInputPorts',4).

example

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Background color of the display, specified as one of these values:

  • 'Black' — Set the background color of the Logic Analyzer display to black (dark).

  • 'White' — Set the background color of the Logic Analyzer display to white (light).

  • 'Auto' — Match the background color of the Logic Analyzer display with the MATLAB® theme.

Tunable: Yes

Data Types: char | string

Color for channels in the display, specified as an RGB triplet.

An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7].

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Font size for channels in the display, in points, specified as a nonnegative integer.

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Format for channels in the display, specified as one of the following:

  • 'Automatic' — Displays floating-point signals in Analog format and integer and fixed-point signals in Digital format. Boolean signals are displayed as zero or one.

  • 'Analog' — Shows values as an analog plot.

  • 'Digital' — Shows values as digital transitions.

Tunable: Yes

Data Types: char | string

Channel height in the display, in pixels, specified as a positive real scalar in the range [8, 200].

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

This property applies only to fixed-point (fi) values.

Tunable: Yes

Data Types: char | string

Spacing between channels in the display, in pixels, specified as a positive scalar integer.

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Caption to display on the scope window, specified as a character vector or string.

Tunable: Yes

Data Types: char | string

Number of input ports, specified as a positive integer. Each signal coming through a separate input becomes a separate channel in the scope. You must invoke the scope with the same number of inputs as the value of this property.

Position of the scope window on your screen, in pixels, specified as a [left bottom width height] vector. The default position 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.

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Sample time of inputs in seconds, specified as a finite numeric scalar. The same sample time is used for all inputs.

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Time display offset in seconds, specified as a nonnegative scalar.

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Time span in seconds, specified as a positive scalar. The x-axis limits are calculated as follows:

  • Minimum x-axis limit = min(TimeDisplayOffset)

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

TimeDisplayOffset and TimeSpan are the values of their respective properties.

Tunable: Yes

Data Types: double | single | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64

Usage

Description

scope(signal) displays the signal signal in the Logic Analyzer scope.

scope(signal1,signal2,...signalN) displays multiple signals in the Logic Analyzer when you set the NumInputPorts property to N. Each signal can have different data types and dimensions.

example

Input Arguments

expand all

Specify one or more input signals to visualize in the dsp.LogicAnalyzer. Signals can have different data types and dimensions.

Integers are supported up to 64 bits and fixed-point signals are supported up to 128 bits.

Example: scope(signal1,signal2)

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical | struct | table | cell

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

addCursorAdd cursor to Logic Analyzer
addDividerAdd divider to Logic Analyzer
addWaveAdd wave to Logic Analyzer
deleteCursorDelete Logic Analyzer cursor
deleteDisplayChannelDelete Logic Analyzer channel
getCursorInfoReturn settings for Logic Analyzer cursor
getCursorTagsReturn all Logic Analyzer cursor tags
getDisplayChannelInfoReturn settings for Logic Analyzer display channel
getDisplayChannelTagsReturn all Logic Analyzer display channel tags
modifyCursorModify properties of Logic Analyzer cursor
modifyDisplayChannelModify properties of Logic Analyzer display channel
moveDisplayChannelMove position of Logic Analyzer display channel
showDisplay scope window
hideHide scope window
isVisibleDetermine visibility of scope
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a dsp.LogicAnalyzer object. Call the scope in a loop to display the signals.

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

Create a dsp.LogicAnalyzer object with four channels. Call modifyDisplayChannel to set the radix of each of the channels. Run the scope in a loop to display the waves.

scope = dsp.LogicAnalyzer('NumInputPorts',4,'DisplayChannelFormat','Digital');
scope.TimeSpan = 12;

modifyDisplayChannel(scope,1,'Name','Index','Radix','Unsigned decimal'); 
modifyDisplayChannel(scope,2,'Name','Fi_hex','Radix','Hexadecimal'); 
modifyDisplayChannel(scope,3,'Name','Fi_bin','Radix','Binary'); 
modifyDisplayChannel(scope,4,'Name','Fi_actual','Radix','Signed decimal'); 

for ii = 1:20 
    fival = fi((ii-1)/16,0,4,4); 
    scope(ii,fival,fival,fival); 
end

Define a WeekDaysInt class to hold an enumerated list of weekday values. Create and save the following class definition file.

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

Create a dsp.LogicAnalyzer object and configure the vector, complex, and enumerated data signals.

scope = dsp.LogicAnalyzer('NumInputPorts',6);
waves = getDisplayChannelTags(scope);

modifyDisplayChannel(scope,waves{1},'InputChannel',1,'Name','Vector Digital');
modifyDisplayChannel(scope,waves{2},'InputChannel',2,'Name','Vector Analog',...
    'Format','Analog','Height',80);
modifyDisplayChannel(scope,waves{3},'InputChannel',3,'Name','Complex Digital');
modifyDisplayChannel(scope,waves{4},'InputChannel',4,'Name','Complex Analog',...
    'Format','Analog','Height',80,'Color','Green');
modifyDisplayChannel(scope,waves{5},'InputChannel',5,'Name','Enum Digital');
modifyDisplayChannel(scope,waves{6},'InputChannel',6,'Name','Enum Analog',...
    'Format','Analog','Height',80);

Call the scope object in a loop to display the signals.

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

    % Create a weekday enumerated value by wrapping the index
    day = WeekDaysInt(1+mod(count-1,5));

    scope(...
          [count (count-(stop/2))],...              % digital vector
          [sinValVec cosValVec cosValVecOffset],... % analog vector
          complex((count-(stop/2)),count),...       % digital complex
          complex(sinValReal, cosValImag),...       % analog complex
          day,...                                   % digital enum
          day...                                    % analog enum
          )
end

Tips

To close the logic analyzer window and clear its associated data, use the MATLAB clear function.

Version History

Introduced in R2013a