question the effectiveness, loop or brute force?

Hey guys,.

I consider not really myself to be a programmer, more like someone who has the possibility of falling through and make things work. I always try to improve my working methods.

I thought this question the other day, and the option to select either option just came in a project working on im. When I ask this question, that I'm more interested in a general best practices context not really a context "I need this code runs as fast as possible."

the problem I have is that I need to run a sub VI twice to access both engines on my robot, the command to access the first engine of the second engine is one of the other, IE. engine is 5 and engine control 2 is control 6. My first idea was to create a for loop and add the first engines offset to the index of the loop and execute the loop for two itterations.

Then I had a colleague just look over my shoulder and ask why I have not just to create the sub vi twice and do not use the loop.

I know that these accomplish the same thing but I like to try and better myself as I said above, what are the advantages and disadvantages of each method and is one favorite on the other?

Thank you guys

The user preference is certainly a part of it, but when it comes to 'best practices', using the loop seems the best option if only for the sake of extensibility. In case you plop the Subvi down twice, you'd have to wire an individual value of each. However, with a loop for example, you can programmatically create a table and feed it to the Subvi same as many times as you wanted. This would facilitate adding devices.

Tags: NI Software

Similar Questions

  • Starting Point question the effect

    I guess there is an obvious answer, that I can't understand.

    In short: I changed the starting point of a video clip of 10 seconds at the beginning of the clip.  When I play from scratch on the timeline WITHOUT active effect, the clip starts exactly to the point that I put.  If I activate an effect (it seems not to matter of what one is), the clip starts now at the very beginning of the clip, ignoring my point of departure edited 10 seconds.

    The 10 second point has been moved to the left of the timeline, and the workspace starts at zero.  Even when I apply something as simple as the Hue/Saturation, the same thing happens... once the effect is applied, when I click to play the clip, even if my 10 second point shows zero, the clip will now play at the beginning of the clip.

    Thanks in advance,

    Keith

    Something is happening with the temporal effects like Echo? Remapping of the time / Time-active stretching? Otherwise, the behavior might indicate that a problem with OpenGL accelerated effects processing and your card is not worth, so try and disable the OpenGL option in the preferences.

    Mylenium

  • Change to the Question of the effect of color

    Hi This is only my second year really using after effects and I've not really used this feature before. But basically, I want to make the color of the water kettle. His white origin. Now, I don't expect the change of color to exactly match the kettle. But when I use the function to color the kettle from white to pink (a bright color), it works pretty well actually. But when I try to color as a darker color, that it does not work. I need to change the hue, brightness and Sam for this has no effect, but it is not fully complete as the rose. How can I change the color of a brown colour only. Ive has messed around with it for a couple of hours now and I'm kind of stuck. Is it possible to do what I did for the pink kettle for the Brown kettle. I hope it's clear. Let me know if something needs to be clarified.

    I recorded my workflow here. As you could see the brown color change is very wet and does not work with only the hue. While the pink kettle has functioned very well. I don't understand how I got the pink color in the video, but I just enabled the effect on this clip.

    2016 04 04 16 01 42 669 - YouTube Bandicam

    Any help is appreciated thank you.

    There is nothing to do. In: it's all just a bad workflow and you wait too long. You answered your own question already in part: use other effects, use several layers manually create masks and hiding.

    Mylenium

  • Scroll through the question of the effect

    Hello.

    scenario of
    I'll put up an object when you click it, you are returned to the top of the page.

    I chose to use scrolling effects for it.

    Question

    I use a screen 1920 x 1080 and so the effect of scrolling is set to this standard.

    When I test the site on a smaller screen, the object is out of place, or even off screen.

    Is there a way to make the static object, or put it to a point on the screen it always follow when scrolling on any size monitor?
    have


    Thank you!

    You can pin the object in place, so when you scroll down to the bottom of the page that remains in the same position (instead of scrolling effects)

    Given the scope defined on the left side of your screen should ensure that it is visible on all the monitors of size.

  • How to get an overview of the effects of the question slide?

    Captivate 5
    Win XPSP3


    Problem: how to have an overview of the effects (such as drop shadow) applied to the objects (jpg) on a question slide.

    Situation: Quiz to tell 5 random questions drawn from a pool of 50 questions multiple choice.


    Questions pool Panel:
    I'm building the Quizzing question slides workspace.
    I can view the slide and add questions and answers + jpg images that may be necessary.

    If I want to add a shadow to an image, I select the object (img) and place you in the effect controls panel.
    I add a drop shadow and can make adjustments, BUT the effect is not visible on the slide.


    The Live Preview button is grayed out and unavailable.


    Overview of the toolbar options are...
    F3 slide... Does not show the effect.
    F4 project... would take too long AND would be not safe to view the slide at which I had added the image effect.
    F12 browser... shows the entire project with 5 random questions but not necessarily the specific slide.

    Am I on the Filmstip Panel:
    There are several options preview...
    F8 this slide... If I select a blank Question slide at random, it shoots a question of the pool of 50, but not necessarily that I'm working on.
    F10 then 5 slides... same problem as F8

    Unacceptable workaround solution:
    I can create another pool 'test', containing one question.
    Copy slides edited to "test the pool and the preview with F8 or F10.
    A lot of extra work...

    Then the effect works and would weigh on the finished quiz... BUT... I can't (without a lot of P'ing on) Preview and adjust effects applied to a question slide.

    Someone at - it ideas?

    Concerning

    Frank

    If you want to test the effects on a particular slide of your pool of the Question, and you don't want to publish all slides to see it, just click with the right button on the slide in the question pool and select move Question to > the project main.

    Then, you will be able to preview the effects as with any other slide.  When you know that the slide is over, just get him back in the Question pool.

  • Force the While loop to exit when the delay is running

    Hello guys,.

    I have a While loop containing some jobs. One of them is delay for 10 seconds. When I push the stop button, the loop does not stop immediately. Instead, it stops after a few seconds (can be, pending other jobs is done).

    What can I do if I want to stop the loop immediately after I press the stop button?

    Thank you for sharing...

    Hello Yoppy,

    I don't know if I understand your problem completely, but here's the method I use to stop the while loop immediately (some ms delay will be there for you).

    I would like to know if the attachment helps.

    There are several ways to do it and you can get better solutions than this one on this community.

  • The effects turns OFF automatically

    Regularly after 2/3 days effects (when opening application it is effect type zoom to open the application or at the opening of the iphone lock) turns off automatically. Also during the opening of multitasking or any application. After you restart the iphone, it resolved for 1/2 days. And yet, the question arises after 2/3 days.

    This problem is coming into my iPhone via ios 9 now plowing 9.3.1

    We can show in pictures how effect stops. So I can not download.

    First, try a forced reboot. Obviously, you will need to wait a few days to see if his works. It will affect all the data.

    To force the reboot your device, press and hold the two buttons of sleep/wake and home for at least ten seconds, until you see the Apple logo.

    If the forced reboot does not fix it, try this. Reset all the settings. You won't lose any data, but all the parameters of the device will have to be entered again in the settings app. This includes the WiFi network passwords, settings > general > reset > reset all settings.

  • To break out of the while loop (1)

    Hi all

    I have a simple question that if a callback to a command button function, I use a (bLoop) While
    loop, where bLoop is a boolean variable has the value TRUE, then how can I break up or out of this while loop by using a control on the façade, which released the while loop by setting bLoop = FALSE.

    I tried, but it didn't come out

    The problem here is that the CVI normally only runs a reminder at a time. While you are in snooze control, no treatment of GUI and subsequent calls to other reminders usually occurs.

    You can try the following approach-, but it's not really the best method:

    While (b_loop) {/ / within a reminder}

    ... / / Do your tight loop

    ProcessSystemEvents ();   Force the CVI to see if all the GUI needs maintenance controls

    }

    If you have a reminder of different control to erase the global b_loop, this packing approach might work for you.

    You must use this technique for very simple programs - it can quickly escape out of control and in the end upward in a mess if you're not careful. OR recommend that you use not ProcessSystemEvents() within a point of order.

    JR

  • The truth about the IMBRIQUEE LOOP

    Hi Experts,

    Yesterday, I looking for the differences between IN and there ARE operators. I googled and I read a thread in the site of Tom Kyte (http://asktom.oracle.com/pls/asktom/f?p=100:11:P11_QUESTION_ID:953229842074). In short, Tom wrote that the use of these two operators are different. They are also treated differently by the optimizer. IN operator works more like join two tables (hased, sorting, etc.) On the other hand, works longer EXIST as LOOP IMBRIQUEE. In other words, the inner loop runs once for each row in the outer loop. He also suggested that if the sub query is very large and high query in small. And let's say that the index of use of subquery, operator EXIST becomes much more appropriate. However, if the subquery is small FOR operator to become effective.

    In addition, Jonathan Lewis also mentions the nested loops in his book (based on Oracle Fundemantals costs) with a chapter. He says the following.

    "The execution plan of a join on the inner table index nested loops can have two different forms of 9i from: a when the optimizer uses the index on the inner table for a single scan and another when the optimizer uses the index for a range scan." The second form ceases to be an option, however, if the external table is guaranteed to return a single line. »

    My question is, if you look at the loop nested within query plans. It always works as a line returns unique index for Each row of the outer query as follows. I mean that you can come through a loop nested between two tables with FULL TABLE SCAN (usually used for this hash join). The optimizer work like this? If the join condition contains indexes between two tables and one of them is quite huge according to the other. Then the optimizer always uses NESTED LOOP rather than other join methods?

    If the above is correct, can we write the following formula?

    NESTED LOOP = QUERY EXTERNAL (a low num lines FTS) & SUB QUERY (a high number of lines with INDEX)

    ----------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ----------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |         |     1.    58.     4 (0) | 00:00:01 |

    |   1.  NESTED LOOPS |         |       |       |            |          |

    |   2.   NESTED LOOPS |         |     1.    58.     4 (0) | 00:00:01 |

    |*  3 |    TABLE ACCESS FULL | EMP |     1.    38.     3 (0) | 00:00:01 |

    |*  4 |    INDEX UNIQUE SCAN | PK_DEPT |     1.       |     0 (0) | 00:00:01 |

    |   5.   TABLE ACCESS BY INDEX ROWID| DEPT |     1.    20.     1 (0) | 00:00:01 |

    ----------------------------------------------------------------------------------------

    Concerning

    Charlie

    The optimizer uses nested loops"when the following conditions are met:

    • The database attached to small subsets of data.
    • The join condition is an effective way to access the second table. ":

    The query optimizer

  • Backups and the effectiveness of programming main HP

    I'm contemplating writing a program quite prepared for the first HP and I wonder about the effectiveness and backups.  I have several questions that I couldn't find answers to in the Guide of use or in other posts.

    (1) I understand that HP connectivity Kit will allow me to transfer programs between the emulator and the calculator back.  But is it possible to record my programs custom from the emulator on my computer?  I would like to have a backup of text files.

    Is there a way to write the text file to my laptop and then copy to the first HP?

    (2) is there any detailed info on the connectivity for the first HP HP Kit?  It is unique to the HP Premium, or is it the same thing as the other calcultors?  It is part of the package of HP Prime, or is it an additional purchase?  The User Guide is available yet?

    (3) all about programming the calculator seems inefficient.  Of programming in the emulator seems slower than if I used a dedicated text editor. (However, I remember wrote some quite long programs on the single line of my HP 41 c years.)  Is there an easy way to cut and paste the text from my computer in the emulator to test the program?

    Thank you

    Nick

    > I understand that HP connectivity Kit will allow me to transfer programs between the emulator and the calculator back.

    In fact, you don't have even the Connectivity Kit for this.  The emulator and the Calculator programs transfer directly to each other with a single press of the Send button.  You have even press reception (there is no this key), or specify where to send them to.  You press just send, and the program will appear instantly in the other first.  Cool, huh?

    > But is there a way to record my programs custom from the emulator on my computer?  I would like to have a backup of text files.

    Yes, and it's completely intuitive.  In the program editor, you just COPY EVERYTHING, then paste directly into your favorite text editor on your computer, where you can edit and/or save it as you like.  You can also transfer programs from your computer to the emulator or the calculator by copying the source code of plain text in the text editor of your computer, and then paste in the emulator or a calculator.  It couldn't be simpler.

    > Is there any detailed info on the connectivity for the first HP HP Kit?  It is unique to the HP Premium, or is it the same thing as the other calcultors?  It is part of the package of HP Prime, or is it an additional purchase?  The User Guide is available yet?

    The "HP connectivity Kit" and its documentation are on the CD that came in the first package of HP.  It's not the same program as Conn4x (the "Calculator Connectivity Kit" for the HP 48/49/50 series).

    > All about programming the calculator seems inefficient.  Of programming in the emulator seems slower than if I used a dedicated text editor. (However, I remember wrote some quite long programs on the single line of my HP 41 c years.)  Is there an easy way to cut and paste the text from my computer in the emulator to test the program?

    As mentioned above, you can easily copy the plain text source code in your favorite editor on PC and then paste it directly into the program editor is in the emulator OR the calculator.  And vice versa.

    Some text editors on PCs, such as TextPad to Helios Software, allow syntactic macros and customizable.  These tools are very useful for the first programming.

    > I realize that the connection Kit may be just a special USB cable.  Is this fair?

    In fact, it's just.  It uses the same USB cable by the calculator to recharge its battery and to communicate with the emulator.

    Hope that helps!

  • How can I remove the "subtitle" that comes after the main title of the effect of title page of Chronicle?

    I use Final Cut Pro 10.1.3 I have a question about the effect of the title page, or the "browser title". I chose the 'Chronicle' effect which contains a main title as a second line that says "subtitles". I don't know how to delete or change this second line. Help please.

    Select this text directly in the viewer and change

  • global variable functional to read and write data from and to the parallel loops

    Hello!

    Here is the following situation: I have 3 parallel while loops. I have the fire at the same time. The first loop reads the data from GPIB instruments. Second readers PID powered analog output card (software waveform static timed, cc. Update 3 seconds interval) with DAQmx features. The third argument stores the data in the case of certain conditions to the PDM file.

    I create a functional global variable (FGV) with write and read options containing the measured data (30 double CC in cluster). So when I get a new reading of the GPIB loop, I put the new values in the FGV.

    In parallel loops, I read the FGV when necessary. I know that, I just create a race condition, because when one of the loops reads or writes data in the FGV, no other loops can access, while they hold their race until the loop of winner completed his reading or writing on it.

    In my case, it is not a problem of losing data measured, and also a few short drapes in some loops are okey. (data measured, including the temperature values, used in the loop of PID and the loop to save file, the system also has constants for a significant period, is not a problem if the PID loop reads sometimes on values previous to the FGV in case if he won the race)

    What is a "barbarian way" to make such a code? (later, I want to give a good GUI to my code, so probably I would have to use some sort of event management,...)

    If you recommend something more elegant, please give me some links where I can learn more.

    I started to read and learn to try to expand my little knowledge in LabView, but to me, it seems I can find examples really pro and documents (http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/ , http://forums.ni.com/t5/LabVIEW/Community-Nugget-2009-03-13-An-Event-based-messageing-framework/m-p/... ) and really simple, but not in the "middle range". This forum and other sources of NEITHER are really good, but I want to swim in a huge "info-ocean", without guidance...

    I'm after course 1 Core and Core 2, do you know that some free educational material that is based on these? (to say something 'intermediary'...)

    Thank you very much!

    I would use queues instead of a FGV in this particular case.

    A driving force that would provide a signal saying that the data is ready, you can change your FGV readme...  And maybe have an array of clusters to hold values more waiting to be read, etc...  Things get complicated...

    A queue however will do nicely.  You may have an understanding of producer/consumer.  You will need to do maybe not this 3rd loop.  If install you a state machine, which has (among other States): wait for the data (that is where the queue is read), writing to a file, disk PID.

    Your state of inactivity would be the "waiting for data".

    The PID is dependent on the data?  Otherwise it must operate its own, and Yes, you may have a loop for it.  Should run at a different rate from the loop reading data, you may have a different queue or other means for transmitting data to this loop.

    Another tip would be to define the State of PID as the default state and check for new data at regular intervals, thus reducing to 2 loops (producer / consumer).  The new data would be shared on the wires using a shift register.

    There are many tricks.  However, I would not recommend using a basic FGV as your solution.  An Action Engine, would be okay if it includes a mechanism to flag what data has been read (ie index, etc) or once the data has been read, it is deleted from the AE. 

    There are many ways to implement a solution, you just have to pick the right one that will avoid loosing data.

  • What happens when you specify multiple iterations of the parallel loop that you have processors?

    I have an app that does the same things together up to 10 times for different material resources. For example, I have a list of 10 COM ports I want to send orders series. I want that they be executed as close to synchronous as possible, but up to 200 ms sync would be acceptable. Currently, I use a loop set up to 10 parallel iterations and assume that LabVIEW will juggle processors according to the needs, the iterations run it as simultaneously as possible. Experimentally, LabVIEW indeed seems to create 10 parallel loops, even when running on a computer with only 4 logical processors, otherwise you go 10-element inside the loop would only be not able to complete, right?

    My question is, I'm doing something verboten with my number of iterations of the loop? According to the help of LabVIEW for loop iteration parallelism dialog box: "If you plan to distribute the VI on multiple computers, set number of instances of parallel loop generated equal to the maximum number of logical processors, you wait for one of these computers contain never.» Clearly I'm violating this opinion and yet it seems to work. My performance will essentially be the same as if I had 10 blocks of code in parallel on the block diagram?

    "Reading'how many Threads don't LabVIEW allocates?" links to this page, it seems that, at worst, LabVIEW is hungry for thread and switching of threads between iterations, but my short demand slowing down enough to accommodate this suboptimal situation. At best, LabVIEW has allocated 4 threads per the enforcement system, so as long as I have at least 3 processors, there are at least more son than the parallelized loop iterations. It's all a bit confusing.

    RnDMonkey wrote:

    I have an app that does the same things together up to 10 times for different material resources. For example, I have a list of 10 COM ports I want to send orders series. I want that they be executed as close to synchronous as possible, but up to 200 ms sync would be acceptable. Currently, I use a loop set up to 10 parallel iterations and assume that LabVIEW will juggle processors according to the needs, the iterations run it as simultaneously as possible. Experimentally, LabVIEW indeed seems to create 10 parallel loops, even when running on a computer with only 4 logical processors, otherwise you go 10-element inside the loop would only be not able to complete, right?

    My question is, I'm doing something verboten with my number of iterations of the loop? According to the help of LabVIEW for loop iteration parallelism dialog box: "If you plan to distribute the VI on multiple computers, set number of instances of parallel loop generated equal to the maximum number of logical processors, you wait for one of these computers contain never.» Clearly I'm violating this opinion and yet it seems to work. My performance will essentially be the same as if I had 10 blocks of code in parallel on the block diagram?

    "Reading'how many Threads don't LabVIEW allocates?" links to this page, it seems that, at worst, LabVIEW is hungry for thread and switching of threads between iterations, but my short demand slowing down enough to accommodate this suboptimal situation. At best, LabVIEW has allocated 4 threads per the enforcement system, so as long as I have at least 3 processors, there are at least more son than the parallelized loop iterations. It's all a bit confusing.

    In this case (where you're interacting with the external hardware and have an appointment) there will be a delay of inheirant at each iteration.  THUS, "Oversubscibing" or by allowing the parallel proceedings as logical processors, actually improves performance by running another period of waiting during the iteration.  In fact, you're not "Violate the advice" of oversubscibing.  You use this technique correctly! Just may not have read about this.  See Esp PP 4

  • Sequence structure flat inside the timed loop and execution order

    I have some problems trying to implement a flat sequence structure when you use a loop timed on a target of cRio VI

    I tried with or without the while loop around the structure of sequence flat, and I also tried to replace the 'Non-deterministic loop' with a timed loop

    The problem is that the program seems to run only once, then get stuck somewhere

    I am writing a program that performs the following operations as soon as possible:
    1. read the Pos_MC of entry on the FPGA
    2 send the value of Pos_MC to the VI target (on cRio CPU)
    3. calculate a value of output based on Pos_MC with a PID block ("exit PID')
    4. send 'PID output' to the FPGA
    5 write "PID output" analog output "MOOG".

    In addition, I want the program to return the measured value "Pos_MC" to a host VI for the recording of data

    So that the output of PID is calculated and sent to the FPGA as quickly as possible, I placed a flat sequence structure to ensure that it happens before you send the output to the nondeterministic loop for recording data

    Also, I want the digital input 'Stop' to be able to stop the loop deterministic (the timed loop)

    I read much more entries than that and the help of several PID and exit, but I rewrote the code for a single entry and exit to make it easier to illustrate

    Screenshot of the code is shown in 'target code.png' and 'fpga code.png.

    The VI themselves are attached in the next post (cannot attach files of more than 3)

    Question 1:
    Any advice on how to get this race? Thank you!

    Question 2:
    Is also my correct understanding in that, using this structure, each 0.9ms (fpga loop time) comes the following:
    1. the input ("Pos_MOOG") is read on the fpga
    2. the production of PID is calculated on the cRio with some delay to computation (for example 0.1ms)
    3. the output of PID is then written for analog output "MOOG" in all about 0, 1 - 0.2ms
    4. the FPGA program then waits until 0.9ms spent and repeat the process

    As opposed to the next pass whenever performing a loop is started on the FPGA:

    1. the FPGA reads the input and written on the output (the output of the execution of the previous loop PID)

    2. then the entry is sent the cRio, PID output is calculated and sent to the FPGA

    3. the new release of PID is maintained until the next time through the loop

    Thank you!

    PHG wrote:

    Thanks for the input guys, any advice as to how I could get the feature in scenario 1?

    I still say that the best route is just putting all the logic of the control in the FPGA.

    Other alternatives include 1) the use of DMA FIFO sedn data back or 2) use interruptions so that the FPGA code can not read the output level until the RT.

    DMA FIFOs are usually very limited, and I would not use them in this situation since I belive said it this code to do for the many outputs.

  • Impossible to click on the buttons for the timed loop.

    Hello!

    I have a loop that is timed with a pace set by the user. And when the loop is running, I can't push any button of my GUI to stop it...

    I have to wait until a mistake or I stop the race.

    I can't put the diagram is too big and I think I don't have the right, but you have ideas?

    Ask me for more details.

    Thank you

    bejard wrote: timed loop is just in a structure of the event and I put 10 ms or 100ms.

    The program runs correctly (with this loop delay of 10ms/100 ms) like in the beginning, but I can't push any button or even change the tabs during the loop.

    You shouldn't have long extensions inside the event.  Which is supposed to stop your timed loop?

    I think that you have the option "Lock the front until the end of the occurrence" lit.  It will not press anything, until the end of everything for this case (including the timed loop).

    According to my experience, using a loop timed in a Windows system is a complete waste and often adds more overhead and questions.  Instead, I really think you need to use a State Machine.  When the button is pressed, you tell your state machine to move to the State the code inside your timed loop tracks.  You can use the State with the structure of the event to time your loop.  If you can go behind your state of event to your processing loop structure.  Just set the timeout on the structure of the event at any rate of loop you really want to.

Maybe you are looking for