T O P I C R E V I E W |
wbriggs90 |
Posted - 04/16/2016 : 2:31:23 PM 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.
![](http://www.originlab.com/ftp/forum_and_kbase/Images/Clutch Graph.PNG)
Zoomed in on a single actuation
![](http://www.originlab.com/ftp/forum_and_kbase/Images/Clutch Graph 2.PNG)
Thanks, Will |
5 L A T E S T R E P L I E S (Newest First) |
wbriggs90 |
Posted - 04/19/2016 : 9:47:51 PM 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));
|
jasonzhao |
Posted - 04/19/2016 : 03:05:11 AM 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 |
wbriggs90 |
Posted - 04/19/2016 : 12:37:09 AM 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;
}
|
wbriggs90 |
Posted - 04/18/2016 : 11:18:43 PM 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? |
jasonzhao |
Posted - 04/18/2016 : 05:57:23 AM 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 |