LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Disable Structure - value of unset variable

I want a piece of code executed when the conditional variable is set to a random natural number. There is no other way than to use the Default tag for that as the Condition allows only for == and !=.

 

I also want this code NOT to execute when this variable is set to 0 or UNSET. Can I do that somehow? I tried comparing with FALSE, null, 0, undefined, nothing works.

 

Vit 

Thomas444_0-1629367110157.png

 

0 Kudos
Message 1 of 6
(1,364 Views)

Hi Thomas,

 


@Thomas444 wrote:

I want a piece of code executed when the conditional variable is set to a random natural number. There is no other way than to use the Default tag for that as the Condition allows only for == and !=.


Do you need to use a conditional "variable" in your use case? Especially when the conditional item can have "random" values!?

Why not use an ordinary case structure?

 


@Thomas444 wrote:

I also want this code NOT to execute when this variable is set to 0 or UNSET. Can I do that somehow? I tried comparing with FALSE, null, 0, undefined, nothing works.


What do you mean by "nothing works"? Is your code executed when you compare your conditional item with "0"?

Again: why not use an ordinary case structure?

 

Why are you using the conditional disable structure at all?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,354 Views)

The question is quite general so I didn't feel like getting into details.

 

So I have this FPGA application with different C series module types and I want to implement a piece of code only when certain modules of given type are used. It can be like 3x 9232s and 2x 9421s, up to 8 modules for cRIO 9057. I use conditional disables for counting the modules because it's quite neat (I just change it in one place and it gets implemented through the code) but I have to specify either:

  • case for constant = 1 || constant = 2 || ......... || constant = 8 (so long to fill in the dialog window and not universal by far) - implement the code,
  • case for default (when constant = 0 or constant is undefined) - do nothing,

or:

  • case for constant = 0 - do nothing,
  • case for default (when constant !=0) - implement the code.

The second approach is straightforward, but when the conditional symbol is undefined, the default case is selected here. Does the undefined symbol always fall in the default case, or does it have some value i can use to trigger such state? Basically I would like to make constant = 0 and undefined constant the same meaning.

0 Kudos
Message 3 of 6
(1,333 Views)

In general a conditional disable structure is kind of like an ifdef which tells the compiler to ignore disabled code.  In your case some interfaces to modules may not allow compilation if the modules are not present.

 

If that isn't an issue you can go with a case structure which is like a switch or if/then/else statement.


Certified LabVIEW Architect, Certified Professional Instructor
ALE Consultants

Introduction to LabVIEW FPGA for RF, Radar, and Electronic Warfare Applications
0 Kudos
Message 4 of 6
(1,327 Views)

Hi Thomas,

 


@Thomas444 wrote:

The second approach is straightforward, but when the conditional symbol is undefined, the default case is selected here. Does the undefined symbol always fall in the default case, or does it have some value i can use to trigger such state? Basically I would like to make constant = 0 and undefined constant the same meaning.


When the symbol is undefined then it's value is not "==0". So the default case of the CDS is selected…

 

What's the problem in setting the symbol to "0"?

 


@Thomas444 wrote:

The question is quite general so I didn't feel like getting into details.


It really helps to know about the reason for your question!

I understand you want to reduce fabric usage on FPGA whenever possible, and using the CDS to react on the installed modules sounds like a good idea!

That's why I was insiting on using plain case structures: on modern computers available RAM most often isn't a problem aymore…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,312 Views)

What's the problem in setting the symbol to "0"?



I just end up having bunch of conditional disable symbols which have to be set up with every target I have in my project. But I recently found out that CDSes can be set up programatically so I probably could make a script for that.

0 Kudos
Message 6 of 6
(1,293 Views)