Hello everyone,
I am trying to connect to CL200A Konica Minolta luxmeter. The communication specification manual states that i should send to the instrument
as an ASCII string the following command: [STX]+"00541 "+[ETX]+[BCC="13"]+[DELIMITER]
The HEX equivalents are
STX -> 02
00541 -> 30 30 35 34 31 20 20 20 (After the 00541 there are 3 space characters.)
ETX -> 03
BCC -> 31 33
The Delimiter for the luxmeter is CR/LF. How do i write this command in Matlab?
Do i use fprintf or some other function?
Thank you!

 채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 13일

0 개 추천

fprintf(device, '%c00541 %c13\r\n', 2, 3)
is one of the ways.
For efficiency I would sprintf it to a character vector and then fwrite() that to the device if this is being invoked in a loop.

댓글 수: 4

MATLAB displays this msg: "Error using serial/fprintf MODE must be either 'sync' and 'async' "
fprintf(device, '%c00541 %c13\r\n', [2, 3])
But what I would do instead is
S = sprint('%c00541 %c13\r\n', [2, 3]);
fwrite(device, S)
Or I might use
S = sprintf('\00200541 \00313\r\n')
or
S = sprintf('\x0200541 \x0313\r\n');
Using the %c version makes it easier to distinguish the characters to be converted from the fixed text.
Thank you very much! It worked!
Hello, thank you both for asking and responding to the question.
I'm trying to connect and read data from Konica Minolta T10a illuminance meter and CL500A spectroradiometer. To read date from T-10a, the technical note says use:
STX + receptor head (01) + command (10) + parameter + ETX + BCC + CR + LF
Parameters are: Hold 0=run 1=hold + CCF 2=disable 3=enable + Range 0=auto + 0
So for hold=run, CCF=disabled, range=auto, that should be something like this:
dataIN="\00201100200\00301\r\n";
writeline(s,dataIN)
dataOUT = readline(s);
But I get this error message:
Warning: The specified amount of data was not returned within the Timeout period for 'readline'.
'serialport' unable to read any data. For more information on possible reasons, see serialport Read Warnings.
Any ideas?
Thank you,

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

추가 답변 (0개)

질문:

2018년 6월 13일

댓글:

2021년 11월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by