|
From: | Doug Stewart |
Subject: | Re: Read serial data directly into Octave |
Date: | Thu, 10 Aug 2017 18:03:51 -0400 |
Hello,
I am trying to have Octave read data from a serial port and then create a
figure with this data. When I run this program all I get is a blank figure
with no data on it. Is there any errors in my code below? Please let me
know.
Thank you
page_screen_output(0);
page_output_immediately(1);
pkg load instrument-control
close all
clear all
clc
ch1 = serial("COM4", 9600);
set(ch1,"bytesize", 7)
set(ch1,"stopbits", 2);
srl_flush(ch1);
i = 1;
srl_write(ch1, "F");
y=0;
x=0;
READY = yes_or_no ("Ready to test? \n");
t=0;
t2=360;
fig_data = [0,0];
dt = 0.02;
h =figure(2);
b1 = uicontrol (h, "string", "Start Test", "position",[10 0 150
20],"callback","uiresume(h)");
b2 = uicontrol (h, "string", "End Test", "position",[200 0 350
20],"callback","break");
uiwait(h);
tic;
unwind_protect
while t < t2
sleep (dt)
srl_write (ch1,"?");
y_raw = strtrunc(char(srl_read(ch1,11)),7);
y_serial = -1* str2num(y_raw);
i = i + 1;
plot(fig_data(:,1),fig_data(:,2));
grid on;
title('90 Degree Peel Test');
xlabel('Time (s) ');
ylabel('Pull Force (lbs)');
t = toc;
fig_data = [fig_data;t,y_serial];
t = t + dt;
endwhile
unwind_protect_cleanup
t_end = t;
csvout = "Data2.csv";
dlmwrite(csvout,fig_data,",");
result_area_t = area_under_peel_time(fig_data,t_end);
result_area = area_under_peel(fig_data,t_end);
end_unwind_protect
af = num2str(result_area_t);
msgbox(strcat("Chart Area: ",af,' Pound-Seconds','
Time:',num2str(t_end)));
close(h);
srl_close(ch1)
--
View this message in context: http://octave.1599824.n4.nabble.com/Read-serial-data- directly-into-Octave- tp4684422.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |