LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I don't understand looping and how to call variables while looping

So for my project, i need to loop this part for 10 repetitions and there is a local variable elsewhere in the block diagram that captures the value of timestamp in to run different function. I want to make a format that the timestamp in is captured 10 times and i expect 10 timestamps to be sent to the local variable but when i run, i find that only the 10th timestamp is sent. I am very new to Labview, could someone help me out.

Theeva_0-1736944618271.png

 

0 Kudos
Message 1 of 8
(453 Views)

You update the P1 timestamp 10 times, but i suspect the following code executes afterwards and reads the last updated value. If you want to "send" the value, send it to a queue and have a 2nd loop react to it. See the Help - > Find Examples and search for Simple Queue example.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(444 Views)

Hi Theeva,

 


@Theeva wrote:

i need to loop this part for 10 repetitions and there is a local variable elsewhere in the block diagram that captures the value of timestamp in to run different function.


So you should have learned from your example: Don't use locals to transfer data when it comes to "transfer all data in correct order"!

Best regards,
GerdW


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

Local variables have nothing to do with "sending". They simply contain the value of their terminal transfer buffer. "What" you read from it depends on "when".

 

You need to start with some basic tutorials.

 

Can you take a step back and show the rest of the code? If you just want all the timestamps in their order as an array, you could autoindex at the loop boundary.

 

Please show us the entire program so we can get more specific recommendations! For example your globally initialize feedback node only makes some sense if there are outer loops. Also note that you have a problem with representations.

0 Kudos
Message 4 of 8
(387 Views)

image.pngimage.png

0 Kudos
Message 5 of 8
(348 Views)

Hi Theeva,

 

you failed in showing the whole block diagram!

 

All we can say is: there are race conditions!

Best regards,
GerdW


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

For your next step of learning, you need to force yourself to not use any variables and instead learn how dataflow works. Trust the wire.

 

Attach your actual VI file.

Certified LabVIEW Architect
0 Kudos
Message 7 of 8
(331 Views)

@Theeva wrote:

(a pile of code fragment pictures)


Pictures of code fragments are useless for troubleshooting.. We cannot see what's in the other cases and what's outside the visible area or the overall architecture. We cannot tell what happens when and in what order.

 

In this case there is serious "code smell" and we can tell that you need to start with some basic tutorials, then implement a good architecture (state machine?). I am sure that 95%-100% of your local variables are unnecessary. Make sure that array diagram constants show the first invalid element or a scrollbar so their size is obvious. For example your "temperature" string array could just be a scalar, right?

0 Kudos
Message 8 of 8
(305 Views)