From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange shift register initialization

Hello,

 

The breakpoint fires once program VI started, but it shouldn't.

When I control the values on comparator, indeed TOP value is grater than BOTTOM value, so breakpoint fires correctly.

But these values must be equal.

Where I've been mistaken ?

 

Thanks

 

Pavel

 

 

Shift_Register_strange_initialization.JPG

0 Kudos
Message 1 of 33
(3,567 Views)

@Pavel_47 wrote:

Hello,

 

The breakpoint fires once program VI started, but it shouldn't.

When I control the values on comparator, indeed TOP value is grater than BOTTOM value, so breakpoint fires correctly.

But these values must be equal.

Where I've been mistaken ?

 

Thanks

 

Pavel

 

 

Shift_Register_strange_initialization.JPG


Obviously it's not ever getting to the breakpoint!  Turn on highlight execution (the lightbulb) and see where all the dots go.  Besides being fun to look at, it gives valuable insight to what is going on with your code.  🙂



Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 33
(3,550 Views)
You have 8 local variables, none of which are initialized to a known state. Heaven only knows what the result of your calculation will be.

A good way to determine whether you are overusing local variables is to count up the number you use and if the result is greater than 0, you may have a problem.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 33
(3,531 Views)

Highlighting doesn't work properly in my setup: when I start VI, it do some initialization, then wait for user clicks to "START".

Unfortunytely "START" action isn't sensed by VI in highlighted mode.

 

In the meantime I've modified a little bit the VI.

Now both values on comparator are exactly the same ... but breakpoint after ">" comparator fires nevertheless.

 

Shift_Register_strange_initialization (1).JPG

0 Kudos
Message 4 of 33
(3,521 Views)

mikeporter a écrit :
You have 8 local variables, none of which are initialized to a known state. Heaven only knows what the result of your calculation will be.

A good way to determine whether you are overusing local variables is to count up the number you use and if the result is greater than 0, you may have a problem.

Mike...

Hello Mike,

 

All these variables come from controls/indicators on Front Panel, so theirs values are defined before execution (actually execution starts when user clicks on "START" button, i.e. after starting of VI)

0 Kudos
Message 5 of 33
(3,514 Views)

@Pavel_47 wrote:

Highlighting doesn't work properly in my setup: when I start VI, it do some initialization, then wait for user clicks to "START".

Unfortunytely "START" action isn't sensed by VI in highlighted mode.

 

In the meantime I've modified a little bit the VI.

Now both values on comparator are exactly the same ... but breakpoint after ">" comparator fires nevertheless.

 

Shift_Register_strange_initialization (1).JPG


If Start action isn't "sensed" and the mechanical action for the start button is set to latching, make sure that the terminal for the Start button is in the Start event. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 33
(3,496 Views)

What's the point of doing the same calculations twice and comparing them on the first iteration?  One value is never going to be greater than the other....they are always equal.  Why not initialize your shift register with 0 or +/- infinity so that you can eliminate those local variables outside the loop.  And I assume they are the same calculations since i can't read a tiny image.  Code is always better.

Capture.JPG

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 33
(3,486 Views)

I've followed your suggestion and changed "START" button action for "latched".

Now it actionned whit highlight set ON.

But unfortunately I didn't see the moment when execution riched the breakpoint (just after "Boolean Crossing PtByPt" block).

But once on breakpoint I've visualized the values before ">" comparator ... and found that they are "Not Executed".

 

So, I'm a little bit confused to understand what is happening.

 

 

Shift_Register_strange_initialization (2).JPG

0 Kudos
Message 8 of 33
(3,474 Views)

Hi Pavel,

 

but breakpoint after ">" comparator fires nevertheless.

The breakpoint will fire whenever code execution comes to this point - unless it is a conditional breakpoint.

Is it a conditional breakpoint?

 

Highlighting doesn't work properly in my setup: when I start VI, it do some initialization, then wait for user clicks to "START".

Unfortunytely "START" action isn't sensed by VI in highlighted mode.

Wrong. In highlight mode your VI behaves the same except it runs much slower…

 

Now both values on comparator are exactly the same ...

Are you sure they are the same? To the very last bit of the float?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 33
(3,465 Views)

Hello GerdW,

 

The breakpoint will fire whenever code execution comes to this point - unless it is a conditional breakpoint.

Is it a conditional breakpoint?

But it should come to this point ONLY if the TOP comparator value is grater than BOTTOM one. Isn't it ?

It's ordinary breakpoint.

 

Wrong. In highlight mode your VI behaves the same except it runs much slower…

Sure, but I was waiting for about 3 min, clicking time-to-time in "START", but execution didn't reach the location of interest.

 

Are you sure they are the same? To the very last bit of the float?

On the above post I visualized probed values ... they are the same until 5 digit after point

 

Thanks

 

Pavel

0 Kudos
Message 10 of 33
(3,455 Views)