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.
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:
Thanks a lot.If you can make it in a GUI,that will better.
All this zip file contains is a blank license.txt file.
There is not code inside
Thanks a lot.
Can anyone kindly take a look at look my following errors. What should I do to get this to work please?
Index exceeds matrix dimensions.
Error in real_time_data_plot (line 34)
serialObject = serial(serialPort);
Thanks a lot.
I test your code, and it's okay.
with condition i change:
voltage(count) = fscanf(serialObject,'%f',1); %#ok<SAGROW>
I don't now why? but result is good.
Thank a again.
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.
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!
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...
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.
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.
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>
Create scripts with code, output, and formatted text in a single executable document.