5.0

5.0 | 1 rating Rate this file 136 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 Ankit Desai

 

07 Oct 2009

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  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
17 Mar 2010 Diego Orlando  
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

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.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
agilent Ankit Desai 20 Oct 2009 10:25:24
34401a Ankit Desai 20 Oct 2009 10:25:24
agilent 34401a Ankit Desai 20 Oct 2009 10:25:24
serial Ankit Desai 20 Oct 2009 10:25:24
scpi Ankit Desai 20 Oct 2009 10:25:25
real time Ankit Desai 20 Oct 2009 10:25:25
data collection Ankit Desai 20 Oct 2009 10:25:25
real time plot Ankit Desai 20 Oct 2009 10:25:25
rs232 Ankit Desai 20 Oct 2009 10:25:25
com1 Ankit Desai 20 Oct 2009 10:25:25
com port Ankit Desai 20 Oct 2009 10:25:25
publish Ankit Desai 20 Oct 2009 10:25:25
tm Ankit Desai 20 Oct 2009 10:25:25
instrument Ankit Desai 20 Oct 2009 10:25:25
query Ankit Desai 20 Oct 2009 10:25:25
test Ankit Desai 20 Oct 2009 10:25:25
report Ankit Desai 20 Oct 2009 10:25:25
34401a Thilini 30 May 2010 11:01:51
real time nolwenn Guillemot 19 Jul 2010 04:42:09
real time plot nolwenn Guillemot 19 Jul 2010 04:42:15
real time plot Ghani Amna 05 Jan 2011 04:20:37
real time plot Marianne Ruiz 26 Apr 2011 16:55:02
agilent Galboa 01 Nov 2011 02:43:41
agilent 34401a Galboa 01 Nov 2011 02:43:44
instrument yong yong 24 Dec 2011 21:37:48

Contact us at files@mathworks.com