LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Decrementing with -1

Hello!

Now we have a smaller problem but our brains seems to have vacation today :P. We want to take a constant and decrement it with 1. For every step we want to decrement the result with one and so on. When we comes to zero we want to start over again from the top. We have been playing with for-loops and the decrementing -1, while-loops and so on... we know this is quite easy for most people 😛 thank you 🙂
0 Kudos
Message 1 of 9
(3,985 Views)
hope this help...

Regards
Neona
0 Kudos
Message 2 of 9
(3,977 Views)
Hello!

Thank you for your help! We thought of something like that too... we would need the values that comes out from that indicator but outside the loop during the time the loop is running... Is there a way to do this? We tried to do it with a local variable but it did not work so good 😛 any suggestions?
0 Kudos
Message 3 of 9
(3,953 Views)
A local variable should work perefctly for a situation like this. The important thing to understand in this matter, is when a node on the block diagram is being read or written to. And the answer: as soon as it's ready and everything before it is complete. As long as both the terminal is being written to (like in Neona's example) and the local variable is being read (the code reading it should keep running), they should be synchronized. If your code stops running, however, then the local won't recieve the updates. You can use Highlight execution (the light-bulb button) to see this nicely.

___________________
Try to take over the world!
0 Kudos
Message 4 of 9
(3,945 Views)
Since the loop should always start over after reaching zero, you need a while loop because the total number of iterations is not known at the beginning. (I would recommend against the FOR-inside-WHILE loop in neona's example, because it will prevent you from stopping the VI unless the value reaches zero)

Yes, if you need the current value in another parallel loop, you can use a local variable to do so. I have atttached a small example (LabVIEW 7.0) that shows one possibility.
0 Kudos
Message 5 of 9
(3,944 Views)
Hello!

Hmm... we created a local variable outside the loop but it is not updated. It updates first when the loop stops... we have a for-loop where we count down as one suggested and then a while-loop outside this for-loop. But the local variable is outside both these loops in the next while-loop and it does not updates at the time when tje first for-loop runs...
0 Kudos
Message 6 of 9
(3,937 Views)
Hello!

The while-loop we need to use the local variable in is not parallell it is outside the loops the counts... around to say... maybe that is a problem?
0 Kudos
Message 7 of 9
(3,937 Views)
You need to have the local variable in another parellel while loop, otherwise it would only update once. If in a parallel while loop, it will keep updating as long as both loops are running in parallel.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 9
(3,916 Views)
Hello!

Thank you for your help 🙂 Now the problem is solved! Best regards!
0 Kudos
Message 9 of 9
(3,886 Views)