Serial Port Communication with ASCII string
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vaggelis Madias
le 13 Juin 2018
Commenté : dralp
le 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!
0 commentaires
Réponse acceptée
Walter Roberson
le 13 Juin 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 commentaires
dralp
le 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,
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!