Control Newport rotational stage PM500 with Instrument Control Box

2 次查看(过去 30 天)
Hello,
I am trying to control the Newport rotational stage PM500 with MatLab. The following is my program.
function t = PM500_Ang_Sec(theta)
% Create a GPIB object. theta is in arc-sec
obj = instrfind('Type', 'gpib', 'BoardIndex', 0, 'PrimaryAddress', 1, 'Tag', '');
% Create the GPIB object if it does not exist
% otherwise use the object that was found.
if isempty(obj)
obj = gpib('ni', 0, 1);
else
fclose(obj);
obj = obj(1)
end
% Connect to instrument object, obj.
fopen(obj);
angle = num2str(theta);
% Communicating with instrument object, obj.
fprintf(obj,'xy')
timedelay_ms(1000)
fprintf(obj,strcat('xg',angle))
fprintf(obj,'xr?')
timedelay_ms(500)
t1 = fscanf(obj);
t=str2num(t1(3:end));
% Disconnect from instrument object, obj.
fclose(obj);
% Clean up all objects.
delete(obj);
When I run this function (with theta = 1200, for example), I am always getting the stage to move about 10arc-sec away from the target value (1193). But when I re-run the function again, it gets to 1200. Can anyone tell me what I did wrong?
Many thanks!
Feng

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Instrument Connection and Communication 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by