LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simple C code loop into LabVIEW code

my applicaion needs to implement the folowing simple block of C code:

while (not terminated)
{
...
...
if (count>10)
{
manipulate some arrays
update graph
} if
} while

The while loop contains data acquisition code. I want the graph output to wait until there have been a user defined number of cycles. the problem I'm having is how to setup the if statement within the while loop.

I'm sure there is a simple solution to this
!
0 Kudos
Message 1 of 4
(2,850 Views)
Perhaps you can use the cis (advanced-> code interface; then right click and choose create c-code)

-Marc-
0 Kudos
Message 2 of 4
(2,850 Views)
hi datalog,
In labview you can implement the while and if and for loops of C by making use of the while,for and case loops.For the type of function you want to right you can make use of a nested while loop and case structures with the loops controlled by the condition you want it to check for.Just see a few examples of loops in labview examples it shall help you in your code.if you yet have any problem ,i shall send you a example code.
vicky
0 Kudos
Message 3 of 4
(2,850 Views)
Your psuedo code indicates that you want to do nothing for the first n cycles and then do something every time after that. If that's all you want, just put a greater than comparison operator wired to the iteration terminal of a while loop, wire the other input to a numeric control, and wire the output to a case statement. If what you want is to do something just every nth cycle, it's easy with either a shift register or the Quotient and Remainder function. Using the latter, wire it
s x terminal to the iteration terminal of a while loop. The y input is wired to a numeric control. The remainder output (x-y*floor(x/y)) will cycle 0,1,2..n-1 where n is the value of the numeric control. Do a comparison on the output and wire it to a case statement. I've a
ttached a picture that shows both solutions.
0 Kudos
Message 4 of 4
(2,850 Views)