RIGOL编程使用

RIGOL示波器可由多种语言编程进行操作。

这里仅仅给出RIGOL编程手册给出的MATLAB的例程,以及自己写的程序。并提供读取的波形数据的工作区(1000Hz,5V有效值),可在无示波器下进行测试。

RIGOL MATLAB 例程

编程手册例程

源代码
%  clear;
% 创建 VISA 对象。'ni'为销售商参数,可以为 agilent、NI 或 tek,
% 'USB0::0x1AB1::0x04B0::DS2A0000000000::INSTR'为设备的资源描述符。创建后需设置设备的属性,
% 本例中设置输入缓存的长度为 2048
% MSO2000A = visa( 'ni','USB0::0x1AB1::0x04B0::DS2A0000000000::INSTR' );
MSO2000A = visa( 'ni','USB0::0x1AB1::0x04B0::DS2F210800048::INSTR' );
MSO2000A.InputBufferSize = 2048;
N = MSO2000A.InputBufferSize;
%打开已创建的 VISA 对象
fopen(MSO2000A);
%读取波形
fprintf(MSO2000A, ':wav:data?' );
%请求数据
[data,len]= fread(MSO2000A,N);% ------------------自加部分------------------% 获取周期
fprintf(MSO2000A,':MEASure:PERiod? <CHANnel1>');
T = fscanf(MSO2000A);
T = str2num(T);
F = 1/T             % 计算频率% 获取采样频率
fprintf(MSO2000A,':ACQuire:SRATe?');
Fs = fscanf(MSO2000A);
Fs = str2num(Fs)
% 计算采样总时间
Tmax = N/Fs% ------------------自加部分------------------%关闭设备
fclose(MSO2000A);
delete(MSO2000A);
clear MSO2000A;
% 数据处理。读取的波形数据含有 TMC 头,长度为 11 个字节,其中前 2 个字节分别为 TMC 头标志符
% #和宽度描述符 9,接着的 9 个字节为数据长度,然后是波形数据,最后一个字节为结束符 0x0A。所
% 以,读取的有效波形数据点为 12 到倒数第 2 个点。
wave = data(12:len-1);
wave = wave';
subplot(211);
plot(wave);
运行结果

主要的语句命令格式及使用方法都在这个例程里了。详细的描述见编程手册。

资源在这,免费下载:https://download.csdn.net/download/qq_41683065/12100339

自写带GUI界面的MATLAB程序

源代码
% GUI里不能带clear,会清空GUI的工作变量
% 我的一个猜想,采样点数为2048是固定的,但采样得到的波形不一样,即所测信号的频率不一样。
function varargout = gaopinGUI(varargin)
% GAOPINGUI MATLAB code for gaopinGUI.fig
%      GAOPINGUI, by itself, creates a new GAOPINGUI or raises the existing
%      singleton*.
%
%      H = GAOPINGUI returns the handle to a new GAOPINGUI or the handle to
%      the existing singleton*.
%
%      GAOPINGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GAOPINGUI.M with the given input arguments.
%
%      GAOPINGUI('Property','Value',...) creates a new GAOPINGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before gaopinGUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to gaopinGUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help gaopinGUI% Last Modified by GUIDE v2.5 10-Jan-2020 11:15:03% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @gaopinGUI_OpeningFcn, ...'gui_OutputFcn',  @gaopinGUI_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before gaopinGUI is made visible.
function gaopinGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to gaopinGUI (see VARARGIN)% Choose default command line output for gaopinGUI
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes gaopinGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = gaopinGUI_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% ------------------------------示波器操作---------------------------------
MSO2000A = visa( 'ni','USB0::0x1AB1::0x04B0::DS2F210800048::INSTR' );
MSO2000A.InputBufferSize = 2048;
N = MSO2000A.InputBufferSize;
%打开已创建的 VISA 对象
fopen(MSO2000A);
%读取波形
fprintf(MSO2000A, ':wav:data?' );
%请求数据
[data,len]= fread(MSO2000A,N);% 获取周期
fprintf(MSO2000A,':MEASure:PERiod? <CHANnel1>');
T = fscanf(MSO2000A);
T = str2num(T);
Fread = 1/T             % 计算频率
str5 = num2str(Fread);
set(handles.Fread,'string',str5);% 获取采样频率
fprintf(MSO2000A,':ACQuire:SRATe?');
Fs = fscanf(MSO2000A);
Fs = str2num(Fs)
str6 = num2str(Fs);
set(handles.Fs,'string',str6);
% 计算采样总时间
Tmax = N/Fs
str4 = num2str(Tmax);
set(handles.Tmax,'string',str4);%关闭设备
fclose(MSO2000A);
delete(MSO2000A);
clear MSO2000A;
% 数据处理。读取的波形数据含有 TMC 头,长度为 11 个字节,其中前 2 个字节分别为 TMC 头标志符
% #和宽度描述符 9,接着的 9 个字节为数据长度,然后是波形数据,最后一个字节为结束符 0x0A。所
% 以,读取的有效波形数据点为 12 到倒数第 2 个点。
wave = data(12:len-1);
wave = wave';
% ------------------------------示波器操作---------------------------------% load('RFdata.mat');
% N = 2048;
F = 1:1:1025;% 获取输入量
IgnoredF=get(handles.IgnoredF, 'String');
IgnoredF=str2double(IgnoredF);
rage_rate=get(handles.rage_rate, 'String');
rage_rate=str2double(rage_rate);% 去均值化
ave = mean(wave);
wave = wave - ave;
plot(handles.wave, wave)    % 绘制波形图像% fft
fftSpec = fft(wave',2048);
fftRms = abs( fftSpec');
% 取一半
fftRms = fftRms(1:N/2+1);
fftRms(2:end-1) = 2*fftRms(2:end-1);
% 取log
fftLg = 20*log(fftRms);
% 绘图
plot(handles.fft1, F, fftLg)[fmax,~,fft_max,~] = Find_extremum_of_RowVector(fftLg', F);% plot them on a figure
plot(handles.fft2,F,fftLg);
hold(handles.fft2,'on')
plot(handles.fft2, fmax, fft_max, 'r+');
xlabel(handles.fft1,'f/Hz'),ylabel(handles.fft1, 'V/mv')
set(handles.fft2,'YLim',[0 250])[fmax,~,fft_max,~] = Find_extremum_of_RowVector(fftLg(:,IgnoredF:end-1)', F(:,IgnoredF:end-1));% 查找最大的谐波数
f1_pred=peak(fft_max,fmax,rage_rate,1);
f2_pred=peak(fft_max,fmax,rage_rate,2);str2 = ['测得信号的最大的频率分量为: ',num2str(f1_pred),' Hz'];
str3 = ['测得信号的次大的频率分量为: ',num2str(f2_pred),' Hz'];
set(handles.string2,'string',str2);
set(handles.string3,'string',str3);function string1_Callback(hObject, eventdata, handles)
% hObject    handle to string1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of string1 as text
%        str2double(get(hObject,'String')) returns contents of string1 as a double% --- Executes during object creation, after setting all properties.
function string1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to string1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction string2_Callback(hObject, eventdata, handles)
% hObject    handle to string2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of string2 as text
%        str2double(get(hObject,'String')) returns contents of string2 as a double% --- Executes during object creation, after setting all properties.
function string2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to string2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction string3_Callback(hObject, eventdata, handles)
% hObject    handle to string3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of string3 as text
%        str2double(get(hObject,'String')) returns contents of string3 as a double% --- Executes during object creation, after setting all properties.
function string3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to string3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction IgnoredF_Callback(hObject, eventdata, handles)
% hObject    handle to IgnoredF (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of IgnoredF as text
%        str2double(get(hObject,'String')) returns contents of IgnoredF as a double% --- Executes during object creation, after setting all properties.
function IgnoredF_CreateFcn(hObject, eventdata, handles)
% hObject    handle to IgnoredF (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction rage_rate_Callback(hObject, eventdata, handles)
% hObject    handle to rage_rate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of rage_rate as text
%        str2double(get(hObject,'String')) returns contents of rage_rate as a double% --- Executes during object creation, after setting all properties.
function rage_rate_CreateFcn(hObject, eventdata, handles)
% hObject    handle to rage_rate (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction Tmax_Callback(hObject, eventdata, handles)
% hObject    handle to Tmax (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Tmax as text
%        str2double(get(hObject,'String')) returns contents of Tmax as a double% --- Executes during object creation, after setting all properties.
function Tmax_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Tmax (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction Fread_Callback(hObject, eventdata, handles)
% hObject    handle to Fread (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Fread as text
%        str2double(get(hObject,'String')) returns contents of Fread as a double% --- Executes during object creation, after setting all properties.
function Fread_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Fread (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
endfunction Fs_Callback(hObject, eventdata, handles)
% hObject    handle to Fs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Fs as text
%        str2double(get(hObject,'String')) returns contents of Fs as a double% --- Executes during object creation, after setting all properties.
function Fs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Fs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');
end
运行结果

仅仅有这个不能运行,还有相应的.fig文件才能运行。

这是自己写的,就不免费了嗷:https://download.csdn.net/download/qq_41683065/12100350

RIGOL示波器编程使用相关推荐

  1. RIGOL示波器使用

    普源精电RIGOL常见仪器问题汇总 1. DG系列产品有功率输出功能吗? 没有,配有PA1011后可实现10W功率输出. 2. 输出阻抗在高阻和50欧切换的时候,为什么输出没有变化? 这是由于信号源的 ...

  2. RIGOL示波器测试特殊功能

    https://www.bilibili.com/video/av58699415?p=2 使用RIGOL示波器的峰值观察偶发窄脉冲 峰值检测是数字示波器中的一种波形获取方式,也是数字示波器的重要技术 ...

  3. 普源示波器软件,Rigol示波器上位机软件NS-Scope介绍

       1.软件概述 ◆为了解决示波器测试操作流程繁琐.参数配置复杂等问题,Namisoft开发的NS-Scope示波器自动化测试程控软件,通过对示波器的程序控制,实现自动化参数配置.数据采集和数据存储 ...

  4. LabVIEW示波器编程

    CSDN话题挑战赛第2期 参赛话题:学习笔记 博客写作背景----项目中解决的问题 最近遇到一个使用stm32单片机多路采集信号的项目,还需要在上位机进行波形的查看,信号算法的处理,初步定为使用lab ...

  5. RIGOL示波器上位机程序DEMO v1.0

    本程序用Labview2016编写,用于直接连接普源示波器,读取实时波形,并生成示波图, 只做了读取,其它触发什么的还没有来得及做,有需求再做. https://download.csdn.net/d ...

  6. 北京普源示波器常见问题

    1.DG系列产品有功率输出功能吗? 没有,配有PA1011后可实现10W功率输出. 2. 输出阻抗在高阻和50欧切换的时候,为什么输出没有变化? 这是由于信号源的物理输出阻抗固定为50欧,输出阻抗的条 ...

  7. 【无标题】py控制泰克示波器,

    python 操作TK示波器(NI-VISA) NI-VISA这是一种美国的一家公司的协议,主要用来和仪器通信,当然这只是一种通信的格式,具体的操作我们还是要参照示波器的说明书. 我们直接采用Pyth ...

  8. PyVISA使用——用python控制TEK示波器源码实现

    项目要求 项目上提出自动化测试需求,要求能够对板级信号使用示波器等仪器做自动化测量 实现方案 使用PyVISA 方案实现. VISA (Virtual Instrument Software Arch ...

  9. 数字示波器CAN节点标定

    背景: CAN通信有错误帧,丢包,波特率不匹配等问题.通过STM32可以返回出填充错误,隐形位错误,应答错误等问题.但是面对错误无能为力.通过示波器又无法直观看出错误帧在哪里. 看了广东致远电子的 C ...

最新文章

  1. 部署yum仓库自动挂载服务
  2. dbnull和null_NULL和DBNull的区别分析
  3. Java Word break analysis
  4. DCGAN-深度卷积生成对抗网络-转置卷积
  5. 从零开始学Symbian (基于carbid.c++、S60第三版)
  6. 后台扫描工具 - 御剑(珍藏版)附下载
  7. windows火车刷票小白秘笈
  8. USB 协议整理 七:STM32F103之USB概述
  9. SQL:with ties
  10. Excel常用技巧—数字和文本转换,三种方法任你选!!
  11. 劳易测BCB G40 H47 L030 - 条码带
  12. 【工具使用】视频制作
  13. [LeetCode] 871. Minimum Number of Refueling Stops
  14. 吴恩达深度学习第一课--第二周神经网络基础作业下代码实现
  15. 缓存就是万金油,哪里有问题哪里抹一下 。那他的本质是什么呢?
  16. 七麦研究院首发AR产品数据报告,数读App Store上的AR世界
  17. html去图片平铺效果,css如何把图片平铺?
  18. 华为HCIE云计算培训笔记第4天
  19. 什么是RAID 0?什么是RAID 1?了解硬盘阵列的作用
  20. 【BZOJ4826】[Hnoi2017]影魔 单调栈+扫描线

热门文章

  1. 【Educoder作业】问题求解——while 循环
  2. 心率脉搏测试c语言算法,基于51单片机语音播报心率计脉搏测量仪设计(仿真源码+电路图+当时PaperPass16%查重论文)...
  3. 虚拟服务器端口211,双路由器要这样映射-路由器设置端口映射
  4. Android中AS创建点9图片与使用
  5. 手机号注册过,被遗忘的网站有哪些?
  6. Mac Scrcpy无线连接
  7. java class dex_class文件与dex文件分析
  8. 三维电影特效动画制作软件——Houdini 17.5
  9. Spring的初始化和对象创建流程
  10. Mysql面试题,sql优化,存储引擎,数据结构,基础知识等