Hi
I am trying to use udpport to sample data from a netFT device that theoretically can sample at 7000 Hz. I am not experienced in using UDP (and udpport) but found some code that can collect the data. However it collects the data without timestamps, which i added, and the sampling period is irregular to highly ireggular. The sampling freqency is also depended on how much i do in between (upd)-read commands which is a problem as I also want a live plot-feed of the data. For the plotting I have some ideas for some home made burst-chunk sampeling, but the problem is having consistent sampeling times and preferble close to the 7000 hz sampeling rate.
In bare a bones version i get the sampeling to about 3000 hz (with a devition of up to ~40% in a 1000 sampels) but this drops down to about 1000 hz when using the "flush(u)" and introduces "lag-spikes" (sample freq ~ 5 hz for 1-5 samples) around every 200:th sample. But it seems the flush is need if I want a functional live-plot. With a live plot i go down to about 10-25 hz sampling frequency.
Is there some sort of buffer in udp-read that can be used to collect larger chunks of the data?
Is there a better way to get timestamps?
Tips on how do i get a stable sampling-frequency not dependent on the computers execution time (I am ok with sampling freqency of about 500 hz)?
u = udpport('byte', 'IPV4');
startCommand="Special Hex Start-String";
write(u, startCommand, "string", netFT, port)
result=zeros(numIterations,6);
TimeStamps=NaT(numIterations,1);
[result(i,:), TimeStamps(i)] = netFT_getFreshData(u);
plot(TimeStamps,result(:,1))
function [ data, TimeStamp ] = netFT_getFreshData(u)
TimeStamp=datetime("now");