LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simplying my code

Curious...

Why are you using so many Globals.  Do you really need them?

RayR

0 Kudos
Message 11 of 27
(1,849 Views)
thanks altenbach,
JoeLabview, i have currently need those globals for now.
i am trying to clean up the codes. i dont want to break anything. so i have to leave them till i can get rid of them.

Best regards,
Krispiekream
0 Kudos
Message 12 of 27
(1,835 Views)

Okay..

The way I proceed to removing Globals is to first investigate where they are used.  If they are within sub-vi's, then I create terminals on the connector pane on the sub-vi and wire them directly. 

I will use Globals if they are rather static in nature, such as holding the Instrument ID (VISA).  But I do not use them to pass data between VI's.

Message 13 of 27
(1,818 Views)
okay..lets say i have this code. what can i do to keep data flowing the way it should and maintaining the same function?




http://forums.ni.com/attachments/ni/170/325172/2/untitled21.JPG





Message Edited by krispiekream on 05-20-2008 06:41 PM
Best regards,
Krispiekream
Download All
0 Kudos
Message 14 of 27
(1,793 Views)

Well, we don't see all of the code (e.g. what is in the FALSE cases?), but here are a few tips.

  • The sequence is unecessary.
  • Use a shift register for the timeout_ctr
  • Just increment the value before the comparison, the rest can start executing in parallel to it (e.g. the Q&R).
  • Where is the error out terminal. can't you wire to it instead of using a local?
  • Set the output tunnel of the [error out] to "use default if unwired" or wire it across in the other cases.

You really should attach some actual code. Debugging images is no fun at all. 😉

0 Kudos
Message 15 of 27
(1,780 Views)

Added to Altenbach's comments would be:

Can you describe what the code does?  Is it part of a loop?  How does it get called? 

The reason for asking is that you appear to use Local(s) to increment a value and Globals to store / update the boolean value.  There may be some much easier and cleaner way to accomplish the same.  But we would need to understand what this is supposed to do in order to suggest optimazation approaches.

RayR

0 Kudos
Message 16 of 27
(1,775 Views)





Message Edited by krispiekream on 05-21-2008 09:36 AM

Message Edited by krispiekream on 05-21-2008 09:39 AM
Best regards,
Krispiekream
Download All
0 Kudos
Message 17 of 27
(1,752 Views)
Hi krisoiekr...,
i´m not sure what we should do with this vi, so i removed the local variables and use shift register instead of them.
See the attachment. It should do the same as your solution.
 
Hope it helps.
Mike
0 Kudos
Message 18 of 27
(1,743 Views)
thanks mike!
i can't view 8.0 at this time.
can you save it as 7.0 or post the image for me?
thanks

Best regards,
Krispiekream
0 Kudos
Message 19 of 27
(1,733 Views)
Is this a subVI or is this this part of some bigger code?
 
You need to learn the difference between controls and indicators. Overusing local variables can easily blur that distinction!!!
For example, "error out" should probably be an indicator. It is an output of the program and not something that the operator ever should set manually.
Same with the timeout counter. It should also be an INDICATOR!
  • A control receives input from the user via the front panel.
  • An indicator displays results of the program.
  • A diagram constant is something that never changes

You can always choose the appropriate state by "right-click... change to control/indicator/constant".

Mind you representations. Your code is full of coercion dots. For example the zero in the FALSE case should be U32. Same for the "200" constant.

Anyway, we need to know how this code part fits into the rest of the program. Is there a bigger while loop around it?

What else needs access to the outputs?

Where do the inputs come from?



Message Edited by altenbach on 05-21-2008 08:46 AM
Message 20 of 27
(1,733 Views)