Data Logging for Electronic Balance Shimadzu UX4200H

2 vues (au cours des 30 derniers jours)
Gustavo Dacanal
Gustavo Dacanal le 14 Sep 2016
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')

Réponses (0)

Catégories

En savoir plus sur Low-Level File I/O 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!

Translated by