# LabVIEW

cancel
Showing results for
Did you mean:

## Timed loop bug

I got a bug inside a timed loop! I modified a array and after a while there will be created some zeros inside the array! I attached a VI containing example code! The array seems to be ok, if I replace the timed loop with a while loop!
Message 1 of 13
(3,264 Views)

Message 2 of 13
(3,255 Views)

Strange!
Message 3 of 13
(3,252 Views)

another try..

Message 4 of 13
(3,251 Views)

## Re: Timed loop bug

Define "after a while".

Some points:

• Your use of the local variable for the graph is completely unnecessary. Use a wire. It will do the same exact thing.
• Your use of the Search 1D Array for doubles can lead to false answers. This is equivalent to doing an equality for floats, and that is not something you do on computers. If you do, you can give me another nickel in my retirement fund..
Message 5 of 13
(3,237 Views)

## Re: Timed loop bug

Thanx, but your answer has nothing to do with the bug! It's of course not the code I used. I only made a simple example for the bug!

Message 6 of 13
(3,232 Views)

double post..

Message 7 of 13
(3,232 Views)

## Re: Timed loop bug

@TPoint wrote:

Thanx, but your answer has nothing to do with the bug! It's of course not the code I used. I only made a simple example for the bug!

How do you know it has nothing to do with the bug?  Improper use of local variables can cause race conditions which lead to unexpected and inconsistent operation.  (Though in your case here, while you don't need the local variable and should be using a shift register, I don't think you have a race condition).  Also, the comparing floating point numbers can certainly lead to unexpected results.  A number is not always equal to the same number.  If you saw 1 / 3 *3, you'd think 1.  Well a computer winds up representing that results as .999999... and it won't be equal.

Does the example actually demonstrate the bug?  I ran your VI and did not see the issue of zero's in your results, but then again, I may not be looking in the correct place.  Where would we see the problem when it occurs.  (In the graph, in an array indicator, somewhere else?)  And you said after a while.  How long is that?

Message 8 of 13
(3,223 Views)

## Re: Timed loop bug

@TPoint wrote:

Thanx, but your answer has nothing to do with the bug! It's of course not the code I used. I only made a simple example for the bug!

A. I did not give you an answer. I asked you to define "after a while". I, like Ravens Fan, ran your VI and saw that the code never stopped. You seemed to have a breakpoint there to make it stop when you think this occurred, but it never stopped for me

B. You never said it wasn't the code you were using, and frankly that's irrelevant here.

C. My points were not answers. They were side-comments to point out things you may not be aware of. They are quite valid (especially the one about the floating point numbers).

Message 9 of 13
(3,217 Views)

## Re: Timed loop bug

The 'search array' is only to detect the zeros! (Thats the reason for internal for loop and the breakpoint) It means, the VI stops automatically, if a zero is detected! I used the code of the for loop inside a custom probe on different parts of the graph array and I got the zeros sometimes on X and sometimes on Y component. Sometimes the array what comes out of the shift register was different to that what comes in. In the case of the example VI i got Zeros on an other Index as I replaced in 'replace array subset'......
I tested it once again and I got zeros at an array size of 20828, but thats differential! In the screen shot you can see, that the date of plot six 01/01/1904 therefore..

Message 10 of 13
(3,211 Views)