Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Using local variables to "clean up" diagram

Solved!
Go to solution

I have attached a photo with red circles indicating my use of local variables to "clean up" a block diagram. Would I run into any issues doing this? Can I leave this task and error unwired?

 

-Sarah

0 Kudos
Message 1 of 8
(5,209 Views)

The photo may have not attached:

0 Kudos
Message 2 of 8
(5,207 Views)
No image but using locals as a way to clean up messy programming is NOT desirable. You are just making things worse. Numerous, numerous threads on why you should minimize/eliminate the use of locals.

Have you taken any of the free tutorials?
Message 3 of 8
(5,204 Views)

Dennis, 

 

I have completed Core 1 + 2 but haven't done any tutorials beyond that. 

 

I will take out the local variables and look up those threads for further explanation. 

 

Thanks,

Sarah

0 Kudos
Message 4 of 8
(5,199 Views)
I see the image now. You probably won't have any problems except possibly with the set local but the others just seem like lazy coding, sorry to say. Also, the use of the VISA Bytes at Serial Port is generally incorrect if the instrument sends a termination character.
0 Kudos
Message 5 of 8
(5,188 Views)
Solution
Accepted by topic author sarahzig

I see some possibly really bad race conditions with your VISA Resources.  For instance, if Task Out 3 is empty (by default), it is likely that the local to read will happen before the local to write.  What this will turn into is you loosing your VISA Reference in the shift register.  Use wires.  Locals very rarely clean up your diagram.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(5,151 Views)

Consider putting all functions relating to the DAQmx task in a Action Engine.  Cleaner top level code. 

Message 7 of 8
(5,128 Views)

Thanks for the explanation - I'll take out the local variables.

 

Sarah

0 Kudos
Message 8 of 8
(5,096 Views)