LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to find out what a program stops working properly

I have written a VI that will generate statistics from an oval image ROI of any size and shape.  It works most of the time and then goes south.  I built a sample VI (attached) that illustrates what is happening.

 

Pull up the VI and an image will load.  Use the mouse to generate the oval ROI and then hit the Show Circle button.  The VI will move through the VI and, in this version, it will count the number of pixels.  I also paint the ROI to make sure that my equation is moving through the ROI properly.  Notice the "XPOS" value,  when it works this value will be the x pixel location that is being counted in that interation and is calculated from my equation --- when it goes south, this number get very large and is bad. (the x pixel can only be as large as 384 or the pixel width of the loaded image)

 

While remaining in the program, redraw a new ROI and hit the show circle again.  It may go bad the first time or it may take 10 times but that x value will get very large and screw the thing up.  It is almost like there is a memory leak of some type or some variable is getting hosed randomly.  I am looking for any suggestion for why this would happen and how can I avoid it. 

 

As a side note...... I have worked this problem for about two weeks and I find no pattern as to when it goes bad.  I do have a gut feeling it has something to do with drawing the ROI although the bounding box of the circle, as shown on screen, always appears to be correct.

 

Please help

0 Kudos
Message 1 of 7
(2,916 Views)

Hi irfocus,

 

Please check your logic.  When this error occurs, it is becuase you have passed NaN (not a number) out of the formula node, which then causes mayhem down the rest of the VI.

Stephen Meserve
National Instruments
0 Kudos
Message 2 of 7
(2,878 Views)

Yes, I understand that however, I don't see how or why I am passing that bad value out of the node.  That is why I show the bounding rectangle values for the ellipse......  I wanted to make sure they are right each time the output value goes bad. 

 

It works much of the time and the input values always appear to be good.  What I can't figure out is what is going bad.  If I were dividing by zero in the node it could be explained however,  again, the input values appear to be good, and as long as they are, this node should be calculating correctly each time.    

0 Kudos
Message 3 of 7
(2,854 Views)

As a follow-up to my reply yesterday regarding this problem.  As suggested, I reviewed my logic and I don't believe there is a problem (at least obvious).  As evidened by the pixel paint ability I stuck in the VI,  the calculated x and y pixel location within the ellipse ROI is seems to be calculated properly, which also suggests that the input variables to my equation node are correct.

 

Again, the frustrating part is that this function works, and then it doesn't, and then it does, without any obvious pattern to suggest why.  I still have to wonder if the redrawing of the ROI within Labview is not scrwing with memory even though the ROI descritptor appaears to be correct.

 

 

0 Kudos
Message 4 of 7
(2,829 Views)

Hi irfocus,

 

Have you taken your formula and fed through every possible value that you could and seen the result?   You might try taking the formula section and putting it in a for or while loop that increments the values you send through and recording the results.  At some point, it appears, you are either overflowing the number of bits available to you or you are dividing by zero, or some other invalid mathematical operation.

Stephen Meserve
National Instruments
0 Kudos
Message 5 of 7
(2,819 Views)

Stephen,

 

Can you be a bit more detailed in what you are suggesting.  I have exhausted everything I know how to check. 

 

Note again, I calculate the information based on the ROI bounding rectangle.  Even when I calculate the info at the precise same ellipse size and position (same input to the node),  it works and then it doesn't with no apparent change to the input variables.  It would make sense that I am overflowing something but I don't know how to check this out or how to avoid it. 

 

I have tested to see if I am dividing by zero at any point and I can't find that I am. 

0 Kudos
Message 6 of 7
(2,814 Views)

Stephen,

 

As a final follow-up to the problem.

 

As of right now it appears I have found the problem.  What was happening is something that you should not expect to happen.  Labview apparently rounds off in ways not expected.  In very unique situations,  the round off error generated in a calculated value forced a square root to be taken of a negative number.  It only happened when a situation came up where I was trying to divide a number by the same number (one gotten from the ROI bounding rectangle and the other acquired by the math)

 

The disadvantge of Labview is that you can't really see what is going on with the math and have to rely on Labview to do thing in a certain way.......leason learned.

 

Anyway,  I simply put a check in the math node for this condition and it seems to have fixed the problem.

 

 

0 Kudos
Message 7 of 7
(2,799 Views)