4.0

4.0 | 6 ratings Rate this file 183 Downloads (last 30 days) File Size: 2.79 KB File ID: #25519
image thumbnail

Collect and plot data from an instrument in real time

by

 

Real time data collection & plotting using query based instrument interactions.

| Watch this File

File Information
Description

This MATLAB(R) script generates a real time plot of voltage values collected from an Agilent(TM) 34401A Digital Multimeter over the serial port(RS232). The data is collected and plotted until the predefined stop time is reached. This example also demonstrates automating a query based interaction with an instrument while monitoring the results live.

This script can be modified to be used on any platform by changing the serialPort variable.

Example:-
On Linux: serialPort = '/dev/ttyS0';
On MacOS: serialPort = '/dev/tty.KeySerial1';
On Windows: serialPort = 'COM1';

The script may also be updated to use any instrument/device to collect real time data. You may need to update the SCPI commands based on information in the instrument's programming manual.

To generate a report of this entire script, you may use the PUBLISH command at the MATLAB(R) command line as follows:

publish(real_time_data_plot);

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
02 Apr 2014 Stuart

Great code, nice and neat. Just wondering if you know whether you can run this concurrently with other processes, say, in a GUI? I want to have this logging every few seconds and in between, pass control back to allow other processes to run.
Great work

10 Feb 2014 An Nguyen  
09 Apr 2012 Andrew

Hello Ankit,

Thank you very much for sharing this with us. I'm trying to read in sonar data via UART continuously over the serial port. I am having speed issues, however, after a certain amount of time.

Would you happen to know if this is a buffer issue? There doesn't seem to be any active cleaning as count increases. I tried a quick fix to reset count back to 1 after 200 iterations which does update correctly but the speed issue still persists.

Any insight would be greatly appreciated!

30 Mar 2012 saranya

and..sir....i dunno to decide...if i should show the three heat variations in a single graph or to create three separate graphs to show induvidual variation...please help me to finish the code sir...

21 Feb 2012 Ying Zhou

Thanks for ur work. It's very useful. I have a pressure sensor to measure air pressure. I use Arduino uno to do ADC and connect to PC. Send data trough serial port to PC. Just made a little change of ur code I got real-time plot of my sensor data successfully.

21 Feb 2012 Ying Zhou  
21 Feb 2012 Ying Zhou  
08 Oct 2010 Ankit Desai

You are getting that error since the fscanf on the serial object did not return any data. You might want to put in a check to make sure you are getting data in each iteration. Hope this helps.

27 Sep 2010 Christian Franco

Hallo and thank you for your work. When i run the file it prompts an error that said

??? In an assignment A(I) = B, the number of elements in B and
I must be the same.

Error in ==> real_time_data_plot at 81
voltage(count) = fscanf(serialObject,'%f'); %#ok<SAGROW>

thank you

17 Mar 2010 Diego Barragán  

Contact us