I've inherited some MATLAB code used to program an XYZ stage through a GPIB connection. To make it more compatible with some existing code in Python, I need to somehow translate it, e.g. using the PyVISA package. I would really like some help with that!
So, what I got working so far is just the basic stuff, i.e.
from visa import *
stage = instrument("GPIB::2")
From this I can use the identification command and correctly get the ID of my device:
stage.write("*IDN?")
So, any idea how to convert the following MATLAB into the appropriate PyVISA commands? My biggest issue is I don't really know how to translate the syntax...
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