From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question related to timing

Solved!
Go to solution

Hi everyone, I would really appreaciate it if you could help me with this small issue. I have to carry out a test of one system , to make this test I need to use values of one array each certain of time.

Basically its a table , first column each row its the time when i have to use the values, and the rest of columns are the values for that specific time.  

Example

7:00  4   5

8:46  10  6

9:03   3   8

etc

So I am thinking of using a timer that counts each 30 seconds, and a function to gets the hour and each 30 seconds check the array and if the current time and the value match i get the value and i do the operations. First if you think an easier way of doing this it will be great. Secondly I am not able to use the function "Search 1D array" in order to compare the value I got "in the get time " with the position of the array since it has a red colour and "Search 1D array does not allow me to introduce that kind of data " ... any advice ?? many thanks !!

0 Kudos
Message 1 of 9
(2,598 Views)
Solution
Accepted by topic author Jalatruken

Hi Jalatruken,

 

any advice ??

LabVIEW can handle timestamps, either as absolute timestamps or as relative time.

I would convert those string timestamps into a numeric value for easier handling in your statemachine!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(2,586 Views)

What else does the program need to do? At any time, you can calculate the time to the next action in ms and place it into the timeout of an event structure (via shift register). Redo whenever one of the other events fires (simple example). This avoids polling the time.

A simple state machine should suffice unless a test can take a long time.

 

What is a "red color". Are you talking about a coercion dot? It always helps to attach actual code. What exactly did you wire to where?

Message 3 of 9
(2,538 Views)

Thanks for your answer. May i ask you a really easy question, if I have a module that need to carry out an equation as you see, the problem is , if the value i get doesnt meet the condition i need to carry out the equation again but starting the Q from the new value. So I am not sure how to keep the value I get from the Q and keep reusing it until i get the result of the loop and i finish this loop. So i would need the value to update and keep reusing it... any idea please ?

 

 

sandra.png

0 Kudos
Message 4 of 9
(2,515 Views)

@Jalatruken wrote:

So i would need the value to update and keep reusing it... any idea please ?


Use a Shift Register.


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 5 of 9
(2,510 Views)

I am so sorry for asking you again but it is a question related to your previous answer, you told me to use a shift, 

but let me explain my current situation to you. I have one equation block and in order to enter to that equation block i need to meet a condition so I added a true/false structure, so I need the value of the Q that I get in a previous iteration of the equation I need to reuse it again until the result of the equation meets a condition. Therefore, I would need to enter in true/ case a shift that (I am not allowed to do that ) and I would need to enter the update value of the sensors for the new iteration.  So basically its a equation that is running , an for each iteration i need the previous value i got plus the new values i got from the sensors , as long as these new values meet the condition. 

Please any help ??update.png

0 Kudos
Message 6 of 9
(2,475 Views)

You seem to have a complete mess in your data flow.  So I recommend you completely rearchitect what you have into a State Machine.  But before you write ANY more code, WRITE down the exact process you need your data and application need to do.  You will notice the states develop.  Then you can program the State Machine pretty easily.


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 7 of 9
(2,462 Views)

sorry but how can i programme that ? I think you havent answered to my question you just say i need to tidy everything, I completly agree.  But Could you please tell me  how I can manage to introduce the result of the equation and the new iteration of the values from the sensors again in a true case. Is there any way of keeping the result in avariable like normal programming and use it from that point ? I have been looking for that but I only get information about shift register that i think i cant use it here...

0 Kudos
Message 8 of 9
(2,458 Views)

Hi jalatruken,

 

 Is there any way of keeping the result in avariable like normal programming 

Learn about DATAFLOW: "variables" are wires in LabVIEW. Use shift registers to store data for next iteration.

Btw what is "normal" programming? Is LabVIEW "unnormal" programming?

Best regards,
GerdW


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