LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why is there a time delay in my while loop

Hi,

 

I am using a while loop to record data. I begin recording data of voltage. I have it set up so as soon as the voltage reaches a certain point it stops and begins to record acceleration through an accelerometer. When I do this the program works fine, and records the data, but there is a time delay from when the voltage stops recording and the acceleration begins recording. This time delay is around .3 seconds. This doesn't seem like much but I need the program to be instantaneous with no delay. Is there anything I could be doing wrong. 

 

Thanks for the help.

0 Kudos
Message 1 of 25
(3,703 Views)

ryan1212 wrote: Is there anything I could be doing wrong.

Yes.  There are lots of things you could be doing wrong.  It would help if you supplied some code to look at.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 25
(3,700 Views)
0 Kudos
Message 3 of 25
(3,689 Views)

You probably don't want to use express VIs for this (we cannot tell from the picture how things are configured).. Prepare both tasks outside the loop at the beginning, then just trigger them one after the other.

0 Kudos
Message 4 of 25
(3,671 Views)

Well, it does take time to write data to a file.  But 300ms sounds a little on the high side.  It could also be the creation of the second task taking some time before it can actually start running.  Between those two, 300ms seems plausible.

 

Look in the Example Finder (Help->Find Examples) for a DAQmx Analog Input.  I suggest learning to use the "real" DAQmx API and getting away from the Express VIs that you are using.  By doing this, you can set up both of your tasks before anything begins and start your second task as soon as you find your start condition.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 25
(3,666 Views)

You will need to use the DAQmx API to solve your delay.  There is unnecessary overhead in DAQ assistant express vis since the Tasks need to be created verified reserved and started on the first iteration and Checked on each subsequent iteration (not to mention the implicit state transition caost some time too)

 

If you Right-click the DAQ assistant you can "Generate Code>>Configuration and example" then migrate the configuration before the loop and the clear task after the loop.

Something like this:

!1.png

Which was all generated from "Generate code although I did "Pull in" the create vi to the main BD to make the snippette complete without the subvi


"Should be" isn't "Is" -Jay
Message 6 of 25
(3,663 Views)

Hi sorry, we are fairly new to LabVIEW. Can you give me a little more of an explanation of how your program works? Such as where your data is being recorded. Also we can get a voltage reading now, how do we set it up to trigger the accelerometer? 

 

Thanks again.

0 Kudos
Message 7 of 25
(3,635 Views)

@ryan1212 wrote:

Hi sorry, we are fairly new to LabVIEW. Can you give me a little more of an explanation of how your program works? Such as where your data is being recorded. Also we can get a voltage reading now, how do we set it up to trigger the accelerometer? 

 

Thanks again.


First that's a snippet drag it to your desktop-  then drag it to an empty Block Diagram in LabVIEW 2013.  the code will <Poof> into existance.  The help file will explan the functions.  If you have further questions after peering at the help file I will reply.

 

Logging was not part of my example- merely a way to move from the DAQ assistant to DAQmx API function calls.  I added Logging to this snippet so you could easilly see how to remove the other express vis and use more of the "non-expressvi" advantages.

!1.png


"Should be" isn't "Is" -Jay
Message 8 of 25
(3,612 Views)

I have the data recorded now, but I cant seem to figure out how to alter the stop condition so that when my voltage reading is below 8V the loops stops iterating. Beginning the accelerometer DAQ. I tried to use the boolean less than (<)  condition with the data going into the top slot and a constant of 8 coming out of the bottom, and the tip going to the stop function. 

 

Any help again would be appreciated!

0 Kudos
Message 9 of 25
(3,598 Views)

You probably want a Greaer than or equal to set to Compare Aggrigates (which returns false if any value is below 😎 and a not

Capture.PNG

!1.png


"Should be" isn't "Is" -Jay
Message 10 of 25
(3,579 Views)