How to communicate/connect to SMC100CC controller (Newport Instr) using Matlab?
조회 수: 19 (최근 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
참고 항목
카테고리
Help Center 및 File Exchange에서 Instrument Control Toolbox Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!