query and read the status from Com port

3 visualizaciones (últimos 30 días)
KANG
KANG el 29 de Mayo de 2015
Comentada: Ajit Singh el 2 de Nov. de 2020
Hi all!
I am working at the com port in order to control the optical shutter (SC10; Thorlabs) using MATLAB. While I could control it, I am looking for the way to read the optical shutter status (open or closed). There is a command 'closed?' to do this but MATLAB does not return the correct value. My code is like,,
s=serial('COM1');
s.Terminator='CR';
fopen(s);
fprintf(s,'ens');
fprintf(s,'closed?');
Ret=fscanf(s)
It would be greatly appreciated if I could get any input!
Thanks,
Kang
  1 comentario
Ajit Singh
Ajit Singh el 2 de Nov. de 2020
Dear Sir,
Could you provide the MatLab script to operate the shutter: opens for 200 mili second in every 10 seconds for 3 times.
Thank you.
Regards

Iniciar sesión para comentar.

Respuestas (2)

Dasharath Gulvady
Dasharath Gulvady el 29 de Mayo de 2015
You have two "fprintf" calls in the code and one "fscanf". The "fscanf" will return the result of "ens". For "closed?" execute "fscanf" one more time.
  1 comentario
Ajit Singh
Ajit Singh el 2 de Nov. de 2020
Dear Sir,
Could you provide the MatLab script to operate the shutter: opens for 200 mili second in every 10 seconds for 3 times.
Thank you.
Regards

Iniciar sesión para comentar.


KANG
KANG el 3 de Abr. de 2018
Sorry for the late, but thanks a lot for your feedback!

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by