LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get first value of loop iteration

I am trying to calibrate two sensors that I will be continuously monitoring real time. My code is inside a while loop continously monitoring the two sensors. In order to keep them calibrated and properly monitor the values despite the change in temperature I need to know the initial voltage values they start at to adjust for thermal changes. 

 

How would I take the first value acquired in the loop at start up and store it so that I have an initial value to subtract from my continuos final values. I"m rather new to LabView and don't know if this will be done in a nested "for" or "while" loop or case stucture for that matter.

 

Thanks

-Dan 

0 Kudos
Message 1 of 5
(5,676 Views)

There are a couple of problems with your VI:

  • With a for-loop like that do not user Insert Into Array. Use a for-loop's autoindexing capabilities to give you the array automatically.
  • Why don't you just configure the DAQ Assistant to give you 10 samples in the first place, rather than using a for-loop?


There are a couple of ways to accomplish the task of getting the initial values and holding them as "calibration" values. Note that I use the word "calibration" in quotes since this isn't really a calibration, but an offset from some arbitrary value.

  • Call the DAQ Assistant outside the loop to get the values, and just feed them inside the loop.
  • Use a shift register to hold the values from the first iteration. You can drive a case structure from the loop's iteration terminal or by using the "First Call" primitive. 
0 Kudos
Message 2 of 5
(5,666 Views)

Im using the for loop to acquire 10 samples in under a second so that I have a more stable value every time the while loop iterates. At least I thought this would give me a more stable reading in under a second then asking the DAQ to simply request 10 samples.

 

I don't under stand this "first call" primitive you are referring too. I still dont understand how I would "freeze" the first values obtained so that I can use them for a "calibration."

 

Thanks

-Dan 

0 Kudos
Message 3 of 5
(5,641 Views)

I think I got it.

 

Is this along the lines of what you were referring too?

 

Thanks 

0 Kudos
Message 4 of 5
(5,637 Views)

I don't think this will work.  On the first loop iteration (i=0), the DAQ values will be put into the shift registers on the right side.  The values on the left are not intialized and will be unknown, so you are storing unknown values.  Try this vi:

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 5
(5,614 Views)