Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
回复
 
主题工具 显示模式
旧 2019-12-10, 20:41   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 使用MATLAB将GPIB连接到外部设备

没有仪器控制工具箱,是否可以使用MATLAB建立GPIB连接? (我没有)。 MATLAB还提供了一种方法来了解外部设备的RS232参数值(波特率,停止位等)。对于RS232连接,我具有以下代码:

% This function is meant to send commands to Potentiostat Model 263A. % A run includes turning the cell on, reading current for time t1, turning % the cell off, waiting for time t2. % t1 is the duration [secs] for which the Potentiostat must run (cell is on) % t2 is the duration [secs] to on after off % n is the number of runs % port is the serial port name such as COM1 function [s] = Potentiostat_control(t1,t2,n) port = input('type port name such as COM1', 's') s = serial(port); set(s,'BaudRate', 9600, 'DataBits', 8, 'Parity', 'even', 'StopBits', 2 ,'Terminator', 'CR/LF'); fopen(s) %fprintf(s,'RS232?') disp(['Total runs requested = ' num2str(n)]) disp('i denotes number of runs executed so far..'); for i=1:n i %data1 = query(s, '*IDN?') fprintf(s,'%s','CELL 1'); % sends the command 'CELL 1' %fprintf(s,'%s','READI'); pause(t1); fprintf(s,'%s','CELL 0'); %fprintf(s,'%s','CLEAR'); pause(t2); end fclose(s)

回答:

对于您的GPIB问题,GPIB卡是否带有可调用的库(如果您在Windows上,则为DLL)? Matlab有一个用于调用外部库的接口。基本程序是具有使用Matlab的解析头文件LOADLIBRARY ,然后查看使用可用功能LIBFUNCTIONS和使用呼叫功能CALLLIB 。

对于您的RS232问题,我认为在没有外部文档的情况下,主机端无法通过任何方式了解设备端的参数。



更多&回答...
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 01:22


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.