LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to sample a sensor voltage and record location (with delay)

Solved!
Go to solution

Hi all, 

Wondering if someone could help me here, i'm still quite a Labview novice... Basically I have a sub vi which I created that is feeding in analogue sensor values into my main vi in parallel with another sub vi, which is feeding in gps location in a combined latitude and longitude string. What I am looking to do is to record the locations in a visible array on the front panel when the acceleration is over a set amount (1g).

 

The issue I have is that I only wish to take down one location string for each time the acceleration is exceeded, so I would like to implement some sort of delay so that when the acceleration increases beyond 1g, the location is recorded and then the program waits for a given time before taking the next location (I only want one location recorded per event). But I cannot work out how to do this. The only way I can think of achieving it will give me several position values each time the acceleration passes the limit.

 

Any help would be greatly appreciated.

 

Thanks

0 Kudos
Message 1 of 8
(2,537 Views)

Hi w.,

 

some pseudo code:

IF accel>1 AND TimeIsElapsed THEN
   store data in array
   start ElapsedTime
ENDIF

 Simple rule: provide just text and you will get just text. Provide a VI and you may get back a VI...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(2,532 Views)

Ok, sorry about that. I have attached the vi and hopefully you will understand what is going on. Essentially the while loop to the right hand side is what I have been given and the part I have worked on is in the left hand while loop. So I have the latitude and longitude string which is called "concatenated string" and my accelerometer readings come from the sub vi called Accelerometer. I currently have boolean greater than set for if>1.

 

The really hard part that I am struggling with is getting the latitude and longitude string to write accross to the array on the right hand while loop called "Marker location array" as a new indexed value and to do this only when the acceleration is above my set value.

 

Thanks again for any help and hopefully I have uploaded it properly!

0 Kudos
Message 3 of 8
(2,526 Views)
Solution
Accepted by topic author w.driscoll90

Hi w.,

 

easiest solution would be to read your "concat string" using a local variable in the right event loop. Build up that "marker array" using a shift register (as usual)...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 8
(2,507 Views)

Thank you for your help, I am still struggling with the shift register part but am almost there!

 

0 Kudos
Message 5 of 8
(2,471 Views)

Rather than using a delay between updates of the locations, you can monitor the transitions from below the acceleration threshold to above. Then you only get one update each time the acceleration increases to greater than 1, no matter how long it remains high.  This can be done with a shift rgister and the boolean Implies function.

 

Also, a queue is the preferred way to transfer data between parallel loops. Look at the Producer/Consumer Design Pattern for more information.

 

Here is a partial modification of your VI showing these concepts.

 

Lynn

0 Kudos
Message 6 of 8
(2,452 Views)

Thanks for your help and some really useful advice. It is now working with one location in the array at a time, however when I press refresh it seems to overwrite the first location with the new location (or empty if currently below the threshold), whereas I would like it to add the new location as a new index in the array. Do you know how I could acheive this please? I aim to get rid of the refresh button also and make this loop automatically run and update.

 

Regards,

 

Will

 

(latest vi attached, I need to update some code to subvi's as you suggested later)

0 Kudos
Message 7 of 8
(2,443 Views)

Will,

 

1. You need a shift regsiter. This will retain data from one iteration to the next.

2. If you want to get rid of the Refresh button, just change the Refresh event case to the Timeout case and set the timeout value to the period at which you want to update the displays.  In this case you really do not need the event structure at all.  Replace the Flush Queue with Dequeue. Set the timeout on Dequeue to the maximum time you want to wait for it to respond to the System Stop Button.  Then the Dequeue will update the displays immediately every time the acceleration threshold is crossed.

 

Lynn

0 Kudos
Message 8 of 8
(2,430 Views)