Serial Port Communication with ASCII string

4 Ansichten (letzte 30 Tage)
Vaggelis Madias
Vaggelis Madias am 13 Jun. 2018
Kommentiert: dralp am 5 Nov. 2021
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!

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Jun. 2018
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 Kommentare
Vaggelis Madias
Vaggelis Madias am 18 Jun. 2018
Thank you very much! It worked!
dralp
dralp am 5 Nov. 2021
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,

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by