Sending <ESC> T over Serial port to Scale

21 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 15 Mar 2019
fprintf(s, '%cT', 27)
you might also need to send a terminator
  2 Comments
Rob
Rob on 15 Mar 2019
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 on 16 Mar 2019
Set the serial Terminator property to 'CR/LF' and
fprintf(s, '%c %\n', 27);
The \n will automatically be converted to CR LF

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!