use of Spectrum Analyzer

7 次查看(过去 30 天)
https://it.mathworks.com/help/dsp/ug/high-resolution-spectral-analysis-in-simulink.html# this example shown an application for analyzing the spectra.
I am trying to use it in direct contact with the oscilloscope, but the readout does not give results.
Is there any expert that can support me in connecting the spectrum analyzer and the oscilloscope.

采纳的回答

Shivam Gothi
Shivam Gothi 2024-9-17
Hello @SCIUSCIA,
Based on my understanding, you are looking to transfer data from an oscilloscope to a spectrum analyzer model in MATLAB. There are two possible approaches to achieve this:
Approach 1 : By creating an “oscilloscope” object:
You can create an “oscilloscope” object which will receive data from the oscilloscope and save it in the base workspace. As a next step, you can export the data from the base workspace to your Simulink model and run the spectrum analyzer model. The procedure is shown below:
Description :
MATLAB provides “Quick-control oscilloscope” to interface with any oscilloscope that uses an underlying IVI-C driver. However, you do not have to directly deal with the underlying driver. You can also use it for Tektronix® oscilloscopes. This oscilloscope object is an easy-to-use interface. Refer to the below documentation to know about the system requirements to use “Quick-control oscilloscopes”: https://www.mathworks.com/help/instrument/quick-control-oscilloscope-requirements.html
Example code:
%Create an instance of the scope called myScope.
myScope = oscilloscope()
%Discover available resources. A resource string is an identifier to the instrument. You need to set it before connecting to the instrument.
availableResources = resources(myScope)
%If multiple resources are available, use your VISA utility to verify the correct resource and set it.
myScope.Resource = 'TCPIP0::a-m6104a-004598::inst0::INSTR';
%Connect to the scope.
connect(myScope);
%Automatically configure the scope based on the input signal.
autoSetup(myScope);
%Configure the oscilloscope.
% Set the acquisition time to 0.01 second.
myScope.AcquisitionTime = 0.01;
% Set the acquisition to collect 2000 data points.
myScope.WaveformLength = 2000;
% Set the trigger mode to normal.
myScope.TriggerMode = 'normal';
% Set the trigger level to 0.1 volt.
myScope.TriggerLevel = 0.1;
% Enable channel 1.
enableChannel(myScope,'Channel1');
% Set the vertical coupling to AC.
configureChannel(myScope,'Channel1','VerticalCoupling','AC');
% Set the vertical range to 5.0.
configureChannel(myScope,'Channel1','VerticalRange',5.0);
%%%%%% Communicate with the instrument. For example, read a waveform %%%%.
% Acquire the waveform.
waveformArray = readWaveform(myScope);
%Define time Array. Oscilloscope returns data points at fixed time steps
t=linspace(0,myScope.AcquisitionTime,myScope.WaveformLength)
% Plot the waveform and assign labels for the plot.
plot(waveformArray);
xlabel('Samples');
ylabel('Voltage');
Open Simulink model:
After executing the above code successfully, open you Simulink model and replace the block “Three tone sine Wave” with “input” block as shown below.
Now go to Model Configuration Parameters (Ctrl + E) > Data Import/Export and check "Input", setting it as shown below:
Run the simulation.
Approach 2: Use “Instrumentation Control Toolbox.
Please refer to the link below to learn how to connect an oscilloscope with Simulink. This resource includes video tutorials that guide you through the process
I hope this helps.

更多回答(0 个)

产品


版本

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by