Data Logging for Electronic Balance Shimadzu UX4200H
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!