Sampling local variable and synchroniz​e with DAQmx

Hello, 
I made a small change in the set-up I used with labview and now when I wanted to change the code I'm having a rather complicated problem.
In my old set-up I was measuring three variables: x and y with a QPD and the power of a laser with a power detector. I was using the DAQmx and I was getting a matrix with three columns with n (sample rate) values. Now, for various reasons I had to take out the second detector. So now I want to build the same matrix as constructed before, but instead of putting the measured values of the laser power I want to put the theoretical values (they are in a local variable) as I cannot measure them. The problem is that this local variable, in general, changes during the DAQmx acquisition time and I would need to sample it at the same rate as I acquire the data from DAQ and then combine all them. How I could sample this variable and attach it to my DAQ results? DAQmx doesn't accept local variables.
Thanks

A local variable is not something standalone. It is always associated with a control or indicator. Hows is it updated?
From your description, it is not clear what you are doing. Can you show us some code instead?
(Also be more clear when using acronyms. QPD cound mean many things)
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • What is difference between local variable and property node ?

    What is difference between local variable and property node ?
    " 一天到晚游泳的鱼"
    [email protected]
    我的个人网站:LabVIEW——北方客栈 http://www.labview365.com
    欢迎加入《LabVIEW编程思想》组——http://decibel.ni.com/content/groups/thinking-in-labview

    To make things clear, here are two small examples that show how nasty locals and value properties can be to the naive programmer.
    - Open the diagram of the race condition.vi before running it and try to predict what will be the values of the two counters after the third run.
    - Use the Compare Locals Properties and Wires.vi to find out how slow locals and value properties can be (times 1000+).
    This being demonstrated, I must add that I use globals and value properties quite often, because they are often very convenient
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Race condition.vi ‏9 KB
    Compare Locals Properties and Wires.vi ‏18 KB

  • No difference between using a local variable and a notifier in timed parallel loops?

    The example code "Pass Data With Notifiers.vi" that came with LV 7.1 illustrates using notifiers with parallel loops.  Just looking at two of the loops, the one that generates the sine wave and the one for "User 1", you can change the timing of the two loops and you can change the condition of the "Ignore Previous" status on the "Wait on Notification".  I have a special case of this to consider, where I'm wondering if there's any reason not to use a local variable instead of the notifier:
    Set the delay on the generator portion (which contains the Send Notification) to something very short, say 5 ms.  Set the delay on the User 1 (which contains the Wait on Notification) to something relatively longer, say 200 ms.  Set the Wait on Notification to False.  Now you have a situation where the User 1 loop action is contingent only upon the loop delay time, since each time the loop timer runs the loop there will always be a value in the notifier.  In this case it seems to behave just like the case where you update a local variable in the fast loop and read it in the slow one.
    Is my understanding correct?  Would there be a performance difference between the two methods?  What do you prefer in this situation and why?
    Thanks,
    Hosehead

    Hi H.,
    I think your idea is to write to a Global Variable in the data-producer VI, and read it in the data-consumer VI(?)
    One reason this might be less efficient than using Notifiers is if you want to graph every new value in the "consumer" - or make sure the value read in the consumer has changed at least once since the last loop.
    > since each time the [consumer] loop timer runs the loop there will always be a value in the notifier...
    > Would there be a performance difference between the two methods? 
    If you don't use the Notification "event" to synchronize the producer and consumer, then to be sure the consumer gets a new vaue, you've made the producer loop faster - every 5 ms - a waste of cpu-cycles.  More often the situation is reversed, that is, there's a consumer that needs to see every single new value, and (without events) the consumer must loop faster than the producer (to catch every new value) - this is called polling and it wastes cpu-cycles.
    Just about anytime one's tempted to make a loop execute "fast" to check on some value (or to make sure there's a fresh value,) there's an opportunity to improve performance through synchronization with events (including notifiers, queues, occurrances, semaphores, and rendezvous')
    tbd
    Message Edited by tbd on 07-09-2006 03:51 AM
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • How to allow user to select pdf file on local machine and populate field with file name only

    Folks,
    I have a project requirement that I am stumped on.  I am admittedly a novice, so forgive questions that may seem obvious.
    My requirement is a form running on a client system where the user can click a button and select a PDF file name from a PDF on their local machine and then populate a form field with that file path & filename.  The file names vary between all machines, so there is no static list.  Note that the PDF is not embedded, nothing is executed, I simply need the file name.
    There are several of these on a form (20+), so manual name entry is too error prone.   I would like to use a 'browse' type dialog, but can not figure out how to implement it.
    I've looked at app.browseForFile, but the users can not install a javascript file in their adobe folder or any other files;  the functionality has to be integral with the original PDF. 
    Functionally, this is no different from the image object file browse, except that I need a PDF instead of an image file, so there doesn't seem like there should be a security issue that is any different from those surrounding the image object.
    I've been stumped on this for the entire week, and I have a deadline rapidly approaching, so any examples or suggestions (please remember I'm a novice) would be greatly appreciated! 

    Thanks for the reply Paul - do you have any sample code of how to attach the PDF?  Or how the user can select a PDF to open?  I might be able to attach it, retrieve the file name, and then un-attach it.
    Alternatively, do you know how to retrieve the file name from the imagePath object?  It will let you select PDF files, but I can't find info on how to retrieve the file name.   It should be the way you would retrieve the file name for an image.
    As a novice in this, thanks for your help and patience!

  • Sun Sudio C++: Local Variables and Watches Values Not Initialized in Debug

    Hi All,
    I am trying to debug my program (using dbx). I have put break points in various functions. However, I have the following problems:
    - when the program runs to the break points, all arguments have in the functions shown in the callstack have values '???';
    - NOTHING is shown in the 'Local Variables' windows;
    - if I put the local variables in the 'Watches' window, the 'value' simply says <unset value>;
    what am I doing wrong?
    Thanks in advance

    Well, first things that comes to my mind is that your app was not compiled with debug info. Could you please post output of the following three commands here:
    $ dwarfdump -l <your app> | wc -l
    $ dumpstabs -s <your app> | wc -l
    $ file <your app>
    (if the first two would print small number, remove "wc -l" and post real output here, please)

  • Local Variables and INLINING

    LV2013SP1
    When making a VI that originates a TYPEDEF'ed cluster, I have always used a local variable of that output cluster, and a BUNDLE BY NAME function to insert the various pieces.
    Like this:
    Now, when I try to INLINE the VI that does this, I get an error message: "This object is not allowed in a VI on which you enable inlining".
    I can replace it with a constant easily enough:
    My questions are these:
    1... Why is the first method illegal?  I suspect something to do with thread-switching into the UI thread, is that it?  Or maybe there really isn't a front panel if it is INLINEd?
    2... Is the constant pattern better, in terms of memory usage?
    3... Is the constant pattern better, in terms of speed of execution?
    4... Should I adopt that pattern anyway, regardless of INLINE or not?
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

     the exact why is not explained
    I believe the "why" IS explained. This all makes sense to me now.
    There can be no instance of the control/indicator, because it's never been placed on the caller's panel.
    If it existed, it would have to have properties like POSITION and BOUNDS, and those have never been set.
    They COULD NOT be set, since they would have to be set (differently) for each instance of the inlined VI.
    The INLINEd VI requires REENTRANCY, that means there is a separate dataspace for each instance.
    I suppose that dataspace now would come from the caller.
    The point of the INLINE is to connect the caller's output wire to the VI's input wire AS IF the VI's code were copied into the caller.
    That means that the CONTROL/INDICATOR is totally unnecessary, and can be removed.
    It therefore cannot be accessed.  Not by property nodes. Not by local vars.
    AND, ON A HUNCH, I tested this:  NOT BY REFERENCE.
    With a REFERENCE to a control/indicator on an INLINEd VI, I get the same error: this object is not allowed in a VI on which you enabled INLINING.
    Because it doesn't exist.
    The control/indicator is a metaphor for the interface between the code and the screen display.  It ceases to exist when INLINEd.
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Combining Digital OUT and Digital IN with DAQmx on E-Series

    Hi,
    I'm trying to combine Digital IN and OUT-function with the DAQmx-driver. I have set the first four channels of my E-Series to IN and the other four to OUT. How can I programm this? I encounter problems when changing an OUT-channel.
    Earlier I did that with the traditional DAQ driver by setting the port to 240 (first four In, second four OUT)
    Thanks for any help

    Hi,
    The easy way i know, is by configure Global Channels at the NI-Max and then use the Linked VI i send.I know it's a elementary VI, but u can continue from this point.
    Hope it helps ....
    Bush-Man
    Attachments:
    Read and Write Digital.vi ‏61 KB

  • Error 200278 and error 200279 with DAQmx read

    Good day everyone,
    I have been trying to write a code which generates a sine wave and a trigger signal and send them out to two different devices. I am trying to phase lock device-1 on a certain phase angle of the operating signal  (sine wave) of the device-2.
    The device-1 which receives the trigger signal also generates a trigger signal at the same time it receives the trigger. It also can not work with trigger signal with a frequency which is greater than 4 Hz.
    I got that part to work and then I realized that I need to make sure that the responses of the devices have the same phase difference. So I added another part to the code which reads the trigger signal generated from the device-1 and the sine wave generated by the code (which basically goes to the device-2).
    I did not have any loop in the code at the beginning, and I just set the sampling frequency and sample rate and I though that it would work at the rate which I want. Unfortunately it did not. So I added a while loop to control the speed of the writing and reading process, and slow it down to 4Hz which is the limit of device-1.
    I have tried the reading process with finite sample and continuous sample on the sample clock and I got Error 200278 and Error 200279 correspondingly. Attached please see the main VI and subVIs. There are some subVis for writing data to the file which are not attached.
    I really appreciate it if you can help me to solve this problem and get the code to work in a way that the whole process works at 4 Hz frequency.
    I am not sure if my code is completely optimized. Any suggestion to optimize the speed of the code and the way it acquires data is also highly appreciated.
    Regards,
    Pooya
    Attachments:
    Trigger_Seq_R1.vi ‏115 KB
    time.vi ‏23 KB
    wavegen.vi ‏33 KB

    Hello Pooya,
    You need to add some wait delay in your while loop. Try adding a Wait Until Next Millisecond Multiple to your while loop with a constant wired in.
    You are acquiring data too quickly. Here is a link that discusses this in general.
    Regards,
    Jeff L.
    Applications Engineer | National Instruments

  • How many ways to read and write a local variable in a called VI?

    Ciao!
    I'm producing my first TestStand sequence. It is called "FirstAttempt" and it is made by a single step which calls a VI. One of the first dilemmas i encountered realizing this sequence is how to read and write a local variable (created going in Variables -> Locals ('FirstAttempt') -> <right click to insert local>) in the called VI.
    The first way (the only one i tried) is to create a control and an indicator on the VI front panel, connect them to their respective terminals in the connector pane and then specify (going in Step Settings -> Module) that these connectors (shown in the Parameter Name column) are linked to the local variable (selected in the Value column).
    The second way (not tried) consists in using TestStand API: create a Sequence Context reference on the VI front panel, link it to a property node in the block diagram, select the property "Locals" and extract from this the local variable name and value which, i think, can be readable and writable.
    So...
    Are the shown ways correct?
    Are there other ways?
    Knowing that a "local" variable can be considered "global" within the whole sequence, is there the possibility to simply create a reference to the local variable and use the reference in the called VI block diagram in order to save space in the connector pane (if using method 1) or in the block diagram (if using method 2)?
    Thanks!
    Message Edited by aRCo on 09-17-2009 05:09 AM

    Hi,
    Before TestStand 3 you would use the second way you quoted as its the only way.
    But now you would use the first way you quoted. You may still what to pass the SequenceContext if you were going to use the TestStand API. For TestStand 3.x and above you would use this way as the first chose. (Personnelly, I would not pass the SequenceContext into a VI if I know it was never going to be used in that VI.)
    Not sure I understand your final comment, maybe you are liking it to passing the reference of a control to a subVI so that the control can be updated from within the subVI.
    If this is the case and you had a situation where you had a step that was running in parallel with the rest of the steps in the sequence either as a separate thread or execution and were dependent on the contents of the  local variable changing from that parallel running step, then you would have to use the API SetVal method to change the local.
    Hope this is clear.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How come my local variable is not updating it's value with respect to what's happening in the while loop?

    Hello,
    I am trying to extract data out of a while loop as my declarations update with respect to the iteration number. I have attempted to use both local variables and shift registers, but with no luck.
    I have also done the following example: http://www.ni.com/white-paper/7585/en and it works like a charm.
    I attached the PNG file with local variable declaration circled in red. Will attach a VI in the next respnose.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    Local Variable.png ‏366 KB

    OK, looking at the code...
    Can you explain what it is supposed to do? What's the purpose of the value property node read which only seems to update an indicator.
    The inner while loop should proably be a FOR loop, because the number of iterations is known before the loop starts.
    Your use of formula nodes seems overly complicated.
    LabVIEW Champion . Do more with less code and in less time .

  • Having Trouble Copy and Pasteing Local Variable in LabVIEW 2010

    I am Having Trouble Copy and Pasteing Local Variable in LabVIEW 2010 in s subVI.
    I have a VI that has a Local Variable called "Node Addr". I can select it OK, and it appears to Copy OK, But when I go to paste it, nothing appears. It doesn't matter if I use Cntrl-C Cntrl-V or the Copy and Paste from the Edit menu, I get the same results. I tried many times and got the same results. I made sure that I had click a paste location. I can insert the Local Variable if I use the Data Communication panel.
    On one of the Paste, I got an error in the error list that said that a Local Variable was not connected to anything. When I clicked on the error, it took me to an insible item in the lower right corner of the block diagram that had nothing but a select box around it. I couldn't select the invisible item, but I could delete it.
    Why does the copy and paste of this local variable not work?
    Why does the paste cause the insertion of an invisible item?

    dbaechtel wrote:
     My VI is fairly complicated. In several places in the VI, I am either reading or writing to this variable which is an numeric Indicator on the Front Panel. Using local variables seems to be the best way to handle this situation rather that using wiring all over the VI. Since the VI is mainly a State Machine and there are only 2 Writes to the local variable, I am not afraid of race conditions in this case.  NO!! While you may think that using Locals is your solution to wiring, it is not!  The fact that you are writing and reading, most likely from several places, will most definitely contribute to a race condition.  Depending on your implemetation, you should ALWAYS use wires.  The wires are the variable.  If you are using a loop (While, For), then using shift registers are appropriate means for routing values so that they are used by other sections of the code, later.  One thing you must respect with LabVIEW is the dataflow.  That's where Locals often fail.
    I am not copying the Local Variable from one VI to another.
    I am not copying the Local Variable from one VI to another.
    The Data Communication panel is one of the panels that shows up in the Functions pop up list when editing the Block Diagram. It is the panel that includes the Local Variable function.
    I don't know if the invisible item that was inserted in my block diagram was hidden or not. All I know is that the Errors List said that it was a Local Variable and that it was not connected to anything. I couldn't select it to get more information. All I could do was delete it.
    You did not address my questions about why the Copy and Paste does not work properly for my Local Variable.  Maybe it's a sign from the Software Gods not to use them LOL!..
    So if I understand correctly, you are trying to copy & paste the Local Variable from within the same VI.  How large is your block diagram?  Did you try right-click on the variable and select "Find > Local Variables"?  If it's a block diagram larger than 1 single screen (which it shouldn't), then it is possible that the Local is hiding beyond the screen.  You should find it as I described earlier.
    See my comments in red above.

  • Data Acquisition - using local variables to write data to a file

    Hello,
    I am running a Data Acquisition vi (currently in LabVIEW 7.1 but soon to be updated to 8.2) that collects ~100 parameters of data from several sources contained in a while loop. The current configuration (which I did not write) uses very few subVIs and writes to ~100 local variables to store each parameter. It then reads all the local variables and builds an array of all the strings, converts then to a spreadsheet string, then uses the write characters to file function to append to a datafile. I am trying to clean things up and have came up with subVIs to collect the data from the following sources:
    8 serial port sources collecting btwn 8 and 20 parameters each
    ~15 thermocouple readings
    ~10 analog inputs
    ~20 parameters read off an ARINC 429 bus.
    I have come up with a subVI to read each of the sources and have placed the subVIs in the while loop. Each subVI outputs the data that it collects in array or cluster form. I was wondering how best to write each parameter to a CSV file at between 1 and 10 Hz. Should I write each subVI output to a LV and then read them off as was done before (the difference being that I have reduced the # of LVs to ~10 vs >100?
    I should add that precise timing is not that important, so if all the subVIs are not collecting simultaneously (which I understand that they won't be), it does not really matter.
    Thanks.

    Hi jilla,
    jilla wrote:
    What I think that you are saying is to turn the outputs of the 4 subVIs into inputs of a 5th subVI that writes to the data file. Correct?
    Yes.  It may sound like a fine-point, but I beileve it's better to create a VI specifically for formatting data - in your example, 4 arrays IN, a single string OUT.  Then write the string to file as a seperate operation.  GUI-displayed data can go through a similar transformation, the four arrays wired to a subVI which builds output-structures specifically for display.  It's a beginner's mistake to put lots of individual controls and indicators on the screen when groups of them are naturally related (in an object-oriented sense.)  Use clusters to group related controls - this will keep the diagram much cleaner.
    One more question: at what point (either # of data points or frequency of data collection) does it become necessary to use queues? Thanks.
    Well, there's not really a clearly definable "point".  I'd say if your update-rate climbs above 100Hz, or you witness poor program or system performance, then it's time.  The scenario you've described is a fairly simple acquire/display&log loop - and simple is good.   Then-again people can't see/react-to updates faster than about 10Hz - so it doesn't make sense to sacrifice performance - if performance becomes an issue.
    Re: queues:  Queues are sometimes used to buffer data that's "produced" in one place and "consumed" in another.
    Here, if/when logging data, you're logging with every DAQ.  I wouldn't recommend using a queue to transport data from a "DAQ loop" to a "Logging-loop" - those functions can be in the same loop.  Should/could a queue be used to get data from a "DAQ loop" to update the GUI at a lower frequency?  Sure, but a Notifier might be a better choice.   Further, in the (simple?) program you've described, you might use a case structure (True/False) to only update FP indicators every "X" iterations - a simple solution that doesn't require Queues or Notifiers.
    Cheers!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)

  • Control buttons in local variables

    hi,
    i have been trying to do this for a long time. i just never learned how to make it work. can someone please guide me?
    i have this program with many many local variables and i know that this forum absolutely hate LOCAL VARIABLES.
    I want to program this the right way, so can you guys please help take a look at my code and see what i can do in order to REMOVE local variables if possible?
    Best regards,
    Krispiekream
    Attachments:
    test.vi ‏768 KB

    does this work?
    i split up the zip file to 2.88mb each.
    i think there is a file size limit of 5mb
    can you rename test01.zip to test.z01
    can you rename test02.zip to test.z02
    Best regards,
    Krispiekream
    Attachments:
    test.zip ‏1078 KB
    test01.zip ‏2847 KB
    test02.zip ‏2847 KB

  • How to assign bean value to a local variable in JSP using struts.

    Hi everybody!
    I've a problem that puzzled me on how to assign a bean value to a local variable like String in JSP using struts.
    we can have someting like this to display the value
    <bean:write name="detailService" property="status" />or
    <bean:define id="theStatus" name="detailService" property="status"/>
         This is country: <%=theStatus%>but an error occured when I tried like this:
    String currentStatus = "<bean:define id="theStatus" name="detailService" property="status"/>";
    or
    String currentStatus = "<bean:write name="detailService" property="status" />";Is there a way to do this?.....
    Any help pretty much appreciated

    Java != JSP.
    The <bean:define> and <bean:write> tags are custom tags meant to appear in the HTML section of a JSP file, as opposed to the scriptlet section. They actually get turned into java code as part of the translation process.
    The <bean:write> tag naturally just writes out what you tell it to.
    The <bean:define> tag defines a local variable, and gives it a value.
    this should do it.
    <bean:define id="theStatus" name="detailService" property="status" type="java.lang.String"/>
    <%
      String currentStatus = theStatus;
    %>With the advent of JSTL, you shouldn't really need to use scriptlet code anymore. Personally I am for 0% scriptlet code in any jsp I write.

  • How to specify a unique integer for each local variable defined in TestStand?

    I have a .net application that reads all TestStand local variables, but for the .net application each local variable should have a unique integer number. Iterating through the locals and storing the index is not a good solution, because if a local variable is moved or deleted, the index will change.
    Does anyone know how to do this in TestStand or having an idea how to this in my .net application?
    Thanks.

    Thanks Doug for your reply. Using a GUID is not an option because this ID is too long. I will try to explain why I need this ID for. I have a lot of C# code that generates code to deal with a lot of instruments. For example to configure a device, user defined variables can be used to specify some settings or to store results. These variables are not stored in the generated code with a name but with an integer number. Now I want to try to be use all our existing device driver code with the TestStand sequencer. So, I need a translation between the name of a TestStand local variable and an integer number. After constructing the interface to my code I want to read all the variables from TestStand and now I need the integer ID to do the mapping to my variables. I know that I can use use your proposition 2 by encoding the unique ID into the name of the variable and parse the name of the variable to get it back, but this is not an automated way. This will be rather difficult if there are several hundreds of variables. For this reason I am looking for an alternative way. Looking forward for your response. Best regards   

Maybe you are looking for