LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

shift Register vs local Variable

Solved!
Go to solution

Hi Together,

 

I don't know if this is the right place, but one (maybe philosophical) question:

 

in one subVi of my program, I have several Cases for a specific proceeding:

WWolf78_0-1645002571451.png

 

in one Case I'm collecting data from an external device and store this in an double array

WWolf78_1-1645002634187.png

 

and in another Case I save this data in excel:

WWolf78_2-1645002686884.png

 

in all the other cases (!) I just have the lines for keeping the information

 

WWolf78_3-1645002739674.png

 

which is pretty awkward, as I have to place all the other stuff around this lines

for better readability and clear cases, which have only the relevant information I think about change all this to like to local variables:

WWolf78_4-1645002922240.png

 

 

good idea / bad Idea?

0 Kudos
Message 1 of 7
(1,235 Views)

Hi Wolf,

 


@WWolf78 wrote:

in all the other cases (!) I just have the lines for keeping the information

which is pretty awkward, as I have to place all the other stuff around this lines

 

for better readability and clear cases, which have only the relevant information I think about change all this to like to local variables:

WWolf78_4-1645002922240.png

good idea / bad Idea?


Definitely a very bad idea (IMHO)! (As I already told you here…)

 

Several comments.

  • You can set tunnels to "linked tunnel", so LabVIEW will wire them automatically for new/all cases.
  • You can bundle related stuff (like your several arrays) into a cluster to reduce the number of wires/shift registers. Use a typedefined cluster and (Un)BundleByName… (From here it's just one more step to using an OO class implementation.)
  • "Better readability" means "follow the wire(s) as they hold the data", it does NOT mean "hide data access in hidden cases because of extensive usage of local variables"…
Best regards,
GerdW


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

Hi GerdW

 

  • You can set tunnels to "linked tunnel", so LabVIEW will wire them automatically for new/all cases.

I already do this, otherwise I'd went crazy connecting the bunch of lines...

 

  • You can bundle related stuff (like your several arrays) into a cluster to reduce the number of wires/shift registers. Use a typedefined cluster and (Un)BundleByName

I've done this for several other Informations as for the MHL and CL and another loop,

anyway this is additional work as to create the Cluster, name all the items, and create the respective bundle/unbundle operations

advantage is just one line walking through all cases

 

  • "Better readability" means "follow the wire(s) as they hold the data", it does NOT mean "hide data access in hidden cases because of extensive usage of local variables"…

that's right.

It's anyhow laziness as I'd have to wire less items (and less distance),

BUT

if it is recommended / common practice (?) I'll do this

0 Kudos
Message 3 of 7
(1,215 Views)

Hi Wolf,


@WWolf78 wrote:

if it is recommended / common practice (?) I'll do this


Tell me any programming IDE/language where data copies and unrestricted data access via locals/globals is "recommended practice"…

(I'm not talking about using variables in text-based programming: in LabVIEW the wire is the variable!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(1,211 Views)

hm, got it
but when it's neither good practice nor recommended, why is it even possible?

resp, when should you use this?

0 Kudos
Message 5 of 7
(1,206 Views)
Solution
Accepted by topic author WWolf78

Hi Wolf,

 


@WWolf78 wrote:

why is it even possible?


Because there might be reasons to use locals/globals in LabVIEW.

(You can also use global variables in most text-based languages…)

 


@WWolf78 wrote:

when should you use this?


You could use locals to write/initialize values in a control.

You could use globals in a WORM (write once, read many times) approach.

 

But keep in mind:

  • Controls/indicators are used to present data to your user, they are not intended as "data buffer/storage". (In LabVIEW the wire is the variable!)
  • Locals/globals come with the risk of race conditions…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(1,194 Views)

@WWolf78 wrote:

Hi GerdW

 

  • You can bundle related stuff (like your several arrays) into a cluster to reduce the number of wires/shift registers. Use a typedefined cluster and (Un)BundleByName

I've done this for several other Informations as for the MHL and CL and another loop,

anyway this is additional work as to create the Cluster, name all the items, and create the respective bundle/unbundle operations

advantage is just one line walking through all cases


If you have some sort of Init-case you can bundle everything without a type def. Just remember that the unnamed bundle requires wires to have a name for you to see them later on if you use Unbundle by name (Unbundle shows all, and you can't hide stuff)

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(1,101 Views)