Data Logging for Electronic Balance Shimadzu UX4200H

2 visualizaciones (últimos 30 días)
Gustavo Dacanal
Gustavo Dacanal el 14 de Sept. de 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')

Respuestas (0)

Categorías

Más información sobre Low-Level File I/O en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by