Real Time Data Graphing 921600 baud Udp
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
I'm attempting to stream data into matlab at 921600 baud over wifi (udp) and am trying to graph it. I'm getting some consistently bad graphs which for some reason always stop graphing at ~700 samples. I took a screenshot of this here:

I'm wondering if it is possible to graph data that comes in at 921600 baud or if matlab simply can't handle the speeds. I've tried some minor code changes to get the graph to plot faster... but I consistently get stuck around 700 samples (which is also lagging). I'm wondering if part of the issue is with the drawnow function? Which I've read is fairly slow and drawnow might have queues that get filled up? I'm not sure about the last part... but any help would be appreciated. Here is my code for the curious:
%Attempt at simplified real time data logging
    %Udp data logging 
    function udpAnimatedLineDataPlotting
        %This function sets up the graphs
        %And initializes the udp listening
        %Initialize udpClient
        udpClient = udp('18.111.63.94',2390, 'LocalPort', 5000);
        %Initialize Plot Window
        uFigure = figure('NumberTitle','off',...
            'Name','Live Data Stream Plot',...
            'Color',[0 0 0],...
            'CloseRequestFcn',{@localCloseFigure,udpClient});
        uAxes = axes('Parent',uFigure,...
            'YGrid','on',...
            'YColor',[0.9725 0.9725 0.9725],...
            'XGrid','on',...
            'XColor',[0.9725 0.9725 0.9725],...
            'Color',[0 0 0]);
        xlabel(uAxes,'Number of Samples');
        xlim([0 1000]);
        ylabel(uAxes,'Value');
        ylim([0 4096]);
        hold on; %Hold on to allow addition of multiple plots
        uPlotSensor1 = animatedline('Color','g', 'MaximumNumPoints', 1000);
        global xcounter; %Initialize x counter value
        xcounter = 0;
        bytesToRead = 36; %Reflects length of message recieved may need to be changed
        udpClient.BytesAvailableFcn = {@localReadAndPlot,uPlotSensor1,bytesToRead};
        udpClient.BytesAvailableFcnMode = 'byte';
        udpClient.BytesAvailableFcnCount = bytesToRead;
        udpClient.InputBufferSize = 1000;
        fopen(udpClient); 
        pause(3);
    end
    function localReadAndPlot(udpClient,~,uPlotNumber,bytesToRead)
        global xcounter;
        data = fread(udpClient,bytesToRead); 
        dataStr = char(data(1:end-2)'); %Convert to an array
        if length(dataStr) == 34 %34 = length of message received
            if xcounter == 1000
                xcounter = 0;
            end
            xcounter = xcounter + 1;
            %Convert to an array of numbers
            dataNum = sscanf(dataStr, '%d,%d,%d,%d,%d,%d', bytesToRead);
            addpoints(uPlotNumber, xcounter, dataNum(1));
            drawnow; 
        end
    end
    function localCloseFigure(figureHandle,~,udpClient)
        fclose(udpClient);
        delete(udpClient);
        clear udpClient;
        delete(figureHandle);
        clear global sensorData1;
        clear global counter;
        fclose(instrfindall);
    end
1 Commento
  Walter Roberson
      
      
 il 22 Giu 2016
				Historically, "baud" is never used with respect to UDP, only with respect to serial (or, occasionally, parallel) connections. "baud" is "symbols per second", whereas UDP is described in terms of throughput in bytes per second. Specific transmission mechanisms such as ethernet or wi-fi might be spoken of in terms of carrier frequency, but would much more commonly be spoken of in terms of bits transmitted per second (aggregated over multiple channels in gigabit ethernet, and ethernet tends to send bit constellations with, for example, 5/4 encoding at less than gigabit, and the channel encoding for gigabit ethernet is not popping into my mind at the moment.)
For udp, per-packet interrupts are common, so to estimate the workload we need to know the packet rate and the total packet size and the payload size and the number of bytes per sample; also the link speed and the MTU you are using.
Risposte (0)
Vedere anche
Categorie
				Scopri di più su Graphics Performance in Help Center e File Exchange
			
	Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
