Serial Port Communication with ASCII string

4 visualizaciones (últimos 30 días)
Vaggelis Madias
Vaggelis Madias el 13 de Jun. de 2018
Comentada: dralp el 5 de Nov. de 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!

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion 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