我继承了一些用于通过GPIB连接编程XYZ stage的MATLAB代码。为了使它与Python中的一些现有代码更加兼容,我需要以某种方式对其进行翻译,例如使用PyVISA包。我真的需要一些帮助!在
所以,到目前为止,我所做的只是一些基本的东西,即
from visa import *
stage = instrument("GPIB::2")
由此,我可以使用identification命令并正确获取设备的ID:
^{pr2}$那么,你知道如何将下面的MATLAB转换成适当的PyVISA命令吗?我最大的问题是我真的不知道如何翻译语法。。。在
classdef cascade12000b < handle
properties(Constant)
GPIB_ADDRESS = 28;
DEVICE_TAG = 'Cascade 12000B Probe Station';
DEVICE_ID = 2;
end
properties
gpib_conn;
end
methods
function [obj] = cascade12000b()
obj.open();
end
function [x, y, z] = get_position(obj)
[r] = obj.exec_command(sprintf(':MOV:ABS? %d', cascade12000b.DEVICE_ID));
tmp = sscanf(r, '%d %d %d');
x = tmp(1);
y = tmp(2);
z = tmp(3);
end
function [] = move_absolute(obj, x, y)
[~, ~, z] = obj.get_position();
obj.exec_command(sprintf(':MOV:ABS %d %d %d %d', cascade12000b.DEVICE_ID, x, y, z));
end
function [] = move_relative(obj, dx, dy)
obj.exec_command(sprintf(':MOV:REL %d %d %d %d', cascade12000b.DEVICE_ID, dx, dy, 0));
end
像这样的东西会有用的
你会这样用的
^{pr2}$如果您必须编写多个设备驱动程序,您可能需要查看一些python包,如slave(注意:我是slave的作者)或{a2}。
相关问题 更多 >
编程相关推荐