How to communicate/connect to SMC100CC controller (Newport Instr) using Matlab?
15 次查看(过去 30 天)
显示 更早的评论
I have SMC100CC controller from Newport. They have supplied drivers for National Instruments also but it doesn't get recognized in NI MAX. I presumed that if its gets recognized in NI MAX I could communicate using MATLAB since I have to use with MATLAB for my research. Communication path is as follows: Computer to USB-RS232 adapter to RS232 cable to SMC100CC controller. Thanks in advance.
0 个评论
回答(6 个)
Mr.NonSeq
2019-1-11
Hello There,
It has been almost 4 years passed until the question posted, however I believe someone will share the latest .m file for communication with SMC100.
Thanks in Advance.
0 个评论
Liz Dreyer
2014-7-24
Did you ever resolve this issue? I am now trying to solve it myself. Thanks!
3 个评论
Liz Dreyer
2014-7-30
Hi Jay, I resolved it too. I am communicating directly with the SMC100 by ascii commands. I initialize the SMC100 using their application before I run my experiment. Once everything is green, I run my experiment and use my matlab function to control the SMC. I send it commands like "1PA0" as seen in the user manual.
Liz Dreyer
2014-7-30
The code is not finalized but here is what I am working with. I call this function in my main program. This is still a draft.
For example, I 'zero' the rotation mount it controls:
smcRotationCurrentPos = mes_Smc_func(num2str(smcRotationAdd),strcat(num2str(smcRotationAdd),'TP?'),1);
smcRotationDiff = abs(smcRotationCurrentPos-smcRotationZer);
smcRotationTime = mes_Smc_func(num2str(smcRotationAdd),strcat(num2str(smcRotationAdd),'PT',num2str(smcRotationDiff)),1);
mes_Smc_func(num2str(smcRotationAdd),strcat(num2str(smcRotationAdd),'PA',num2str(smcRotationZer)),0);
pause(smcRotationTime);
Salaheddin Hosseinzadeh
2014-7-30
编辑:Salaheddin Hosseinzadeh
2014-7-30
xHi Jay!
One things that I don't understand is that your device has a serial port (RS-232)? or USB?
As I understood your device is connected to PC via a serial to USB connecter? Is it so?!
If yes then you don't need to do anything but creating a serial object
serial('COMx') % check device manager to see what com port you have to use
If not, then please explain more!
You can attach the M file here so that we all can see it. tnx
Salaheddin Hosseinzadeh
2014-7-30
编辑:Salaheddin Hosseinzadeh
2014-7-30
Hi Jay,
I see your code, good! I don't understand the problem?! What is the problem then if you created the serial object and you can sent commands to it. Can you at least reset the device?! Which means you can successfully send the commands?! Or non of your commands are recognized?!
Regards
Salaheddin Hosseinzadeh
2014-7-30
Hi Jay,
Oh yeah darling, I've a cure for your problem! You want to send a series of command, without running a program, not typing and waiting for the device. You can't do anything with the response time of the device. So we have to wait and we do it by creating a mediator, lets call it myfunction.
1- you have to make another function that sends your commands to the device. This is something I did for an Waveform Generator, so instead of using
fprintf(obj,'command');
you will use
myfunction(obj,'command');
2- you have to create a myfunction to get 2 arguments, obj, which is your serial object, and a string which includes commands.
3- what happens in the myfunction is very simple, it has a fprintf(obj,'command') plus a pause(.6) seconds or any amout of pause u like. so
function myfunction(obj,command)
fprintf(obj,command);
pause(.6);
end
4- Assuming that your device responds you when you send query commands, usually has '?' at the end of command then you can make myfunction a bit more sophisticated to scan the device automatically.
function response = myfunction(obj,command)
fprintf(obj,command);
pause(.6);
if regexp(command,'?')
response = fscanf(obj);
else
response = [];
end
end
5- you have to create the serial object 'obj' in your main program.
function mainprogram
% here is the main body of your function
% create the serial obj here ans pass it to the myfunction
obj = serial('COM4');
respond = myfunction (obj,'*RST'); % IEEE command to reset the devices, may not work for yours
respond = myfunction (obj,'IDN?'); % get device ID, this time response is not empty
....
% before you terminate the mainfunction you close and delete the serial obj close(obj); delete(obj);
end % end of the main
So in your main you have to replace fprintf with response = myfunction it will only take a minute if you use CTRL+F
lol!
Hope that helps ;)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!