I am new to matlab. With the help of online search i have written MODBUS RTU code to fetch data from my device. I want to import this data to simulink for further DSP analysis. Below is my matlab code for fetching MODBUS RTU data from serial port.
instrreset;
clear all;
close all;
clc;
s = serial('COM4');
set(s,'BaudRate',115200,
'DataBits',8,
'StopBits',1,
'Parity','None','Timeout',1);
fopen(s);
request = uint8(hex2dec(['01'; '03'; '00'; '00'; '00'; '02'; 'C4'; '0B']));
ts = timeseries('mySeries'); % Updated
while(1)
fwrite(s, request);
outdec = fread(s,9);
y = typecast(uint8([outdec(7) outdec(6) outdec(5) outdec(4)]),'int32');
z = datevec(datetime('now')); % Updated
ts = timeseries(y, z); % Updated
disp(y);
end
fclose(s);
delete(s);
clear s
disp('STOP')
in while loop i am continuously fetching the modbus value in variable y. Now i want this value in simulink. My data fetching will be at every 100ms or you can say my sampling frequency will be 10hz.. Any help will be appreciated.
My main aim is to design the digital filter that is best suited for my application.
Thanks in advance.