How to communicate/connect to SMC100CC controller (Newport Instr) using Matlab?

21 views (last 30 days)
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.

Answers (6)

Mr.NonSeq
Mr.NonSeq on 11 Jan 2019
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.

Jay
Jay on 30 Jul 2014
Edited: Jay on 30 Jul 2014
The problem has been resolved. I have attached a '.m' file which contains my initial testing of the controller using MATLAB. I have used usb-serial adapter for communication purposes. Please feel free to send me an email if you have further queries. Bests. Jay

Liz Dreyer
Liz Dreyer on 24 Jul 2014
Did you ever resolve this issue? I am now trying to solve it myself. Thanks!
  3 Comments
Liz Dreyer
Liz Dreyer on 30 Jul 2014
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
Liz Dreyer on 30 Jul 2014
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);

Sign in to comment.


Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 30 Jul 2014
Edited: Salaheddin Hosseinzadeh on 30 Jul 2014
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
  1 Comment
Jay
Jay on 30 Jul 2014
Hi, since the communication port to smc100cc is serial its necessary to create an serial object. Also I was told there are others ways to communicate with this instrument without creating serial object. I have attached the '.m' file in my previous answer please check. Bests. Jay

Sign in to comment.


Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 30 Jul 2014
Edited: Salaheddin Hosseinzadeh on 30 Jul 2014
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
  1 Comment
Jay
Jay on 30 Jul 2014
Sorry, for not stating earlier. The problem has been resolved. Presently I am not able to send a series of commands as can be seen from the '.m' file. The instrument requires about 0.7-0.8 seconds delay for execution of next command. If you or anyone has solution for this please let me know. Thank you. Jay

Sign in to comment.


Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh on 30 Jul 2014
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 ;)

Community Treasure Hunt

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

Start Hunting!