The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Plot real time data form multiple sensors

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
TomBe Posted - 06/17/2015 : 09:08:31 AM
Hi,
I’m having problems with importing data in real time into Origin and plot them.
The data is available through a serial COM port, or an ASCII file, in which the new values are constantly written into.
The data stream contains multiple sensors and I would like to display them in a bar chart next to each other.

The data stream would look like this:

1 value_sensor1
2 value_sensor2


But I could change the data stream to any format, if needed.

I’ve tried this script: http://www.originlab.com/forum/topic.asp?TOPIC_ID=2370
quote:
getfilename *.*; // open file selection dialog... find your ASCII file
%Z=%B%A; // %A is selected file name, %B is its path
%P=%H; // plot name
%W=%[%C,'_']; // wks name. Next, define the TimerProc macro...
def TimerProc {
win -o %W {open -w %Z}; // import ASCII file to wks
lay -a; // rescale to show new data
};
timer 6; // run TimerProc every 6 seconds



My problem is, that Origin plots the highest value for each sensor. But I need the latest value for each sensor to be plotted.
Is there a simple way to accomplish this?
I’m very grateful for any help.
6   L A T E S T    R E P L I E S    (Newest First)
SeanMao Posted - 07/14/2015 : 02:31:38 AM
Hi,

If you select the whole column, the bar of the highest value will overlap with other ones and appeared as one bar only.

That is way in the script I replied before, it will only plot the latest added points but not the maximum value.

Regards!

Sean

quote:
Originally posted by long123

My problem is, that Origin plots the highest value for each sensor. But I need the latest value for each sensor to be plotted.

sbvdxfnbghm

long123 Posted - 07/10/2015 : 02:03:10 AM
My problem is, that Origin plots the highest value for each sensor. But I need the latest value for each sensor to be plotted.

sbvdxfnbghm
TomBe Posted - 07/04/2015 : 06:34:04 AM
Thank you very much for your help.
Unfortunately Origin needs a few seconds to load the file, after 10 seconds, because the file is getting too big, I guess.
Origin is probably not the right program for live data.
But the code you wrote works fine, if you wait a few seconds.
Thank you
SeanMao Posted - 06/19/2015 : 04:34:08 AM
Hi,

Suppose you have 3 sensors, the following code should help:


string fname$ = E:\Test\TestData.txt;
impasc;
@glob=1;
range raIn = !; // For reimport
int inirows = count(col(1),!=""); // Count total data rows
//Suppose there are only 3 sensors
plotxy (wcol(1)[inirows-2:inirows],wcol(2)[inirows-2:inirows]) 215; // Plot last sensor set as bar plot
string gname$ = %H;
double olddate = exist(%(fname$),5); // Note the file date-time

def timerproc
{
    double newdate = exist(%(fname$),5); // Current file date-time
    if(newdate != olddate)
    {
        reimport orng:=raIn; // reimport if the file has changed
        olddate = newdate;
        win -c %(gname$); // Delete previous graph
        int nrows = count(col(1),!=""); 
        range rnewX = wcol(1)[nrows-2:nrows]; // Define a range to store last 3 X values
		range rnewY = wcol(2)[nrows-2:nrows]; // Define a range to store last 3 Y values
		plotxy (rnewX,rnewY) 215;
		string gname$ = %H;
    }
    else ty Nothing new ...; // Delete this line if not needed
}

@glob=0;
timer 10;

//timer -k;
TomBe Posted - 06/18/2015 : 05:52:00 AM
Hi Sean,
Thank You very much for the quick reply. This method seems much more elegant.
But unfortunately it didn’t solve my problem. Origin still displays the highest value for each sensor in the bar chart.
I probably did not explain exactly enough how the values are written into the file.
The new values are constantly added to the end of the file.
The file would look like this after a few milliseconds:
1 value_sensor1
2 value_sensor2

1 value_sensor1
2 value_sensor2

1 value_sensor1
2 value_sensor2


I’ve tried to use the Range Notation to plot only the latest values, but it seems that that’s not the right way.

I could add a Y value to my data stream, which will be increased every time after all sensor values are written.
For example:

X Y Z
1 1 value_sensor1
2 1 value_sensor2

1 2 value_sensor1
2 2 value_sensor2


If I use the 3D Surface Graph instead of the bar chart, is it possible to plot the second last Y value, so Origin does not plot a half finished row of values?

Regards
Tom
SeanMao Posted - 06/17/2015 : 10:03:05 PM
Hi,

You can check out the example in link below for your case:

http://www.originlab.com/doc/LabTalk/examples/Data-Import#Reimport

In the example, there is a line should be modified as following:

plotxy (1,2) 215; // Used to plot a bar plot

For plot type IDs, please refer to this page:

http://www.originlab.com/doc/LabTalk/ref/Plot-Type-IDs

Give it a try and see how far it goes.

Regards!

Sean

OriginLab Tech. Service

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000