Data Logging for Electronic Balance Shimadzu UX4200H
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Here is my simple code applied to Data Logging (RS232 port) of an Electronic Balance (model UX4200H, Shimadzu). I would be pleased for any comments. best wishes, Gustavo
instrreset;
clear all;
close all;
clc;
% remove any remaining serial objects to prevent serial issues
disp('BEGIN PROGRAM');
% Initialize Serial Port Object [s]
s = serial('COM4');
% Specify connection parameters
set(s,'BaudRate',300,'DataBits',8,'StopBits',1,'Parity','None','Timeout',0.1);
% Open serial connection
fopen(s);
% Specify Terminator
s.terminator = 'CR/LF';
% Set read mode
set(s,'readasyncmode','continuous');
% Check Open serial connection
s.Status
% Send command PRINT to eletronic balance UX4200H
fprintf(s,'PRINT')
% Read the output
r = fgets(s)
% Convert CHAR/string to array number
r = str2num(r(1:9));
xlswrite('results', r)
% Disconnect and close serial port
fclose(s);
delete(s);
clear s
disp('STOP')
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu String 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!