마이크로 컨트롤러에서 전송되는 직렬 포트에서 데이터를 플롯하려고 할 때이 데이터를 해석하고 그래프로 나타냅니다. 데이터는 너무 빨리 (마이크로 초의 50 분마다) 오게 될 것이므로 특정 수의 데이터 포인트를 읽으면 그래프를 따라 스크롤하고 싶습니다. 스크롤없이 단일 데이터 값과 여러 데이터 값을 성공적으로 그래프화할 수 있었지만 스크롤을 구현하려고하면 값이 왜곡되고 보통 스크롤 할 값에 도달하면 코드가 깨집니다.스크롤 할 Matlab 플로트 가져 오기
delete(instrfind);
clear;
close all;
s = serial('COM3'); %assigns the object s to serial port
set(s, 'InputBufferSize', 1); %number of bytes in inout buffer
set(s, 'FlowControl', 'hardware');
set(s, 'BaudRate', 9600);
set(s, 'Parity', 'none');
set(s, 'DataBits', 8);
set(s, 'StopBit', 1);
set(s, 'Timeout',10);
%s.Terminator = '"';
clc;
disp(get(s,'Name'));
prop(1)=(get(s,'BaudRate'));
prop(2)=(get(s,'DataBits'));
prop(3)=(get(s, 'StopBit'));
prop(4)=(get(s, 'InputBufferSize'));
disp(['Port Setup Done!!',num2str(prop)]);
fopen(s); %opens the serial port
t=1;
a = zeros(100,'int8');
dataToDisplay = zeros(100,'int8');
disp('Running');
dataToDisplay = [];
while(t < 501) %Runs for 500 cycles
for x = 1:4
a(x) = fread(s); %reads 3 values of the data from the serial port and stores it to the matrix a
end
if (t>101)
for i = 1:98
dataToDisplay(100) = ((a(1)-96)*10)+(a(2)-80)+((a(3)-32)/10); % combines the values in a and changes them into the value to display
dataToDisplay(i) = dataToDisplay(i+1);
end
else
dataToDisplay(t) = ((a(1)-96)*10)+(a(2)-80)+((a(3)-32)/10);
end
%if(data(t) == 10)
%dataToDisplay(t) = a;
plot(dataToDisplay,'-*r');
axis auto;
grid on;
hold on;
t=t+1;
x = 0;
a=0; %Clear the buffer
drawnow;
end
fclose(s); %close the serial port
나는 또한 내가 읽고있다 값이 4 7 세그먼트 디스플레이에 동시에 표시하므로 내가 표시 할 양식 번호를 얻기 위해 필요한 디코딩 할 것을 추가해야합니다. 처음 3 개의 디스플레이는 숫자를 유지하는 반면, 4 번째 유닛은 현재 MATLAB 코드에서 필요하지 않은 유닛을 가지고 있습니다. 때문에 assumedly 오타 무엇
당신은 확실 이 '보류'가 필요한가요? 또한 아마도 수동으로 축을 정의 할 수 있습니다. 아마 훨씬 쉽게 읽을 수 있기 때문입니다. – MayeulC
지금 당장 스크롤링 작업을 시작하려고합니다. 결과적으로 결국 다른 축을 수동으로 설정 한 다른 서브 플로트를 갖게 될 것입니다. – AmatuerCoder101