LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with writing a program that will allow for stop/start commands (or something along those lines)

Not the greastest title to post, but wasn't sure how else to describe it in a title,

So I have a problem.  I want to run part of my vi, possibly multiple times as I modify the number of points in a set of data that I want to do a lienar regression.  Then once I have settled on a the number of points I want to use, I want to take the slope and intercept from the linear fit and use that in the other part of the vi.

my problem is that I don't know how to approach this. I had thought of using case structures.  But I wasn't sure if that was the most appropriate option and if it was hwo to approach it.  So what I am really looking for here is some advice on how I should approach this.


I will give a bit more detail of the vi (I should note this is not my entire vi, I have truncated it to the relevant parts for this problem).  So i have set of intensity data and I want to run an autocorrelation on it, which is what my autocorrelation vi does.  Once I get the autocorrelation data I normalise it.  What I then do is to the get the initial slope of the autocorrelation data.  This is done in my slope intercept vi.  At the moment I have got things wired so that I can see how the fit looks with the data.  It is here that I will be changing the number of points that are to be fitted.  This slope intercept data is then used to calculate an apparent diffusion coefficient.  It is in this region that I want to be able to essentially split the program into two parts.  The first part allows for an appropriate fitting procedure to the initial slope of the auto correlation and to thus yeild the apprirate values.  the second part is to then take the slope and intercept values and use them to calculate the apparent diffusion coefficient; so here I want to be able to then tell the program to run with the slope and intercept data (like using a button or something).


I have included the vi's and an example of my intensity data in a zip file.

Any help would be appreciated.

 

Thanks

0 Kudos
Message 1 of 9
(3,375 Views)

This sounds like a perfect application for a State Machine architecture.

Try searching for State Machine and going through a few examples.

 

In your case, you will have a state for:

- initialization

- calibration (setting the number of points in the set)

- data analysis (linear fit)

 

Post back if you are having trouble figuring out how to set this architecture up.

Cory K
0 Kudos
Message 2 of 9
(3,359 Views)
I updated your main VI. It is not a state machine but I think it get you closer to what you want whitout going that far. I only updated the main vi dapp calculator.vi
Tim
GHSP
0 Kudos
Message 3 of 9
(3,344 Views)
you could also use an event structure.
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 4 of 9
(3,338 Views)
If you put my vi in the same folder as the others that you had and it should run.
Tim
GHSP
0 Kudos
Message 5 of 9
(3,332 Views)
State machine for the win.
---------------------------------
[will work for kudos]
0 Kudos
Message 6 of 9
(3,323 Views)
Thanks guys, I appreciate the quick response.

@aeastet - I still need to update to LV 9 so I couldn't check your code.  I will do that soon and when I do I will have a look at it.

With regards to using a state machine, I think I will have ago at this as well since it is somethign that is worth knowing how to do in general.  I will give it ago and if I have any troubles will be back here (can't work on it today, am in the lab).  Thanks Cory K. for pointing out the 3 states that I will need.
Message Edited by scottum on 09-22-2009 01:47 PM
0 Kudos
Message 7 of 9
(3,293 Views)
here is 8.6
Tim
GHSP
0 Kudos
Message 8 of 9
(3,275 Views)
Thanks aeastet.  Going through it now.
0 Kudos
Message 9 of 9
(3,271 Views)