Seeking advice on real time ploting GUI, how to implement the data collection.

2 views (last 30 days)
Hello.
I am using a Arduino Due on which a Peripheral DMA Controller (PDC)(Direct Memory Access) to fill a 256*4 buffer and then as each one of those 4 fill up the values are sent to matlab through Due's native port with USB speeds. I did not figure out the microcontroller code by my self and it comes from here:
Anyway as it is now all it does is to throw chunks of 512 bytes through the COM port/USB. Arduino has something called SerialUSB that I can't find any info on but that seems to enable me to use it as I would a ordinary com port with a RS232 converter but way way faster.
I have made this function to check that it works:
function [] = Due_realTimePlot
s = serial('COM10');
set(s, 'DataBits', 8);
set(s, 'StopBits', 1);
set(s, 'BaudRate', 115200);
set(s, 'Parity', 'none');
set(s, 'InputBufferSize', 10240);
fopen(s);
b_data = fread(s, 2048, 'uint8');
LSB = b_data(1:2:end);
MSB = b_data(2:2:end);
result = ((MSB .* 256) + LSB);
fclose(s);
delete(s);
clear s;
clear b_data LSB MSB;
end
But I want to use this to collect large number of samples, average them to increase the resolution and then process the data in different forms such as making a histogram or perform FFTs and other fun stuff. So I begun writing a GUI without guide but I don't know how one handles the collecting part vs the ploting, I have no experience with this sort of thing and I honestly can't even know what I am really after but I want to learn that in due course. Right know I have begun the GUI by having the COM port set up and only when the port is opened will the Due start sending data, I guess I have to find some way of ether before running it choose the duration of the acquisition session or somehow enable me to start collecting data and keep doing that until I press a button or something who's callback function closes the port.
As shown I am somewhat lost and I appreciate any and all thoughts on this hole subject, I don't want so simply make the array in matlab 10,000,000 large but I have a hard time of finding a clever way of collecting chunks in a ever growing large array and I would love to be able to collect a huge amount of samples to be stored in some file I guess.
Anyway I will write here again when I have gotten any working example or figured something out, I mean even if I have no clue and have hit a wall I should be able to find some workable way to do what I want.
Regards

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!