Sending <ESC> T over Serial port to Scale

14 次查看(过去 30 天)
Hello dear community,
I have a scale from the company Sartorius. My task is to send commands to the scale, to get the weigth back or to tare the scale.
In the scale-menu I can choose between different modes: "SBI" (Standard-Sartorius Protocol), "SCIS" (another Sartorius Protocol) and "Secondscreen(SBI)" (the scale is sending the weigth continiously).
Over Putty I succesfully connected to the scale in running mode "Seconscreen(SBI)". So I could read the weigth but couldn't give commands. I also can recieve the weigth in Matlab via fscanf(s).
But I want to communicate with the scale, so there are in the manual the commands for the SBI protocol and there are commands for the SCIS protocol.
I tried both of them but without success. In the SBI-protocol f.e. if I want to tare the scale the command is "<ESC> T" (see link below on Page 154&155).
Manual - SBI commands (page 154 and 155)
I tried to send the ASCII "ESC" and the T with the following code:
s = serial('COM4');
s.Baudrate=9600;
s.DataBits=8;
s.StopBits=1;
s.Parity='none';
s.Terminator='CR/LF';
fopen(s);
pause(0.1);
%fprintf(s,'%X','1B');
%fprintf(s,'%s','T');
%fprintf(s,char(27)+'T');
fprintf(s,'%X','1B 54');
fclose(s);
Can somebody help me communicate with my scale in SBI or in SCIS?
Or can somebody atleast give me the correct code for sending "<ESC> T" to the scale?
Thanks,
Rob

采纳的回答

Walter Roberson
Walter Roberson 2019-3-15
fprintf(s, '%cT', 27)
you might also need to send a terminator
  2 个评论
Rob
Rob 2019-3-15
Thanks for the fast answer. It didnt work probably because of the Terminator. I would like to add <CR> & <TR> (ASCII 13 and 10) at the end of the command Is this the correct syntax ?
fprintf(s, '%c T%c%c', [27, 13, 10]);
Walter Roberson
Walter Roberson 2019-3-16
Set the serial Terminator property to 'CR/LF' and
fprintf(s, '%c %\n', 27);
The \n will automatically be converted to CR LF

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by