LabVIEW

cancel
Showing results for 
Search instead 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!
0 Kudos
Message 1 of 13
(3,260 Views)

Your VI did not get attached to your message.

0 Kudos
Message 2 of 13
(3,251 Views)
Strange!
0 Kudos
Message 3 of 13
(3,248 Views)

another try..

0 Kudos
Message 4 of 13
(3,247 Views)

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..
0 Kudos
Message 5 of 13
(3,233 Views)

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!

0 Kudos
Message 6 of 13
(3,228 Views)

double post..

0 Kudos
Message 7 of 13
(3,228 Views)

@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?

0 Kudos
Message 8 of 13
(3,219 Views)

 


@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).

0 Kudos
Message 9 of 13
(3,213 Views)

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..

0 Kudos
Message 10 of 13
(3,207 Views)