Community Nugget 02/05/07

This week we are going to have some fun with dials.
A dial can be a very useful thing. You pop one on your front panel...
and you're ready to display your data in a nice way.
However, there can be much more to dials than that.
Let's start by placing the cursor over either end of the scale. You should see the rotate icon -
Clicking and dragging will now allow you to play with the scale. Grabbing at the low end value will rotate the dial, as seen on the left side of the image below. Grabbing the high end value allows you to change the shape of the scale, as seen on the right side.
So with very little effort we've created a dial which looks different and can make our application more interesting.
But wait, there's more. By right clicking the dial and selecting "Text Labels", you can have your scale made up of text labels. You can edit these labels by right clicking the dial after changing to text mode.
This could be useful for any number of things, like compasses or other dials with labels and can be done with other numeric controls, like slides and meters. You could use a slide, for instance, to make a single-selection control, like radio buttons.
This is not all. There are other things you can do, like making the ramp visible or making the labels appear on the outer part of the control instead of the inner one or adding needles to the dial, not to mention the things you can do with control customizations. I suggest you go and play.
P.S. These are all just simple examples. You can make your application look much better and more interesting by customizing controls and playing with all kinds of options.
For a list of past nuggets, see here.
Try to take over the world!
Attachments:
TextDial.PNG ‏6 KB

Nice tips!  I only just learned some of those things a few weeks ago when I posed a very similar question on the LAVA forums.  Specifically, by placing the cursor at the "Max" end of the scale, you can drag it around until it coincides with the "Min" end.  The usefulness is for displaying the position of a rotary encoder on a spinning shaft.  Now that I know how to remove the gap between 360 and 0 points, it's very easy to indicate a spinning shaft.  I just read the (scaled) encoder angle out of DAQmx, perform a modulus with 360 deg, and wire to the guage.  Now the needle spins around continuously, just like the shaft it indicates.
BTW, I haven't found out how to control the amount that the whole dial gets rotated.  I would typically want my 0 position to be at either N,W,E, or W but I've had to rely on touch to try to get it there by mouse alone.  I didn't see a setting when I right-clicked for the properties pages.  (Admittedly, I haven't yet scoured all the object properties using a block diagram property node.)
-Kevin P.

Similar Messages

  • Community Nugget 2-19-2007 "Stacked Sequence Exterminator"

    I am sure everyone with even casual familiarity of LabVIEW has run across older (or newer) code that is just peppered with ...
    Stacked Sequences from Hell.
    Stacked sequences (especially the one's containing sequence locals) are the hallmarks of confusing, unreadable and unmaintainable code. Data flows in all directions (mostly right-to-left), a large percentage of code is hidden at any given time, and it is almost impossible to debug and follow what going on. Often there is clear data dependency (or execution order does not matter), so the sequence serves no purpose. Better programmers don't use stacked sequences at all and even keep flat sequences at a minimum.
    Here is an example:
    Since the code seems to work "sort of", and trying to rewire things manually will probably lead to accidental errors, we have no choice than to leave things in place...
    ... or do we???
    If we try to right-click on the sequence, we can only remove individual frames, breaking everything in the process. No go! A dead end!  Sigh!
    But let's not give up just now.... We can easily convert the stacked sequence to a flat sequence, so lets do that as a first step:
    At this point, we can remove the flat sequence and all connections remain in place. Now we can just cleanup the elements and wires and everything look much better. Ahhh!!!
    In summary:
    An easy two-step procedure allows us to exterminate unnecessary stacked sequences without any danger of breaking the code. This method should lower the fear to remove these monstrosities. Try it today!
    This is a Community Nugget. If you want to contribute, please sign up here: http://forums.ni.com/ni/board/message?board.id=BreakPoint&message.id=3379#M3379
    Message Edited by altenbach on 02-18-2007 10:43 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SeqToFlat.gif ‏15 KB
    SeqStackedA.gif ‏10 KB
    CannotRemove.gif ‏12 KB

    Tomi,
    Aren't you asking for a good reason to use a "bad" construct?
    Your suggested code construct would look like this.
    After wondering how to make it faster, you would concider this.
    But the revised version is not possible with a stacked seq. With a State Diagram you have a lot more flexibility, and you have it now.
    Now don't get me started because the next thing you know I will be talking about the SDE* and this thread is about exterminating Stacked Sequences..
    Wait, I think I just did.
    Ben
    * With a State Diagram you have a lot more flexibility, and you have it now. If you use the SDE the graphic documentaiton comes along for the ride.
    Message Edited by Ben on 02-19-2007 07:59 PM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Stacked Seq.JPG ‏20 KB
    Stacked Seq Rev1.JPG ‏23 KB

  • Community Nugget 05/27/2009

    On occasion, you may wish to measure the amount of time a certain piece of code takes to execute.
    What many people do is something like one of these options:
    But this annoying to rewrite every time. If you're good, you probably have a merge VI or use VIs such as the OpenG VIs shown here to save some time on writing this code.
    Well, there is a faster way:
    The timed sequence has an output terminal which tells you how long it takes to execute. You can simply drop one and select that terminal.
    Caveats:
    I believe they're only available on Windows and RT.
    They take too much space (but then, so does the alternative).
    If you're running your code in parallel with other code (which you should not be doing), they might get higher priority, thus skewing the results. I don't know enough about this to give a good answer.
    When you drop one, it has terminals on the inside. You have to select to hide them if you don't want them.
    For a list of past nuggets, see here.
    Try to take over the world!

    In the first pic (flat
    sequence), the inputs of the substract-prim needs to be swapped (as in
    the code using OpenG)
    Actually,
    in both cases the earlier time is correctly substracted from the later
    time. It's just arranged differently (and I agree it can be confusing.
    Another reason to do this, although personally I don't time my code very
    often, so I don't actually use this).
    Sequences always make me nervous...
    So I prefer negative times for two reasons:
    * Something odd is on my BD
    * Rewind the time ASAP before the moment I dropped the sequence
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • An increase in community nuggets!

    Hi Everyone,
    On the LabVIEW board I've noticed we've got a number of new community nuggets!  I think this is great and I wonder if there's something I can do to help. I was thinking about taking turns linking to the nuggets via the announcements. Thoughts?
    Thanks!
    Laura

    Darin.K wrote:
    Kidding aside, if there were any way to make Kudos counts more accessible/sortable/searchable that would go much, much farther in sifting posts than an announcement.  If you could search for say a user's posts on the LV board with 4+ Kudos you are bound to find some true nuggets.  Trust me, I get that info the hard way and it is worth it.  (Enough beating that dead horse, for now).
    Ditto that!
    Note: Please take off your "moderator-keep-the-hit-count-high" hat for a second.
    Speaking from ove tens years of watching this forum...
    The high post count and traffic is both a curse and a blessing. The high traffic keeps it interesting and lively. There are many very insightful posts that buble up to beat back the question flow. But with the flood of info it can be challenging to sepearte the floatsum from the jetsum (I'll bet that I had to spell at lest one of those words wrong).
    Similar to a bear swiping at salmon as they swim past, the good or bad can be picked out one by one as they pass by.
    So as long as I stand on the bank and keep my eye on the information flow, I can goolbe up even the smallest nuggets.
    But trying to catch-up!
    I used to be able to do it back in the early days of the forums but not anymore. Too much info too fast and there are precious few clues to even attempt it.
    The best clues end up being the Kudos.
    Threads with high Kudos counts either indicate a "golden nugget hidden at the bottom of a pile of fluff"* or the gang has found a worthless thread to exploit. Both of which I want to read.
    Another approach still depends on the Kudos and that is to check out who is the Kudos leader for the day or week. if a name shows up that I don't expect I can that person down to see what earned them their new found fame or I look for a frequently flyer with higher than normal counts.
    So... getting to the point...
    maybe the default should be "weeK' instead of "Month".
    Another idea... that would require help from the web-team...
    How about a "post of the week" "month" poll where we can nomimate and vote for the top or three posts?
    Those polls/and supporting thread could serve as index to the top posts and allow for catch-up when we return to the forum after a period of time.
    Ben
    * First use of the word Nugget in connection with a choice piece of LV info.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Community Nugget Series: Applicatio​n Developmen​t- Installmen​t 1

    Installment 1: Code by intention and basic code components
    In
    this Nugget series we will discuss application development, the
    different ways we use to access data and information, develop a GUI that
    has Controls, Indicators and other front panel objects accessable from
    sub.vi's in multiple ways and explore a software developers approach to
    LabVIEW without OO but exposing OO concepts. I'll be starting with
    basics and moving to a real-world app designed specifically for Test
    Automation.  Many of the concepts have wide ranging application but as
    this is my first "Nugget" and "Series" I'll chose to speak from my
    strengths.  I hope you all forgive me.
    So lets show how to start:  I do it thusly
    NOTE:
    The vi hasn't even been saved yet!  The FP and BD are blank (OK - Use a
    template if you want to save time but for this demo I'm starting from
    scratch)
    This is where software starts, with the end
    user(s) firmly in mind!  <Sea Story> I grew up as an Electronics
    Technician.  One day a test instrument rep demo'd a new o'scope with
    advanced math functions.  We were impressed with the capabitities -
    untill it took 5+ minutes to perform the operations.  Automate that!
    [prompt user "please wait while device X does some math.  Ensure
    sliptick oil resivour remains above "critical.""]   We called it "Same
    Day Display."  The instrument MFG did not think about the end uses for
    the product when archetecting the system.  <
    Let's not do that here.  
    Overall Achietecture: 4 main interlocking Queued P-C loop vi's
    defined as: (If I may borrow from a business case to aid visualization)
    Corporate Communications ( CC or GUI):
    Executive:
    Operations:
    Accounting:
    Each of these loops Consumes exactly 1 Queued loop:
    1:
    CC is primarrilly an Event Loop. After initialization it responds to FP
    events.  These events can be caused by direct user action or by
    indirect actions when something in the application generates an event
    the GUI needs to respond to. It produces the "Executive" Queue and may
    generate events.  It keeps the user informed and happy.   It is the
    primary abstraction layer between the developer and the user.  If the
    user can do it CC needs to respond - If the developer expects the user
    to do something it Must be intuitive or explained by Tip Stips and / or
    on screen instructions.
    2: Executive is a QSM
    (Queued State Machine) it consumes the "Executive" Queue, generates the
    "Operations queue, and may generate events for CC.  This is the main
    abstraction layer between the developer and the application
    enviornment.  In this demo we will perform "Tests" defined as a sequence
    of things do much like the tasks your manager asks you to take to
    acomplish an objective.  Its the manager scheduling how when and what to
    do and has a really great Admin department that knows the business,
    what can be done by the Ops dept and has a list of activities that
    should be performed to satisfy the customers (yep! sequence files!)
    We'll get to those in another nugget in the series!
    3:
    Operations is another QSM it consumes the "Operations"
    Queue, generates the "Accounting" queue, and may generate events for CC
    .  This is the main abstraction layer between the developer and the
    system components or HAL (Hardware Abstraction Layer).  All interaction
    between the application and other resources (except the file system and
    KVM) takes place here.  Again- we'll save that for another nugget.
    4:
    Accounting is another QSM it consumes the "Accounting"
    Queue, generates "Executive" queue, and may generate events for CC . 
    Its job is to let the Executive know what the result of the operations
    are so managemant can make an informed desicion on what to do next. And
    it files reports in whatever format the Admin assistant's policy says to
    do it in.
    Each of these four main functions exist in all applications and all LabVIEW code.  Here is CC GUI A.vi after saving 
    the
    GUI responds to user clicks of "stop"(Tip Strip Val ="Press to stop
    this vi ") and the vi changes state on the next loop iteration.
    Executive
    functions are encapsulated in the while loop itself Management is
    simple: "Unless the last operation was True do the same thing again" (and the constant 10 is our admin assistant!!!! change it and the app behaves different)
    Operations
    "list of things the vi knows how to do" is limited to Update i, Wait
    (n)mSec and (AN,D not then, no data dependancy so we are multitasking!)
    read Stop
    Accounting is in the condition terminal reporting the value of
    stop- and we chose not to report anything- could have reported Array of
    Stop, Last i, or any of the values we see either to the FP, any file
    whatever!  just illustrating a point.
    Our requirements a a bit more detailed and we'll get back to the GUI next nugget:GUI FP object encapsulation.
    Jeff

    F. Schubert wrote:
    Thanks for this nugget. The business case model looks interesting. I'm looking forward to see how this will evolve.
    As a side note, I always like graphical sketches. So the basic idea of the interaction between the business entities could be drawn using boxes and arrows.
    Felix
    As ususal you and I are on the same page.
    These images ...
    and
    appear im the documents I posted in this thread where I talked about doing the design first (consistancy).
    The high level organizational, interaction diagrams are what I try to sketch up mentally during kick-off meetings. I use a variety of methods to get the information I need for these diagrams depending on what I know going in and the nature of the customer but... I don't let the meeting end until i have a picture tht models a system that meet the neeeds.
    The diagrams doc what the customer wants, splits up the work into clean concise chunks, establishes responsibilities, needs, and the chararcter of each. In short they go a long way toward defining the design.
    And for those apps you only up-date every three or four years...
    There ain't nothing like those diagrams to gt you back into the same frame of mind you where when you designed it.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Community Nugget 4/08/2007 Action Engines

    Action Engines, What are They?
    “An action engine is Ben's term for a functional global which includes extra actions other than just holding the data.”
     (tst , 03-13-2007 01:18 PM)
    In a nut shell tst has nailed it except for the “Ben’s term” part. I was originally exposed to the term "Action Engine"
    by reading the book ""LabVIEW Applications Development A Course on Advanced LabVIEW Programming Techniques*”.  But
    before I get into details of the Action Engine (AE), I will attempt to clarify some terminology.
    Functional Globals
    Functional Globals (FG) are VIs that are functionally equivalent to LabVIEW globals. Functional Globals store
    information. You can read them or write them and that is it. No fancy stuff. Functional Globals are also referred to as
    LV2 globals because LV2 did not have globals but it did support Un-initialized Shift Registers (USRs). The USR is the
    entity that stores the information.
    USR.jpg
    USR’s
    Shift Registers (SR) come in two varieties “Initialized” and “un-initialized”. The presence or absence of a wire
    feeding the SR from outside the loop distinguishes how LabVIEW will implement the SR. If there is NO wire feeding a
    shift register (A), then the SR is not initialized. This is called an “Un-Initialized Shift Register”. The USR variety
    is implemented as static buffer that is re-used from call to call. The values written to the USR in and earlier call
    persist for access (B) in latter calls**. A Functional Global exploits this behavior by implementing two methods of
    interacting with the contents of the USR.
    Functional Global.JPG
    In the “Write” action (not shown) the value of “Numeric in” is placed in the USR. In the “Read” action the contents of
    the USR are returned via Numeric out.
    Action Engines
    An Action Engine (AE) can be thought of as a machine (Engine) that performs some useful task (action) often on
    something (typically but not limited to data in a USR). Functional Globals are very specific type of Action Engine.
    They have two actions “Write” and “Read”. They operate on the data stored in the USR either by replacing or using the
    contents of the USR. So AE’s are a superset of Functional Globals. In many documents the terms AE and FG are
    interchangeable. A recent poll on LAVA has indicated that Functional Global is the most popular term. Since this Nugget
    was prompted by answering the question “what is an AE?” in the remainder of this document you will find that I will
    generally use the term AE.
    Do What to What?
    AE design revolves around the ways the shared resource must be accessed manipulated or monitored. In a Functional
    Global, the actions “Write” and “Read” are appropriate. That is not necessarily the case for AEs. AEs can have entirely
    different set of actions depending on the interaction requirements for the information stored in the USR. A short list
    follows.
     A Configuration AE could allow for multiple processes to share a single copy of the system configuration (in a USR) by
    providing actions like “Set Device ID”, Set Device ON-Line…
    A hardware device can be realized as an AE that presents actions appropriate to the physical phenomenon being measured
    or controlled.
    A DO Port Controller AE could store a reference to the physical device in one SR and the port status in another SR and
    have action like: Set Main Motor On”, “E-Stop”, …
    An Instrument can be implemented to store the device name and settings with actions like “Set Input ON” “Auto-Scale Y”
    and “Get Trace”,…
    Screen Stacks can be implemented by using control references in one USR and maintain a screen view stack in another
    then implementing actions like “Set Config Screen”, “Set Login Screen”, “Back”…
    Users can be managed using an AE with action such as “Add New User” “Set Password”, “Disable User”…
    The list goes on and is limited only by our imagination. Here is an example that shows how a running average can be
    maintained.
    Running_Average_Example.jpg
    Running Average Example
    The Running Average Example shown above shows how a running average can be maintained using an AE. The AE is
    initialized before the While Loop executes. On each iteration of the loop the simulated measurement value (random
    number) is used to update the history of all measurements (Add Number(s)) and the mean is calculated (Calc Mean).
    Please note that although the buffer of all measurements is affected in every step of this example, the buffer (USR in
    the sub-VI) contents are never part of this VI’s diagram. Since the history is stored in the sub-VI, the history can be
    acted on from more than one thread as shown below.
    Parallel_Loops.jpg
    In the parallel Loops Example the history is initialized and then two loops run in parallel with one updating the
    history and the other plotting the average. Since the History resides inside the USR of the sub-VI the two while loops
    are effectively sharing the same block of memory, the block used to store the USR. The Sub-VI was implemented as shown
    in the following sequence of images.
    Init.jpg
    As was the case with Functional Globals, the actions are implemented as a type def’d enum***** driven case structure.
    Appropriate code is present in each case to realize the intended actions. In the “Init” case, contents of “Array in”
    are used to initialize the history. In our example above we did not pass an initial array value. Therefore the “Init”
    resets the history (cleared the array).
    Add Num.JPG
    The operation of the AE when the “Add Number(s)” action is called varies depending on its usage. If the caller passes a
    non-empty array, it is appended to the array. Alternatively, passing a value via the Numeric in” control, and leaving
    the “Array in” un-wired adds a single element to the history. We used the Numeric In input so we were continually
    building our history one value at a time.
    Calc_Mean.JPG
    When the “Calc Mean” action is invoked, the average is calculated and returned.
    This Nugget is continued in the next post
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Solved!
    Go to Solution.

    Nugget continued
    The Traffic Cop Behind the Scenes
    A detail I have not mentioned up until now is that AEs should be implemented as VIs that are not reentrant***. VIs that are not reentrant can only be executing in one context at a time. LabVIEW will ensure that if there is ever a situation were two contexts are attempting to act on the same AE at the same time, LabVIEW will schedule the first and the subsequent will wait until the first call completes. This is similar to a traffic cop preventing more than one vehicle from entering an intersection at the same time. The Traffic Cop is illustrated in the following timing diagram were we look at how the processing of two threads is affected by using a single AE.
    Execution_Timeline.JPG
    In the figure above the processing time of two processes “P1” and “P2” are illustrated by a red or blue solid arrow respectively. In the parallel loops example shown earlier, P1 could be the “Calc Mean” loop and P2 could be the “Add Number(s)” loop.
     t0 - t1
    Both processes are executable and run their assigned tasks. Neither process is accessing the AE.
    t1 – t2
    P2 continues to run while P1 calls the AE. Since the AE is idle it is available to run so P1 continues execution running inside the AE until all work inside the AE completes. The dotted arrow shows that the thread for P1 is executing in the data space allocated for the AE.
    t2 –t3
    At t2 the AE terminates and both process run as in t0 – t1.
    t3 – t4
    This time segment is similar to t1 – t2 with P2 running in the AE.
    t4 – t5
    Similar to t2 – t3 the AE terminates and both process run.
    t5 – t6
    Similar to t1 – t2. P1 take control of the AE.
    t6 - t7
    At t6 P2 attempts to call the AE. Since the AE is not idle it is not available to run. P2 is placed in a resource wait state (it is NOT running) waiting for the resource to become available. The dotted horizontal arrow indicates the process is not executing.
    t7 –t8
    At t7 the call of the AE by P1 that started at t5 completes and P1 continues to execute outside of the AE. When the call by P1 completes the AE becomes available. The process P2 is marked as executable. The scheduler includes P2 in its executable threads and the AE is available. P2 then executes inside the AE until the call completes.
    The Beauty of the AE
    This behavior of a non-reentrant VI is a wonderful feature we can exploit to eliminate race conditions. Race conditions are the nemesis of many a developer. In hardware this was solved with clocked enabled logic. In LV we solve race conditions with Queues, Semaphores, Rendezvous, Occurrences, and Action Engines!AEs can eliminate race conditions when all operations involving updates of the data stored in the USR are done INSIDE the AE. A very simple illustration of how the encapsulation of USR manipulation is shown in the following set of examples.
    Port_With_Global.jpg
    This VI is intended to demonstrate how two bits of an eight-bit port can be used to control the running state of two pumps. To illustrate the control process, one pump will be set running at start-up and then every half second the state of both pumps will be toggled to simulate switching of the supply. This example uses globals and fails miserably.
    Port_With_Global.jpg
    In this example we start out by initializing a global variable so that bit “1” (zero based) is the only bit set in an array of eight bits. This turns on Pump 2 to start. Then the “Port Update” and a “State Change” loops run in parallel. In the “Port Update” loop the state of the port is read from the global and used to update the GUI.
    In the “State Change” loop, the port status is read and the first Boolean is inverted before being written back to the global. Similarly for the second Boolean. Since the read of the globals both occur before the subsequent data processing, one of the threads will be processing old data.
    Port_With_Action_Engine.jpg
    The Action Engine version codes up the same way as the global version but now all of the data manipulation of the port states are encapsulated in the Action Engine  “Port Controller”. This encapsulation ensures all operations involving the data in the USR are forced to happen sequentially even though we did not have to implement any code to achieve this affect.
    The key point to take away from this example is a shared resource (the port status in the case) when implemented as AEs come with resource contention resolution built in provided that all manipulation of the shared resource takes place inside the AE.
    Action Engines to the rescue!
    Action Engines are not a replacement for Queues, Rendezvous and the other synchronization techniques. They are typically called for when your design dictates that a single resource must be shared by more than one parallel process and none of the LabVIEW provided techniques are sufficient. They require a design of their own to ensure they work correctly. They also have to be developed and supported.
    This Nugget is continued in the next post
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Community Nugget 5-Mar-2007

    Type Definitions Let You See Your Application in a Different Way
    “THE ESSENCE OF TYPE DEFINITIONS IS THAT IF THE TYPE DEFINITION IS CHANGED ALL "MEMBERS" WILL CHANGE THE SAME WAY.” (Albert Geven LabVIEW Champion )
    Type definitions are a wonderful yet under utilized feature of LabVIEW. They allow you to manage the data types of your application in controlled manner.
    Type_Defs.png
     In large applications they can save you hours of work. I have had the opportunity to work on large applications developed without type definitions. These opportunities are seldom quick and easy to change. I have found it to be well worth the time and effort (both of which were considerable) to introduce type definitions as the first step in modifying an existing application. If your application has more than one sub-VI, your application will probably benefit from the use of type definitions.
    Type definitions (type def’s) are implemented in LabVIEW as custom controls. Type def’s allow you define the data types*** used by your application. Once a type def is defined and used on a front panel or block diagram, LabVIEW will ensure that all instances of that type def remain consistent with the definition. This means that if you edit a typed definition and save the changes, every place where that type def is used will be updated automatically. This is particularly useful in the case of enums when they are used to drive action engines**** or state machines.
    Through the use of clusters, you can establish a hierarchy for your data if appropriate. As shown in Hierarchy1.png the hierarchy screen offers a button to control the visibility of type definitions used by your application. By using Type definitions consistently throughout an application a developer can easily determine which VI’s will be affected by a change to one of them.
    Hierarchy1.png
    In the case of the Demo shown above, we can see that the top level VI “Demo” needs to know about changes to the action provided by the sub-VI “Caller”. We also see that changes to the “Chan Name” (Channel Name) data type affect the definition of the “Chan Info” (Channel Information) type definition as well as the “Caller” but they do not affect the top level VI “Demo”.
    We can determine all of the above without ever opening up the diagrams of any of the VI’s or type definitions. This is made more descriptive by editing the icons of the type definitions. The process is quick and easy.
    You start by opening the control editor
    Customize.PNG
    ... and choosing “type def” before saving the control as a unique name.
    You can then open the default icon and select most of the default icon’s image
    Select existing image.PNG
    And slide it down to the left.
    Slide down n left.PNG
    Which gives me plenty of room to add text.
    Structure Name.png
    Since the icons retain the native LabVIEW look it is clear which objects on the hierarchy screen are type definitions. I have for the largest applications taken the time to add graphic that represent the data defined by the type def. This becomes very helpful to pick out the data type you are after from hundreds of VI on the screen.
    View Data Hierarchy.png
    In the application hierarchy screen snippet above I have illustrated how type definitions are very helpful when investigating how a possible type definition change can affect an application. The VI hierarchy screen, when used with type def’s becomes a “data definition hierarchy screen”. Looking at all of the VI in a type def’s hierarchy tells you which high level functions could be affected by changes. The callers tell you the VI’s that need special attention and will adapt to changes in the typed definition. In the case above, we can see (well I can because I can do a little scrolling) that of the 700+ VI used by the application, there are only 10 that use the definition (I shudder at the thought of trying to do this same analysis without type def’s.  ).
    To get the hierarchy snippet I presented above I located** a top-level type def. By “top Level type def” I mean a type def that is not a member of any other type def. Once I located the icon for Equipment Group type def, I was able to right-click and choose Show VI Hierarchy
    Show VI Hierachy.PNG
    Followed by a right-click Highlight connections
    Highlight Connections.PNG
    Summary
    Type definitions allow data structures to be defined and maintained across an application. Enums and clusters use benefit from being used as type def’s. The VI Hierarchy screen includes the option to view or omit type definitons. Consistent icon usage for type def’s makes it easier to find them in large applications. The hierarchy of type def’s define data dependencies.
    Closing
    I hope the above observations on type definition creation, use, and their power to be useful. I’d also love to hear about
    1) How you have used type def’s to your advantage?
    2) How you go about organizing your data structures?
    3) What features of type def’s have I omitted?
    If you have a Nugget you would like to present please post here to reserve your week!
    A list of all Nuggets can be found here .
     Ben
    Notes
    * Warning: changes to application containing hundreds of VI and were not developed using type def’s should be left to professionals. This kind of work has lot in common trying to remodel a house of cards. Every move must be done with great care and you should be not surprised if the entire enterprise comes crashing to the floor. In short, do NOT try this trick at home.
    ** You will find that if you use type definition s in your applications they will end up decorating the bottom edges of your hierarchy.
    *** Type def’s define the data type and not the default values. You cannot use type def’s to establish default values. If you modify a type def that is used as constant on a diagram, all instances of that type def will be replaced with new instances. Default values that were saved in the block diagram will be lost when the constant is replaced with the new definition. This is by design. The method I suggest for establishing a default value is to use a sub-VI to explicitly define the value. In the case of clusters use a bundle by name node to set the fields as required. In the attached 7.1 example you will find
    Type_defd_Constants
    Where I have illustrate the use of sub-VI’s to establish default values. In the example, there are two sets of default values of the type definition “Chan Info” (Channel Information) denoted by the green and grayed-out icons.
    Documented_Constants
    The sub-VI documentation also helps future developers of the application pick-out the proper default settings.
    **** The attached example includes a simple example of an action engine. Stay tuned for a future Nugget where we may discuss action engines.
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Code.zip ‏109 KB

    My recent project involving TypeDefs and 'constant' VIs is about XML creation:
    Where the red 'dot' is a formatter constant with the following content:
    <%1$s>
    %2$s
    </%1$s>
    By using a enum for the XML-tag I can avoid mistypes since XML is case sensitive
    Using 1$s allows me to reuse the first input twice
    And if I need to change the tag-creation I can edit my constant VI.
    Ton
    Message Edited by TonP on 03-05-2007 09:13 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    ChartLocations.xctl_KML_Core.png ‏1 KB

  • Community Nugget, 05/27/2007

    Today, a useful tip:
    On occasion, it could be very useful to have a VI know whether one of its inputs was wired or not.
    For example:
    You could have a VI which will accept a path, or pop up a file selection dialog if you haven't wired the path input.
    You could have a LV2 style global which would execute its Write case automatically if you wired something into it.
    You could have a utility VI which will operate on the VI calling it unless a reference to another VI was given to it.
    The possibilities are endless.
    LabVIEW does not currently expose a way of letting us know whether an input was wired in the calling VI or not, but there is a workaround. When you don't wire a value into an input control, that control uses its default value. For many datatypes, you can determine as default a special value which would be considered invalid and then check if the control is equal to that value and assume that the input control was not wired if is equal to that value.
    Consider the following code, for instance:
    If a VI reference was wired, the VI will control the defer property for that VI. If no reference was wired, it will control the defer property for the caller, so to control the defer property in your VI, you just have to drop it in the block diagram of your VI.
    Common invalid values include -
    NaN for floating point values
    an empty (invalid) reference for references (VIs, controls, etc.)
    negative numbers for numbers which should only be positive
    a special invalid value for enums.
    Now go out and be creative.
    P.S. You should note that it is important to choose a correct invalid value.
    NaN, for instance, can be achieved through calculation (e.g. through dividing by zero).
    For a list of past nuggets, see here.
    If you want to write nuggets yourself, see here.
    Try to take over the world!
    Attachments:
    Defer Updates.png ‏7 KB
    Defer Updates.vi ‏37 KB

    Just a point I noticed about that (very quick) example - the Defer Updates input should probably be a required input and in any case should not be T by default, because that would make the FP get stuck.
    Attached is a simple example demonstrating its use. When the OK button is changed, the updates are defered for several iterations.
    Try to take over the world!
    Attachments:
    Defer Example.llb ‏52 KB

  • Community Nugget 02/25/2007

    The native LabVIEW controls were designed to be readable and easy to use, but they are also quite boring.
    There are many ways in which you can change the appearance of your application, ranging from changing the colors of your controls to using system colors and controls to customizing controls to look more interesting.
    Today I'm going to discuss another option which most people are not aware of - using external resources while customizing.
    Basically, every control is made up of several parts. Some of these pieces have limited options for customization, but the other pieces are usually just images which you can replace with anything you want.
    Let's start with Office. LV graphics are vector based graphics, so you can resize them and they will always look sharp. Office graphics are also vector based, so you can copy images created in Word or PowerPoint into LV and your controls will scale nicely. There are probably other programs which can do this, but Office is the one I have most readily available.
    An example might be in order. Continuing with the dials theme from my previous nugget, here are two dials where the housing part was replaced with two gradient filled circles created in PowerPoint. As you can see, this can make your front panel look different and much more appealing and should also resize nicely.
    Note - at least in LV versions in which I've tried this, the internal LV clipboard does not get the image when you copy it in Office. You need to paste it when you edit your control in customize mode and then right click it and select Copy to Clipboard.
    Here's another example, also inspired by something shown in the dials nugget.
    On the left you can see how you can create a classic looking clock by using an appropriate background image and replacing the housing of a dial with a square frame (taken from the decorations palette).
    In the middle you can see how this can be abused by placing a clown nose on a granite background. It is very important to NOT OVERUSE THIS. A user interface becomes extremely unusable if it is filled with distracting and conflicting colors.
    On the right you can see another nice thing - Office images support alpha channel transparency and this is transferred into LV. As you can see in both this picture and the next, this doesn't look too well on my computer, but maybe newer versions of Office\LV handle this better. Also, be careful - LV will usually be much slower when drawing overlapping controls, since it redraws them every single time instead of being smart and only drawing them when needed.
    On the same note, you can use transparent GIFs and PNGs to have images with irregular shapes.
    Another thing that this image shows (other than the partial transparency) is the reshaping of a numeric control by making the numeric text background transparent and replacing the frame with a shaped image
    Attached are three VIs:
    One shows the clocks with a couple of numeric controls with irregular shapes and partial transparency.
    The second shows using an image created in Office and copied into LV to create a Star-Trek like animation.
    The third shows a VI from the NI site which shows using animated GIFs inside custom controls.
    I would like to state this again - this should be used wisely. It is extremely easy to make a front panel too crowded. Remember that your users eventually need to use the program and that is the most important thing. These tricks should be used to make the user interface more usable or more appealing, but they should not come at the expense of usability.
    To learn the basics of control customization, see this page from the LabVIEW help.
    For a list of past nuggets, see here.
    If you want to write nuggets yourself, see here.
    Try to take over the world!
    Attachments:
    GIFAnimatedControls.vi ‏295 KB
    Clocks.vi ‏823 KB
    Flow 61.vi ‏39 KB

    Great nugget.
    For LabVIEW 8.20 users it might be worth mentioning that it now supports direct background images, similar to the windows desktop. You can easily expand the selection in the list by placing other images into "...\resource\backgrounds" of your LabVIEW folder (On windows: C:\Program Files\National Instruments\LabVIEW 8.2\resource\backgrounds).
    For example you could place the woodgrain background image from your clock display, then simply select to "tile, stretch, or center" the image in the pane background.
    Typically you would choose a small "atomic" image that nicely autorepeats a given pattern when tiled. The advantage is that the background will always fill the window, no matter how you size it.
    The following menu can be reached by right-clicking on the scroll-bar and selecting "properties" (LabVIEW 8.20 only!).
    Message Edited by altenbach on 02-26-2007 12:47 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FP-Background.png ‏71 KB

  • Community nugget: Code Capture Tool 2.0

    When the snippet feature was introduced in 2009, some people thought that this would be the end of the Code Capture Tool (CCT).
    Well, they were wrong. It's back. Bigger, better and cooler.
    For those who don't know the CCT, it's a small utility which you can use to make screenshots of LabVIEW code, either for sharing or for documentation. You can see here  for more details.
    For those who already know it, now's the time to introduce the new features. The following video shows them nicely, but to recap:
    The CCT now supports creating snippets (in any version from 7.0 and up).
    The snippets themselves will only be usable in LV 2009 or later.
    You can now add annotations and sketches in the preview window.
    This will allow you to draw attention to specific parts of the code.
    Here's a video demonstrating the new (version 2.0) features: the video might take a while to load but it's worth the time
    You can download the Code Capture Tool 2.0 at LAVA.
    Here are a series of videos on the CCT (1.0 and 2.0).
    Have fun,
    Yair and Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

    Here are some captures with these version, showing both the annotations and snippet features:
     A capture with LabVIEW 2009 with an annotation.
    A capture (no snippet) with annotations and arrow pointers
    A capture created with  LabVIEW 7.0
    A snippet with annotation.
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Nugget: Open block diagram programati​cally

    There are a way to open a block diagram programatically. Exists a undocumented function located in
    "%Program Files%\National Instruments\LabVIEW 8.6\vi.lib\Utility\sysinfo.llb\Set Block Diagram Open.vi"

    My good old 7.1. (ok, I run that in hyper-boost mode ) has a property node 'VI.Block Diagram Window.Open'. Should be available for anyone and documented in 2010.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Darren's Weekly Nugget 06/22/2009

    Today's nugget deals with gracefully closing a LabVIEW built EXE window.  Most everybody knows the trick of using the Quit LabVIEW function at the end of a built EXE to close its window.  In fact, you may have even included some extra logic, like with a Conditional Disable Structure or the App.Kind property, to make sure Quit LabVIEW doesn't run while you're developing and debugging your VI in the LabVIEW editor:
    Have you ever noticed, though, that sometimes when you quit a LabVIEW built EXE, you see a brief flicker of the toolbar?   This can happen if you have your VI set to have a dialog window appearance (so that there is no toolbar), and you run the Quit LabVIEW function after clicking the "Stop" or "Exit" button that you created on your VI's front panel.  In this case, the built EXE, upon going idle, will show a toolbar (with the Run button) for an instant before the panel closes.
    To avoid this toolbar flicker, you can make one simple change to the code above:
    By calling FP.Close, you are telling LabVIEW to hide the front panel of the VI/EXE first before exiting.  This way the extra cleanup that LabVIEW must do can occur without the front panel of the built EXE showing, and we never see the toolbar flicker.
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

    Sebster:  Yes, it will work, but you should clear the error before you execute the code. Furthermore you will need to get the reference to the calling VI (or the top level VI).
    Darren: Thaks a lot for the hint, the FP.Close was really new to me. Maybe you adress the other side (splash screen while loading) in a further nugget.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Custom Button Nugget

    Custom Control Design: Boolean Buttons
    I was giving help to someone to help them make their buttons look better when I was asked to discuss how to make nice custom controls in a more formal way that everyone could benefit from (special request from Jeff Bohrer) in this thread.
    http://forums.ni.com/t5/LabVIEW/Decal-Custom-Contr​ol/m-p/1544212
    First let me show some of my controls and then we can talk about how they are made. We will also discuss the dos and don’ts of making nice buttons.
    To do something like this you will need to have an artistic flair or access to someone that does. It takes a long time to design and develop the icons that you see. There are many parts and like writing code there are many little pieces that are required to make these things look good. So I am going to have to assume that you have access to custom icons that you want to use for this process.
    First thing that you want to do is create a button on the front panel of the program that you are working on. Right click on the button and you will see and option for advanced and customize.
    This will open a new window which is a custom control window.
    From Here if you click on the wrench button in the menu bar it will allow you to edit the button.
    You will see tweezers after you click this button. This is where the magic happens. If you click on the Window option in the menu bar you will see an option for show parts window. This window will show all of the parts that make up this control. There are three parts for a Boolean button. We are only worried about the button part. You can also click on the button part to edit what you need. If you right click on the button you will see these options.
    We need to talk about some of these options and what they mean when you are importing your custom icons.
    Result of option:
    import from the clipboard - this will distort the picture and it will look fuzzy.
    import from the clipboard at same size - this will distort the picture and it will look fuzzy. It will be worse if the button is bigger than the picture that you are importing.
    Import from file – This is the best option as it will make nice pictures as long as the picture that you are importing is the same size as the button that you are importing to. The way to make your buttons look the best is to edit them in a picture editing program prior to importing them so that they are the same size.
    Import from File at Same Size – This can distort the picture if it is a different size than the button that you are importing to. This can make your pictures look fuzzy.
    So when I make a custom icon I make sure that it is the same size as the button that I am using so I get the best picture quality that I can. You need to also remember that if you resize the button on the front panel that it will distort the picture ion on your new custom button. If you need to make a different button size you need to make a different size icon to go with it. It can get very time consuming to do this correctly.
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    Green Button Control.ctl ‏314 KB

    Thanks for the nugget. I was doing some new button designs today, so I add my newest findings right here.
    At first: resizing is a bit critical. Get your design as a vector graphic (svg using inkscape), then use it on a LV button of the same size. A good start for design is tango, because it's all public domain (be aware of licensing issues when using icons from the net, most stuff on wiki-commons is CC-SA='share alike' which might force you to open your code!) and svg.
    In this case, I use the IEC5010 On/Off Symbol (found here). Using inkscape, I did export a 16x16 png (attached). Now let's get it into LV:
    Place a 'Modern->Boolean->Round LED' on a FP and go to Advanced->Customize. Little trick from the micro-nuggets-thread: use the win explorer to drag-drop the png file on the control FP. Now Select and Cut/Ctrl+X. Right-Click the Round LED and select 'Import Picture' -> Decal. (Do NOT switch to edit mode for this). Wow, the frame is now around both the on and off led. Below my result for 64x64 px size.
    Get different sizes by: 1. export the png from Inkscape in the appropiate size and 1. Resize the round LED befor copying it from the clipcoard.
    As mentioned in the original post, the image does not scale with the button resizing as usual.
    I have some more tricks. Hope the weekend gives me the time to post them.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml
    Attachments:
    On_Off_16.png ‏1 KB

  • Linking my forum profile to the community profile

    I'm requesting some possibilities to link my forum profile to my community profile (and to my LAVA profile, that would just be great).
    I just realized this because in the statistics of my forum profile, I see a 'blog authored', and while I'm bloging on the communities, this isn't reflected.
    After some more thoughts, people like me donate a lot of (unpaid) time to make NI products better. Our participation in the forums and the community could be some cheap way to pay it back to us. If a potential employee or contractor is researching about our knownledge, the profiles could be impressive. If we would have linked them better, we could present us in a much broader background (I really do use the different options I have online for different objectives of mine).
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

    I read your post prior to posting this. I agree that on the long term, a single profile would be cool. But I also like the differences of forums and communities, and having diffrent providers might be the prize you need to pay for this.
    I'm more interested in short-term workarounds at the moment. Philosophically I also like to have a cloud identity, so I'm fine with a set of options to interlink my profiles. All the profiles offer some options to link to some web2.0-services (facebook, twitter, icq), the community profile has a field for the forum profile.
    I also don't want to just discuss this on a technical level, but in the field of information management. If someone clicks on my profile, what information might this person be intersted in (and which information I want to provide). Well, it wont be a nice woman looking for a data but more likely some other engineer/technican/scientist or someone from a HR department that wants to check my technical expertise in different fields. So for them I would like to display a kind of top-ten charts where I am good at or interested in.
    BTW: A personal messanger would be cool for this as well, so I could for example contact someone that was pretty active on the forums for let's say SMTP and directly ask this person if he/she can help my with my own SMTP problem.
    I've seen this (some time ago) completley HR related on the joelonsoftware blog, where they where introducing a service (pretty expensive) for HR-departments where they could check the profiles (CVs) against the activity on the stackOverflow.
    Don't misunderstand me, I'm not currently looking for a job, I target this with a technical knownledge-sharing intention. If I know that a memeber of the forums has some expertise I need, I'd like to have a look if this person hasn't founded a community for exactly this topic before asking.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Is there a way to reference the property node value of a control in another VI?

    Let's say that I have a situation like the one shown in the attached image.
    I have an interlock system which is basically a bunch of booleans
    If for example the "RF Enable" button in the "interlock VI" is true, then I should be able to flick the ON switch in my other VI (in the back), but if the value is FALSE, then it shouldn't allow it.
    In other words, how do I check the value of a control across 2 separate VIs (running simultaneously)?
    Thanks!!
    Attachments:
    sample.jpg ‏295 KB

    Is one VI launched by the other, or are they launched independently? If it's the former then you just need to pass the control reference to the subVI via terminal node. If it's the latter there are a variety of ways to handle this:
    Use a global variable - somewhat "sloppy" as it requires a global variable, and can lead to race conditions. In the "Interlock" VI you just set the value of the global variable when you change the value of the Boolean. In the other you're just reading it.
    Action Engine - Ben wrote a Community Nugget a while back. Similar concept to a global variable.
    Queue - The "Interlock" VI simply pops an element onto the queue with the value. The other VI just monitors the queue for a new element. It just needs to have something like a shift register to keep track of the last state.
    Use the VI Server to access the controls of the "Interlock" VI. You can do this by accessing the "Interlock" VI's pane and get the control references. With the control reference you just need to get the value with a property node.
    ... (I'll let others chime in)

Maybe you are looking for

  • Can not open .sit files any more

    I get a warning that it is not a compressed file. I downloaded a new copy of Stuffit 11 and it dosen't work either. The files show as an icon of a little brown suitcase ant the suffix is .sit. If you look under get info it says that it is a stuffit a

  • Is there a different type of DVI ports??

    Hi All, My question is that I have a Radeon 9000 video card that supports dual display with ADC and DVI ports, I have a flat screen display to the ADC port and I want to use the DVI port to a television... Well, I got a DVI to S-video/composite adapt

  • Changing Page Size and Margins for existing document

    Hi, really new at using InDesign and have a question. I have an existing document about 40 pages containing text and graphics. I need to change the page size from the original 8x10 to 8.5x11 as well as change the left margin from 0.5" to 1" If I simp

  • Hi all,  script

    hi i have modified zscript only and not driver prog in dev server. 1.  do i have to transport all includes that are existing in the system or only the one which i have added?? 2.  how to transport style from dev server to quality server.?? 3. is ther

  • Is it possible to do this kind of system with Cirrus?

    Sorry for my poor english. I am looking for a technology that solve my problem and I am not sure if Adobe Cirrus is the right one. I am making 1vs1 turn based game system for cross platform (iOS, Android, Web) The game process ... PlayerA start app a