DLL slows parrellel while loop

Hello

I am changing a VI I wrote, to work with another piece of equipment. Communication tends to work directly through labVIEW. My new equipment provided with a driver/dll library and now I have many layers before reaching the material (LabVIEW-> driver-> software-> the measuring equipment). I have some time this account down to run alongside my Subvi who manages my method of measurement of the loop. As I put in place the screw that call DLLs that count - while loop slows down in the same frequency, I'm calling the dll. I've changed the "Run in the user interface thread" setting to the "Run in any thread" option in the call library function node. In fact, which got rid of my problem about 90%. But my meter still comes in a few seconds at the end. I wonder in what sense the crux of library function call delayed a seemingly parallel thread?

Any suggestion on the place where to continue searching for a fix?

Welcome them

/ Lorenz

It is hard to tell what might work without knowing your DLL and what he actually did, but I see something in your loop that will force LabVIEW to toggle the user interface thread! The property node to update the text of the start_method th button will ALWAYS force a change of context for the UI thread. If you can avoid this really should not be possible for the DLL block your loop more. At least try to not update this property if it needs to be changed with regard to the previous value and not at each iteration of the loop.

A guess is that the DLL actually interfaces to ActiveX code somehow. LabVIEW initializes its ActiveX environment to run in the UI thread, because it is the only safe thread system in LabVIEW to perform many threaded ActiveX components or when the data marshaling is involved. If your DLL tries also to connect to an ActiveX interface, it will be forced to go the UI thread that explains how to access the property in your loop can get delayed.

And another problem you have is the moment of software. count you down the loop increments of 10 ms, but Windows will be hardpressured for hard real-time performance. While you are not using the "wait until the next ms Multiple" to take account of some jitter, if the loop is blocked for more than 10 ms through an external resource, you will actually jump an interval.

Better would be to calculate the time elapsed directly reading the timer tick before entering the loop, then use the output of graduation of timer her to "wait until the next ms Multiple" to calculate the difference. Dividing this difference by 10, and then adding your counter value initial this result would give you the same value that you feed your VI calculation, but what about the real system clock, not a counter loop running asynchronously with questionable interval.

Tags: NI Software

Similar Questions

  • read from measure Makefile slow while loop

    Hello

    I'm using Labview for controlling a lower Member brace. What I did is to save in a spreadsheet, the values of two angles in a random walk. The control template is done well because I tested it by giving two sine waves with different frequencies and the system responds by following paths. The problems begin when instead of sine waves, I put the experimental values of the read angles and "the file of the measurement reading. I can't change the speed of the system by varying the time while loop. The speed is always the same.

    In the vi attached is possible to find this piece in the upper left corner of the while loop.

    I use windows 7, 2013 and cDaq-9178 labview.

    Thank you in advance for the answer.

    Best,

    Flavio


  • Control and Simulation in a loop / while loop with TCP/IP reading / writing of synchronization

    Hello, I have a problem with reading TCP/IP and written in two loops. The problem is NOT to get the two loops to read and write to and from the other. This has been accomplished. My problem is when I run control and the loop simulation on my laptop and the while on a RTOS remote on the controller on-Board of LabVIEW in a remote PXI chassis, the while loop the remote system running on four 4 times faster than the loop control and simulation on my laptop. In other words, for each iteration of the loop control and simulation on my laptop, there are 4 four iterations of the while loop on the remote system. I need to know how to get a degree of kinship (1:1) with these iterations of the loop. When I run a longer simulation in real time, say 10 seconds, the control and Simulation loop begins to slow, i.e. the simulation time slows down until it is no longer in real time and the "Late Finish"? Parameter is set to true and the LED lights and continues to stay lit. At this point, the system destabilizes due to what I believe is being well sampling rate too discreet and I have to end the simulation. How can I get a ratio of one to one between the loops and also to avoid slowing the loops causing destabilization?

    To give an overview of my application, I implement a control system in a network, seen in "image2.png". This is achieved using my laptop as a subsystem 1. Reference signals are generated from the laptop and the error signal is produced. Control measures taken and the control signals are sent via TCP/IP to the remote system. Position feedback is returned, and the process repeats. My system has Core I7 Procs w / 3 GB of RAM, up to 1 GB/s speed via ethernet and LabVIEW 2011 installed with all necessary modules and networking tools. The attached VI Custom_Wireless_Controller works on my laptop. The remote system I'm working on that has the 7830 NI R Series with FPGA card. OTN runs on the PXI chassis with an enbedded controller that has networking capabilities of up to 100 MB/s via ethernet. I use the FPGA for the acquisition of data and apply control signals to my plant. The plant is the PCE twist connected to the FPGA through the cable of the ECP - RIO of NOR. Subsystem 2 is this side of the CNE. The FPGA collects position, he sends to the controller via the network, receives signals from the network drive and writes signals to the plant power amplifier that operates the plant. This process is repeated and the VI and is titled Custom_Wireless_Plant.

    I appreciate the help really and look forward for her and for any question!

    Well, the first step is to understand what you have set up right now. Your control and Simulation loop on the side of the controller is configured as 'Runga Kutta 4' and you have a loop timed on the other side. In addition, you have the primitives of TCP/IP on the control and the Simulation diagram and means he will perform (a message) on the size of each minor step, which in your case is 4.

    So, you have two options:

    1. replace the Solver side controller Runga Kutta 1 (this must synchronize loops)

    2. hold RK 4, but create a Subvi around two primitives of TCP/IP and configure from the VI to run than the major (continuous) step-size. If you do it right, you should see a 'C' on the upper right part of the VI you have created.

    Please let me know if what I said is not clear...

  • Stop and start the task in while loop

    I try to start and stop an output meter (creates pulsed output) in a while loop and I don't know how this is possible. I have a while loop running who is taking measures from a digital compass. If my title is within acceptable limits, the outputs of the meter (2 of them to turn to the left and right) must be turned off. If the title is out of the acceptable range, let say too far to the right, I want to start one of my outings of the counter to activate the object to the left. The issue I am having is that if I put the block 'Start the task' in the while loop the system will try to start each iteration of the loop, even if it is already on. I don't know if there is a problem, but it does not appear effective from a programming perspective. I remember reading somewhere that stop and start tasks can really slow a loop. Any suggestions?

    I actually just to understand it. If you use some if statements and the "fact of task is" block you can make it work.

  • How to set up the execution in a way independent while loops?

    Hello

    I hope someone here can help point me in the right direction for that.  My system at this stage is still quite simple, I just data collection of 2 resistance probe and a pressure sensor, their output in the Panel before and sometimes to write.  I have put architecture in place to call parallel loops running at the frequency I would ideally like to do.  that is, I want the RTD to update every seconds and the pressure transducer for updating chaque.5s, I want to write to the file at a rate defined by the user and I want the Panel before updating a half second (correspondence with the pressure transducer).

    Now, in the structure, I wrote, it should run all the while loop once before it can restart the sequence.  Technically, the code works, but it takes ~1.5s to the RTD to collect and update and so the whole VI takes ~1.5s to complete.

    I don't care if the RTD is slow to update, but as I use the sensor as a gauge of the cell pressure I need to know at a high frequency that the pressure is in the cell, and I don't want to wait 2 seconds for the information.

    I know I'm starting to get into a much more advanced architecture for this and ive spent the last googler 6 hours trying to find a procedure for how it works but I can't figure out a way to have the whiles stop waiting for RTD loop finish.  I guess that this is to divide the VI in several screws and construction of a library, but the resources I could find about it were not very useful for a beginner like me.  If someone could point me in the right direction on where I should look then that would be great!

    Thank you

    Zach

    Zach,

    Because you created the tasks of data acquisition elsewhere, we do not understand how you have set up. Continuously, starting and stopping tasks may be slower than setting up of a permanent task and let it run.

    You have not indicated that you use the DAQ hardware.  It is often better to leave in the DAQ hardware clock set ignition rather than rely on software distribution. The pressure loop reads 1000 samples at a time and calculates their.  If you're not sampling at 2000 s/s or faster, the loop ends late due to waiting for data.  In two loops DAQ, you do not use the calendar information.  Acquire the data in tables rather than waveforms.

    The Dequeue functions in the loop at the bottom have no wait times for this loop will not iterate until all three queues have data. As the pressure loop runs faster than the loop of RTD, the queue of pressure slowly fills.

    The upper and lower loops are vying for the data.  The preview queue item does not delete data from the queue, but the functions of the Dequeue elements in the loop of the low fact.  If data is deleted form the queue before the upper loop resembles it, it will never be saved. With your installation there is no way to ensure that you get all the data or that you do not read and record the same data more than once.

    You don't have anything set up to stop one of the loops.  You use the Cancel button to stop your VI?  If Yes, STOP! Other aprticpant on the Forums said: "using the button abandon to stop a VI is similar to the use of a tree to stop a car.»  It works, but can have unintended consequences. "Things like closing of files, freeing up the queues, by closing the task of acquiring data, and other things can occur when the program is interrupted.  You do not shut down your computer by pulling the plug.  Stop your program also neatly.

    Ok.  I have highlighted some of the things that can keep your program to run as desired.  What can you do about them?

    1. you probably don't need call loops.  Normal so the loop should be good enough.

    2 put a stop button on the front panel. Put the terminal in loops (bottom) and connect it to a function to send a Notification and the status of the Terminal loop (stop sign).  Put wait Notification functions in each of the other loops.  Put a period shorter than the time loop minimum on all of them if the lops can work.

    3. see the comments above regarding the DAQ bed material.

    4 use the Dequeue timeouts to adjust the pitch of the loop the loop where the data is used.  Also make sure that all data is removed.  You need to think about your time together and what are the bottlenecks.  Except if you expect this system to grow to much larger dat sets, I probably acquire ALL data (pressure and RTD) at the same rate and reduce the displayed amount by the average like you do for pressure data now.  If you want different final data rates, just average different amounts of data.

    5. it might be useful to learn how to work the State machines.  Display, averaged and recorded files could be managed in a loop by a simple state machine while allowing for more flexibility in the calendar.

    6. Another good reason to consider a state machine is that initialization and shutdown processes can easily be handled in the corresponding States. At this point you do nothing with errors. A state machine would enable you to handle errors (for example, the cancellation of the selection of the user files) without stopping the program.

    Lynn

  • repeatedly calling a dll that contains a loop

    I would like to call a dll function that contains a while loop. This copy of the data to a buffer loop a signal command "on" is true:

    void Get (double * x, double * y, double z *, double *, double * P, double * R, int on)
    {
    int index is Index - 1;.

    while(on == 1)
    {
    If (index > = buffersize)
    {
    index = 0;
    }
    * x = buffer [index]. Position [0];
    * y = buffer [index]. Position [1];
    * z = buffer [index]. Position [2];
    * Y = buffer [index]. Angles [0];
    * P = buffer [index]. Angles [1];
    * R = buffer [index]. Angles [2];
    index ++;
    }
    }

    I want to call this function from dll once 'on' is set to true and it ends once it becomes false. I also want to be able to 'on' on and outside, so that it can copy data from the buffer when I want to. I could not find a way to do it, and whenever I walk through the program it does not 'stick' when the Get function is called (i.e. the while loop inside the GET is running), as I would expect.

    Thank you for any assistance.

    I guess 'Index', 'buffersize', etc., is static variables?

    In any case, once you called the function expected of LabVIEW for the function to fill. You can not dynamically pass a new value for "on" during the execution of the function. Note that this is not a question of LabVIEW. The same would be true when using this DLL from any other programming language. What you need to do is to have the function use static 'on' and then provide a separate function to set this value. Note that you must also configure the COLD LAKE to be "incoming".

  • Series of reading and DAQ in same While loop

    Hello world

    I have a while loop that has a DAQ reading and a reading series of VISA.

    DAQ readings slow while loop for series com & therefore the iterative nature of the measures to constantly check byte-by-byte (for the full range of the code: 22 bytes) does not work. (it will check 8 bytes, 24,.. etc. because more bytes is collected in a buffer before it can browse new loop.)

    Is it possible to synchronize these two data acquisition devices?

    Data acquisition speed is fast enough, so if there is a way to keep the series bytes in a queue and take only the first 22 bytes for every while loop iteration?

    Thank you for your help. I can't join VI, but I can give you a reference image.

    I recommend having separate loops of data acquisition and reading series.  If you simply connect the latest value, the local variable is great for sending to playback in series to the other loop for logging.

  • How to end parallel while loops

    Hi, I'm using LV8.5.  I have 2 while loops, running in parallel.  Loop1 is faster (waiting time of 100 ms) and Loop2 is slower (several minutes waiting time).  I use a local variable (STOP button) Boolean to commonality between the loops.  The button is in the loop faster (Loop1) and the local variable is in Loop2.  When I try to end the While loop, Loop1 stops immediately, while I have to wait for Loop2 finish.  Is there a simple way to make two loops to stop immediately?  I have been using a Control\Stop Application, but may not be the right solution.

    Thank you.

    Hi shanx2,

    reduce waiting time in your second loop and count the iterations instead. The loop will do the same, but the stop will react much faster. Another possibility would be to use a queue instead. Connect to a timeout that corresponds to the current time-out period, you use and send a message to stop the loop. You can choose between the queue has been exceeded or not. Connect this result to the conditional loop. You can send the message from the queue after the first loop was arrested.

    Mike

  • Code Golf: stop two while loops with guaranteed ratio iteration

    Proposal

    In the vein of the tradition of Perl, I would like to see if there is any interest to solve a few puzzles programming in LabVIEW. Can someone post a problem and define the rules to solve.

    Here's a question for beginning/intermediate to sharpen your "palette".

    Description

    With a user action, how you would stop two while loops such as the relationship between iterations is the still the same? Concrete to view this situation is to take action: both instruments use the same source of synchronization to take measures, but second divides the clock down so that it is a little slower than the first whole factor. For example, if the slower instrument is four times slower, then at the end of the VI, the slower instrument takes 100 measures the fastest instrument took 400.

    Rules

    • You can use vi.lib
    • You cannot include any other subVIs
    • Your solution should pass for loop1 interval as low as 25 ms

    Model (joint in LabVIEW 2009)

     

    If people are interested in this, then we will find a way to improve future problems. Please post your suggestions and criticisms, but only if you also post a presentation ;-)

    MacNorth wrote:

    [..]

    If we choose the first suggestions, the VI has yet to recover the data at different speeds. You can dedicate a loop for each instrument to disassociate a jitter and latency introduced by their connectivity or the inner workings. This adds a margin of safety when there is a conflict of thread and the pilot. You can also implement a simple counting as altenbach loop and renounce the multiloop complexity.
    [..]

    It is a very good point. But I wanted to make sure, you should / need to discuss the benefits, but also the disadvantages of the design. Implementation of an application is most often a process of 'special cases '. If a framework/design for a single application model does not necessarily correspond to another application.

    Designs are always strongly according to the requirements and constraints. What gives here designs will result in educational services, of course, but not necessarily as reference models for specific applications.

    Advantage of simple loop:

    • No synchronization between several loops required
    • Can easily implement any whole factor between services (quotent & function remains for a case structure

    Disadvantage of simple loop:

    • Take advantage of the multi core systems (at least not much)
    • Can easily run out of the time constraints (material not "not responding" enough, fast manipulation of data takes too long,...)
    • Code will accumulate within the structures of the case, where the readability could suff

    The advantage of multiple loops:

    • See essentially the disadvantages of single loop (several loops solve those)

    Disadvantage of multiple loops:

    • More complex, especially for the sync switch (not beginner friendly, requires a more/better design)
    • May contain easily questions source such as race conditions and locks

    A little side note:

    Even if the equipment works different acquisition rate, this does not necessarily that the software must use different rates for data extraction. You can use the same model of an hour, but get X times more values for the task faster than the slower running. The 'only' thing to care of are the sizes of buffers and bottlenecks in the data transfer.

    MacNorth wrote:

    [..] The best advice published OR shutter multiple while loops (https://www.google.com/search?q=labview+stop+multiple+while+loops) are laughable (and the 'solution' in my model). [..]

    No, it's not laughable. For many applications, this approach to shutter at the same time several loops running is OK. The constraint: only for simple parallel running loops.

    More complex loops (producer/consumer and similar) with the more complex data relationship ships require more valiant approaches such as queues, declaring events or user.

    My 5 cents only,

    Norbert

  • Timed loop versus While loop

    Most of the machine control software I design have the following structure:

    1. There's a HAND that takes place inside a TIMED LOOP with synchronization of 50ms and priority of 100. His only job is to read / write data from / to DAQMx IO cards.

    2. the MAJOR can call several SUBs based on the choice of the user, and once a submarine is called FP MAIN is closed and the FP SUB opens. All submarines have a States Queued Machine running within a TIMED LOOP with 50ms timing but with priority to 50.

    3. data transfer between HAND / SUB is through function globals - there are many of them based on past data.

    4. all woks fine so far. No need to any RTOS. and platform of WIN7 is alomost standard. I even ran with a timing of 20ms without anything crashing...

    Problem: When there are a lot of file i/o operations in a SUB partciluar, then I have the chance to see several missed iterations. Perhaps the TIMED LOOP is hogging resources.

    What I want to do: convert both TIMED in asnd SUB HAND loops simple while loops.  But I am concerned by the priority - since the MAIN interacts with HW there priority. But with LOOP WHILE how can I ensure this?

    Or is there any replacement / effective way of doing what I do now?

    Rama wrote:

    .... FGV should be thrown out the window...

    Well used for a while, based on many articles in the KB. One of them is locked... and it does not represent the engine of the Action or of the FGV as a villain to avoid.

    The driving force is one of the largest buildings in LabVIEW.  The FGV who does nothing but Get and Set (or writing and reading) is useless and a waste of resources.  Why?  It does nothing to fix possible race conditions (does not protect critical sections) and it is much slower than just using a global variable.  See this example I put in place to see what I mean: an overview of the race Conditions.

    Rama wrote:

    So in the sample that I had attached, what do you think would happen if I just replaced the two loops with the SAME timed in MAIN and SUB wait value ms. is there a work order then?

    When things are at the same time, there is no such thing as the order of execution.  But as I said, it seems that your loop is quite slow, so it's something I would not worry.  Just make sure that you do not have a loop that uses all the CPU.

  • Sharing data between multiple while loops, competitor rates

    Hello

    I am trying to Exchange data between competitor while loops running at different speeds.  What is the recommended way to do this?    In practice, I have 12 indicators and 3 cards I would update (on screen) in the slower loop, although the data acquired and stored on disk in the fastest loop.  The image below is a simplified version of what really works my candidacy.

    I currently use local variables and shared to achieve this.  I heard however that local variables are evil because of their use of memory (data are copied instead of who passed by reference).

    Thanks for your suggestions,

    Adam

    Hi Adam,.

    Yes, here you go.

    Mike

  • Need help to use while LOOP to run immediately

    Hello

    I use the Oracle 11 g R2 database.

    I need to use 'while' below statement so that I'm going to immediate execution with the following ranges in a LOOP.

    USING 100, 200
    USING 201, 300
    WITH THE HELP OF 301, 400
    USING 401, 500
    declare
    v_maxseq_id number:=100;
    v_minseq_id number:= 500;
    
    begin
    --WHILE LOOP
    
    EXECUTE IMMEDIATE 'insert /*+APPEND*/all into stage_parsed_while
    select * from STAGE_PARSED_h2 WHERE src_file = ''a'' AND load_date = ''03-apr-2013''
    and seq_id between :1 and :2'
    USING v_minseq_id , v_maxseq_id ;
    
    
    end;
    Kindly help... Thank you

    Your syntax for the While loop:

    set serveroutput on;
    declare
      i pls_integer := 101;
    begin
      while i < 500 loop
        dbms_output.put_line('Min :: ' ||i || '; Max :: ' || to_char(i + 99));
        i := i + 100;
      end loop;
    end;
    
    anonymous block completed
    Min :: 101; Max :: 200
    Min :: 201; Max :: 300
    Min :: 301; Max :: 400
    Min :: 401; Max :: 500
    

    And Yes, I'm agree with suggestion of knapen to accomplish the task with a single static SQL, rather than go for dynamic SQL (which is the first wrong approach) and then using loops to slow further (which would be another mistake).

  • Problems to use TimerEvent in While loop

    Hello

    I try to use a while loop a TimerEvent. In the example below, I created the function init should loop through values myArray, tracing of each value to every three seconds. It seems, however, that because I am incrementing the value currentNum outside the while loop (from the timerHandler function), the just loop continues to turn until the Flash no longer responds.

    var myArray:Array = new Array ("one", "two", "three", "four", "five");

    var currentNum:int;

    myTimer var = new Timer (3000, 1);

    function init (): void {}

    while (currentNum < myArray.length) {}

    trace (myArray [currentNum]);

    myTimer.addEventListener (TimerEvent.TIMER_COMPLETE, timerHandler);

    myTimer.start ();

    }

    }

    function timerHandler(e:TimerEvent):void {}

    currentNum += 1;

    }

    init();

    I wonder if what I try to do is just simply not possible or if I'm missing something.

    Thanks in advance for any thoughts on the issue.

    This loop will run at the speed of light of the processor.  Put the timer inside it will not slow down it.  Chances are that you do not want to use a loop of any kind other than that which is developed through the use of the timer and the single event handler function.  Maybe together the repeat of the timer value be based on the length of the array.

  • How to increase code efficiency in a while loop (using PXI5105 for sampling outside signal digitalizer)

    Theoretically, we want the PXI-5105 (digitizer) have 302 record with each record has a 1260 sample (the save operation is inside a while loop) in approximately 30ms, however we have found that for each period (30ms), the PXI5105 only perform about 10 records. It is so wired. I wonder if the operations inside the while loop consume more time (for example 3MS), so that he cannot have 302 records even the PXI-5105 have 60 M/s speed of sampling. Is it true, you can find my labview code and if possible can you give me some suggestion in the most short time of operation of the loop.

    Please find attached labview code.

    Hi g_l_g_s,

    The digitizer PXI-5105 acquires data at the speed that you specify and stores the data in its memory embedded (up to 512 MB). The data is then sent to your computer when the Multi Fetch Cluster.vi is called. In VI that you posted, you are only fetch record during each while the loop iteration. If you want to retrieve 302 records you will need to specify 302 files in the horizontal Timing.vi to configure. For more information about scanners, you might find the DevZone, hereuseful.

    To determine the amount of time it takes for each while the loop iteration, you can consider using the structure of code in the example comparison community calendar, which is located here.

  • structure of the event + while loop

    Hello, I am trying to understand how to unite two while loops in attached VI for half a day

    The first loop creates a state machine solid which reacts on each key and runs one of the structure cases. (that part works very well)

    The second loop, always generates the random number, but it stops the generation during the time where one of the structure cases events are executed. (this is the part ticky)

    Any suggestions?

    If you want your random number to stop so that the user triggered events are running, you should be able to simplify your design a lot.

    It can be done with a loop using the case of timeout.

Maybe you are looking for