query and read the status from Com port

조회 수: 2 (최근 30일)
KANG
KANG 2015년 5월 29일
댓글: Ajit Singh 2020년 11월 2일
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
Ajit Singh
Ajit Singh 2020년 11월 2일
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

댓글을 달려면 로그인하십시오.

답변 (2개)

Dasharath Gulvady
Dasharath Gulvady 2015년 5월 29일
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
Ajit Singh
Ajit Singh 2020년 11월 2일
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

댓글을 달려면 로그인하십시오.


KANG
KANG 2018년 4월 3일
Sorry for the late, but thanks a lot for your feedback!

카테고리

Help CenterFile Exchange에서 Optics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by