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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Capturing Event times
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

wbriggs90

USA
5 Posts

Posted - 04/16/2016 :  2:31:23 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver.2016 and Service Release 1(Select Help-->About Origin):
Operating System:Windows

I just need a little help getting started on some Labtalk Programming.
I have a sheet of data containing three columns.

Time (x) Numeric
Valve Voltage (y) Numeric
Clutch Pressure (y) Numeric

I want to capture the start time when voltage goes above 3 and then capture the end time as when pressure goes above 150. the delta of these would be my desired output (actuation time).
If I can get the help defining this then I can modify to get de-actuation times and do statistics on these outputs. such as mean actuation time and standard dev. An image of my data is below.



Zoomed in on a single actuation


Thanks,
Will

Edited by - wbriggs90 on 04/16/2016 5:52:01 PM

jasonzhao

China
262 Posts

Posted - 04/18/2016 :  05:57:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

It seems that the main process is to get the Intersect between the signal and horizontal line y=3 and y=150;

You can construct the horizontal line and calculate the Intersect by using Gadget: Intersect with graph active;

In Gadget dialog, you can Click the triangle button and select the Generate Script for LabTalk usage.

Please refer to this page for details:
http://www.originlab.com/doc/Origin-Help/Gadget-Intersect

Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 04/18/2016 05:58:04 AM
Go to Top of Page

wbriggs90

USA
5 Posts

Posted - 04/18/2016 :  11:18:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm not sure that what you suggest will achieve what I'm after. Maybe I misunderstand the application of the intersect tool.
Essentiall I want to monitor the data streams and wait for clutch voltage to go high. then I want to monitor clutch pressure to see when it goes High(>150). then I want to capture in an array the actuation number and the time it took from clutch voltage onset to clutch pressure above 150. then the same thing on the next one, and on and on and on. What I have right now:
// define and initialize variables;
pp=col(2);
vv=col(3);
t=col(1);
cph=150;
cpl=10;
cv=10;
list;
range pp=col(2);
acount=0;
nrows=pp.getsize();
xstart=0


// loop through data





for(int ii = 1,ii<nrows,ii+=1) ;
{
if(vv[ii]<cv & pp[ii]<cpl)
c=1;

if(vv(ii)>cv & pp[ii],cph);
c=2;

if(vv[ii]>cv & pp[ii]>cvh;
c=3;



I am thinking I will define the states this way
case 1 is clutch is deactuated
case 2 is clutch is actuating
case 3 is clutch is actuated
case 4 is clutch is de-actuating


thoughts?

Edited by - wbriggs90 on 04/18/2016 11:22:27 PM
Go to Top of Page

wbriggs90

USA
5 Posts

Posted - 04/19/2016 :  12:37:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is where I am now. This code will not run and I am having trouble debugging. I get Command Error. Not sure of the source. I have stepped through it a couple times but this is my first labtalk script.


// define and initialize variables;
range pp=col(2);
range vv=col(3);
range t=col(1);
cph=150;
cpl=10;
cv=10;
range pp=col(2);
acount=0;
nrows=pp.getsize();
xstart=0;
xend=0;
c=0;
ii=1
// loop through data





for(ii = 1,ii<nrows,ii+=1)
{
if(vv[ii]<cv & pp[ii]<cpl)c=1; //de-actuated
if(vv(ii)>cv & pp[ii]<cph) //Actuating
{ if(c=1)
{
xstart=t[ii];
acount+=1;
}
c=2;
}
if(vv[ii]>cv & pp[ii]>cph) //actuated
{if(c=2)
{
xend=t[ii];
col(4)[acount]=acount;
col(5)=xend-xstart;
}

c=3;
}
if(vv[ii]<cv & pp[ii]<cph) c=4;

}
Go to Top of Page

jasonzhao

China
262 Posts

Posted - 04/19/2016 :  03:05:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Would you please send a sample data to us (by mail: tech@originlab.com)?

so we can hava a try and provide you an example.

Best regards!
Jason
OriginLab Technical Service

Edited by - jasonzhao on 04/19/2016 03:05:55 AM
Go to Top of Page

wbriggs90

USA
5 Posts

Posted - 04/19/2016 :  9:47:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have achieved what I want with the below script. Please take a quick look to see if there are any best practices I did not follow or if you have any suggestions on better labtalk script writing.:

// define and initialize variables;
range pp=col(2);
range vv=col(3);
range t=col(1);
cph=150;
cpl=10;
cv=10;
acount=0;
nrows=pp.getsize();
xstart=0;
xend=0;
c=0;
ii=1;
range tt=col(6);
Range a = col(4);
range at= col(5);

// loop through data





for(ii = 1;ii<nrows;ii+=1)
{
if(vv[ii]<cv && pp[ii]<cpl) c=1; //de-actuated
if(vv[ii]>cv && pp[ii]<cph && c==1) //Actuating
{
if(c==1)
{
xstart=t[ii];
acount+=1;
}
c=2;
}
if(vv[ii]>cv && pp[ii]>cph) //actuated
{
if(c==2)
{
xend=t[ii];
a[acount]=acount;
at[acount]=(xend-xstart);
}

c=3;
}
if(vv[ii]<cv && pp[ii]<cph && c!=1) c=4;

tt[ii]= c

}

double aa=mean(col(f));
double sd=stddev(col(f));
double atime=(aa+(3*sd));

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000