Algorithm to SubVI

I created a VI to verify that a data file is formatted correctly.  I simply created a file path control and LED indicator.  For development, I added an "OK Button" with the algorithm inside it's "Value Changed" event. 
I now want to make my algorithm a subVI.  Would it be better to remove the event loop, or should I wire the OK Button to an input terminal to call the routine?

The latter part won't work because all that you'd be passing is the value of the Boolean, and the subVI would have no way of knowing if that's from a control or a constant. While you could pass in a control reference of the button and do dynamic event registration, that would be fairly pointless in this situation. Just have the subVI with the file path control and indicator. No event structure in the subVI. Keep the event structure in the main VI. When the user presses the button, call the subVI.

Similar Messages

  • How can I create a subVI that has state?

    I'm trying to simplify a VI that I inherited and I noticed a recurring pattern that IMHO should be a subVI.  The pattern is that we have a digital output line that is controlled by a timer.  Each output has a start time for it to activate and a duration after which it is turned off.  When the state changes, a single line entry is added to a common log file and an indicator shared variable is set so that the remote host VI updates.  We have a big while loop that checks the current time against each of the activation conditions.  To detect when the state has changed, we're using a shift register (for each actuator).  It's one thing to see the same pattern 3 times, but it's worse -- we want to sometimes use a different number of actuators.  If I was writing this in C++ (with which I'm far more comfortable than LabView), I'd write a class for the actuator and instantiate it N times.  The class would have member data to keep track of its state.  I can create a subVI that does the meat of the design pattern, but I can't figure out how to store the previous state in the subVI without requiring it to be passed in.  How do I keep the state and behavior of a VI together?  Surely there's a way to do this because otherwise I can't see how you could implement state-ful algorithms like, say, a PID controller.  But I'm at a loss to figure it out ...
    Thanks.
    Keith.

    To save state in a subVI and not use that state in other subVI calls, make the subVI reentrant.  When a subVI that is reentrant is called it creates a unique memory space for that subVI.  This is called a clone.  That memory space is where state is held for that subVI.  Keep in mind that it also means that the memory footprint is going to be larger.
    To set a subVI to be reentrant, open it and go to File -> VI Properties and select execution.  It will be a choice on the bottom left.
    Hope that this helps,
    Bob Young
    Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
    DISTek Integration, Inc. - NI Alliance Member
    mailto:[email protected]

  • LV OOP when using accessor methods (subVIs) or bundle/unbundle operation?

    Hello
    When should I use the (private) accessor methods (subVIs) and when the bundle/unbundle operation to access the class data? What is the reason that the bundle/unbundle operation is introduced to LabVIEW OOP? I need some rules for a coding guideline.
    Thanks
    Solved!
    Go to Solution.

    Thanks for your hints. I wanted to understand the differences between a private vi access and the unbundle operation like in the picture.
    I found some more explanations on the website: http://www.ni.com/white-paper/3574/en
    -> "Creating "read" and "write" methods for every data value in a class is a process acknowledged to be cumbersome. LabVIEW 8.5 introduced the ability to create accessor VIs from a wizard dialog, and LV2009 added further options to that dialog.
    We were concerned about the performance overhead of making a subVI call instead of just unbundling the data. We found that our current compiler overhead for the subVI call is negligible (measured between 6 and 10 microseconds on average PC). A bundle/unbundle operation directly on the caller VI versus in a subVI is nearly the same amount of time. We do have an issue with data copies for unbundled elements because much of LabVIEW's inplaceness algorithm does not operate across subVI boundaries. As a workaround, you may also choose to avoid accessor methods in favor of methods that actually do the work in the subVI to avoid returning elements from the subVI, thus avoiding data copies. This choice is frequently better OO design anyway as it avoids exposing a class' private implementation as part of its public API. In future versions, we expect that inlining of subVIs will become possible, which will remove the overhead entirely.  
    We feel in the long term it is better to improve the editor experience and the compiler efficiency for these VIs rather than introducing public/protected/community data."

  • Algorithm comparison FLOPS

    Hi Everybody,
    Is there a method to compare two algorithms in Labview(v.7) when it comes to their floating point calculations or number of FLOPS?
    I am looking to compare two algorithm (roughly),  something like FLOPS command in Matlab if any. I know one way for performance comparison might be comparing their looped execution time. But any FLOPS alike command ?
    Thanks

    Hed wrote:
    FLOPS is just the number of floating point operations.
    The more common definition is "FLoating point Operations Per Second", comparing different hardware with the same algorithm.
    http://en.wikipedia.org/wiki/FLOPS
    (You seem to be using the plural definition of FLOP, which is not as common, comparing the number of operations needed to perform a certain task, irrespecitve of hardware).
    Both definitions are not really useful to compare two algorithms in LabVIEW. The only thing you should do is compare the timed performance between the two algorithms. Be aware that even the same algorithm can be implemented more or less efficient, depending on the skill and knowledge of the programmer. Make yourself a small bechmarking operation as a three-frame flat sequence. Make sure that nothing can run in parallel with the middle frame. Pure coding cosiderations such as "inplaceness" and avoidance of extra datacopes are crucial for very efficient code.
    Take a tick count in each edge frame and place your code in the middle. If it is a fast code, put it in a loop for a few million iterations. Take the difference in tick count and divide it by the number of iterations, convert to seconds, and display it in SI units e.g. 45u (=45microseconds) per loop.
    Watch out for constant folding. If your loop is folded into a constant, you might get false ultrafast readings. If you have LabVIEW 8.5, try the new inplace structure.
    If you are dealing with variable size arrays, measure the speed as a function of array size: Is the execution time linear with N, with NlogN, with N*N, etc. How is the memory use? Plot log(time) vs. log(size). What is the slope of the curve? Are there any breaks? (e.g. when you exceed the cache size or when you start swapping).
    If you are running on a multipurose OS (e.g. windows, mac, linux), there are many other things running at any given time, so the speed will have some variations. Some people are tempted to e.g. take the average, while the fastest speed is probably a better measure of true speed.
    You can norrow the variation by raising the priority of the subVI (careful!). If the computation is within a subVI, you should make sure that the front panel of the subVI is closed. Often, you gain speed by disabling debugging.
    If you have multiple CPUs/cores, watch the task manager? Are both being used? Code optimized for multicore might have a slight penalty on a single code system.
    LabVIEW RT has much tighter controls on execution and you can debug down to the clock tick using the execution trace toolkit(http://sine.ni.com/nips/cds/view/p/lang/en/nid/13746). I am not familiar with RT, though.
    Anyway, I am curious what kind of algorithms you are trying to test. Maybe it is of general interest. You could even start an informal "coding callenge" to tap into the collective wisdom of the forum members.
    For some ideas, here is a link to the coding challenge archive: http://zone.ni.com/devzone/cda/tut/p/id/5174
    LabVIEW Champion . Do more with less code and in less time .

  • Create subVI Control from Reference Name Bug

    If you connect N references to a sequence structure and create a subVI from this structure, the first N-1 controls will have the name of the original control (desired), but the last one will not. It will have the name of the generic type of the control this reference is pointing to. Of course, if N = 1, that means that the created control will have the generic name.
    Illustration:
    In the diagram above, subVI 1 has been created from a sequence to which a reference to "Numeric Control" was connected. Here is the FP of that subVI, as created by LV:
    subVI 2 was created from a sequence to which both references were connected. Here is the FP of that subVI:
    This does not seem to depend on the type of the control. If I add a graph:
    the created subVI looks like this:

    Kind of an extension of this bug, but not exactly the same. Might be due to the same cause though
    If you create a subVI incorporating Property Nodes (not recommended in general for performance reasons, but not a killer either), the subVI will obviously have references to the corresponding controls as controls and references to the controls will appear in the calling VI:
    Before:
    After:
    (it never ceases to amaze me how bad the cleanup/auto-routing algorithm developed by NI is :-)
    Here is the corresponding FP of the created subVI:
    This time, never mind the names of the original controls, they will be ignored, no matter how many different controls there is.
    (I am not even mentioning the well-known feature that if instead of enclosing the property nodes you just enclose the wires coming from the "Value" node, the subVI's controls will read "Value, Value2", etc, where the type of the "Value" controls will in general have absolutely nothing in common).

  • Best way to throw custom error from SubVI

    Hi
    I was wondering how best to throw error messages from a SubVI.
    Say I have a toplvl VI called Caller.vi which calls Sub.vi. The toplvl vi whishes to use the Sub.vi's error out cluster to determine what to do - e.g. halt execution of the toplvl vi if the Sub.vi throws an error. Easy enough if the Sub.vi just have to pass errors from build in LabView functions and VI's, but how to do it if the sub vi has to throw a custom error upon some condition?
    Say the sub vi takes a certain number of inputs and that the inputs need validation before executing what ever the sub vi does. E.g. a certain algorithm implemented is only meaningfull if a>10.
    My own thought is this: Simply select between an empty/no-error error cluster and an error-cluster containing the wanted custom errorcode and description. The area circled in blue is the interesting part:
    Is that the worst idea you've iever seen implemented?
    The only other real suggestion I've been able to find (which originally adresses another issue, but shows a method for "throwing an error") is a VI posted in this thread: http://forums.ni.com/t5/LabVIEW/Throw-an-error/m-p​/882575 which looks like:
    Please help me out guys How to throw a custom error which is not intended for the end-user, but intended to ease the life of a develper calling the sub-vi if he/she wishes to.
    Best regards
    Wuhtzu

    Thank you tbob. (EDIT: and thank you blawson)
    I know all about volunteering and having jobs to do - I participate in quite a few fora. I just thought that my topic was lost since after only 2 days it was on page 3 of the forum - but if page 3 isn't forgotten I will remember that next time and also if 2 days isn't patient I will also remember that
    To you answer: The error code should be negative, shouldn't it? Even though an indicator wired to error-out of a build in labview function will actually display error codes as positive... maybe it's diffrent form labview version to labview version. My v2010 manual reads:
    "You can define custom error codes in the range of -8999 through -8000, 5000 through 9999 or 500,000 through 599,999"
    So say I want to throw an error with error code 5687 - should I then wire -5687 or +5687 to the cluster?
    Thanks - Wuhtzu

  • Open file in main vi, write in subvi and close in mainvi

    Hi,
    Im opening a file in the main vi , passing the reference number to the
    write to text file which is located in the subvi and passing the refnum
    out from this vi to the main vi again to close the file.
    But, I always have only the last value of the measurement stored.
    Im getting data from the serial port.
    what am I doing wrong?
    Can someone help me.
    Thanks and regards.

    You probably have forgotten to set the "Write" function to APPEND the data to the file.
    This has nothing to do with where you are writing the file.  Check the inputs for the write function and make sure you set it up to append.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

  • Open and Close Front Panel of SubVI

    Hi all,
    Running LabVIEW 2011 on Windows 7 x64.  I am trying to get a subVI front panel to open from my main FP with the press of a button and then close with a button press in the subVI.  Here is the piece from my main FP that calls the VI and opens the FP 
    Plots is defined in another loop and all of the loops are in a flat sequence.  I did it this way because I want it to start with the first press and not stop my main loop from running.  I have moved the item in the left loop around a lot so I'm not sure if I can run that in the same loop as the event or not.  Either way opening the VI seems to work fine.
    The problem shows up when trying to close the subVI for the SECOND time.  The code is here:
    As I said, the first time I open and close the VI everything works as I expect it should.  I am then able to open it again but now the "blank button" doesn't function and I can't close the window or even open the block diagram to probe anything.  I have been trying to figure this out for awhile, any insite would be greatly appreciated!
    Thanks
    Solved!
    Go to Solution.

    Its good that you found the bug.
    This code may serve as a way for you to compare notes.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I display data gathered in a subVI in a graph of the main VI?

    I have written a largish application (~50 VI's) which acquires, analyzes, display and saves data from an instrument with a built-in DAQPad. My problem is that my block diagram is rather messy by now. I'm using an event structure in my main VI which reacts to buttons being pressed on the front panel. During data acquisition (one frame of the event structure), I need to do a lot of data processing, and I'm displaying both raw data and analyzed data on the front panel. I'm using a lot of subVI's for this, but I always need to get data out of the subVI's again to display it on the front panel, cluttering my block diagram. It would be much nicer if the subVI could update the main VI's graphs and indicators. I just found two examples with control references which show how a subVI can modify e.g. a 3Dgraph of the main VI, but I'm unable to use this with normal graphs and charts - I can't find a way to update the actual data in the plots (I can scale the plot or color it blue etc - but I really want to change the data it's displaying, not color it blue). Is there anything I'm missing? Is there example code for this kind of problem?
    best regards
    Martin

    im assuming that you want to update your graphs and indicators as you are performing your DAQ, otherwise, you can pass out your value/s when the DAQ completes.
    I have attached a very simple example of using a reference to update your front panel graph.
    Hope this helps.
    Attachments:
    Reference Example(LV7.1).zip ‏17 KB

  • Getting Error while decrypt a file using Blowfish algorithm

    I am using blowfish algorithm for encrypt and decrypt my file. this is my code for encrypting decrypting .
    while i am running program i am getting an Exception
    Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.SunJCE_h.b(DashoA6275)
    at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA6275)
    at javax.crypto.Cipher.doFinal(DashoA12275)
    at Blowfishexe.main(Blowfishexe.java:65)
    import java.security.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import java.io.*;
    import org.bouncycastle.crypto.CryptoException;
    import org.bouncycastle.crypto.KeyGenerationParameters;
    import org.bouncycastle.crypto.engines.DESedeEngine;
    import org.bouncycastle.crypto.generators.DESedeKeyGenerator;
    import org.bouncycastle.crypto.modes.CBCBlockCipher;
    import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
    import org.bouncycastle.crypto.params.DESedeParameters;
    import org.bouncycastle.crypto.params.KeyParameter;
    import org.bouncycastle.util.encoders.Hex;
    public class Blowfishexe {
    public static void main(String[] args) throws Exception {
    KeyGenerator kgen = KeyGenerator.getInstance("Blowfish");
              kgen.init(128);
              String keyfile="C:\\Encryption\\BlowfishKey.dat";
    SecretKey skey = kgen.generateKey();
    byte[] raw = skey.getEncoded();
    SecretKeySpec skeySpec = new SecretKeySpec(raw, "Blowfish");
              System.out.println("key"+raw);
                   byte[] keyBytes = skey.getEncoded();
                   byte[] keyhex = Hex.encode(keyBytes);
                   BufferedOutputStream keystream =
    new BufferedOutputStream(new FileOutputStream(keyfile));
                        keystream.write(keyhex, 0, keyhex.length);
    keystream.flush();
    keystream.close();
    Cipher cipher = Cipher.getInstance("Blowfish");
    cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
              System.out.println("secretKey"+skeySpec);
    FileOutputStream fos=new FileOutputStream("C:\\Encryption\\credit11.txt");
              BufferedReader br=new BufferedReader(new FileReader("C:\\Encryption\\credit.txt"));
              String text=null;
              byte[] plainText=null;
              byte[] cipherText=null;
              while((text=br.readLine())!=null)
              System.out.println(text);
              plainText = text.getBytes();
              cipherText = cipher.doFinal(plainText);
              fos.write(cipherText);
              br.close();
              fos.close();
              cipher.init(Cipher.DECRYPT_MODE, skeySpec);
              FileOutputStream fos1=new FileOutputStream("C:\\Encryption\\BlowfishOutput.txt");
              BufferedReader br1=new BufferedReader(new FileReader("C:\\Encryption\\credit11.txt"));
              String text1=null;
              /*while((text1=br1.readLine())!=null)
                   System.out.println("text is"+text1);
                   plainText=text1.getBytes("UTF8");
                   cipherText=cipher.doFinal(plainText);
                   fos1.write(cipherText);
              br1.close();
              fos1.close();
    //byte[] encrypted = cipher.doFinal("This is just an example".getBytes());
              //System.out.println("encrypted value"+encrypted);*/
    Any one pls tell me how to slove my problem
    thanks in advance

    hi
    i got the solution. its working now
    but blowfish key ranges from 56 to448
    while i am writing the code as
    KeyGenerator keyGenerator = KeyGenerator.getInstance("Blowfish");
    keyGenerator.init(448);
    this code is generating the key upto 448 bits
    but coming to encoding or decode section key length is not accepting
    cipher.init(Cipher.ENCRYPT_MODE, key);
    Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.a(DashoA12275)
    at javax.crypto.Cipher.init(DashoA12275)
    at javax.crypto.Cipher.init(DashoA12275)
    at Blowfish1.main(Blowfish1.java:46)
    i am getting this error
    what is the solution for this type of exception.
    thank you

  • SHA2 Algorithm support in Adobe Acrobat 9

    Hello,
    1) Does Acrobat 9 supports SHA2 Hash algorithms while signing PDF file?
    2) As per my understanding PDF is signed using below approach
        Step 1. Take the PDF contents
        Step 2. Calculate the Hash of the content
        Step 3. Then sign(Encrypt) the hash. (here again we calculate the hash)
      So we are hashing the content twice.
      If I use SHA1 algorithm in Step2 and SHA2 algorithm in Step3, Adobe 9 is able to verify the signature. But if i use SHA2 algorithm in Step1 & Step 2
      Adobe 9 is saying "Content altered....."
      Why so?
    Please help.
    Thanks in advance
    Priyanka

    SHA2 was only added in Acrobat 9.1.  Also, the Microsoft Base CSP is needed for SHA2 support - Base CSP is included in Vista and Windows 7, but in XP it needs to be downloaded as a seperate addon.
    How are you setting the values in your SecurityHandler?  Off the top of my head, I believe in order to use SHA2 to hash the content (your "Step 2") you need to use AES-256 as your encryption algorithm which required a different cryptVersion be set in your SecurityHandler structure.

  • Avoiding data memory duplication in subVI calls

    Hi,
    I am on a Quest to better understand some of the subtle ways of the LabVIEW memory manager. Overall, I want to (as much as practically possible) eliminate calls to the memory manager while the code is running.
    (I mainly do RT code that is expected to run "forever", the more static and "quiet" the memory manager activity is, the faster and simpler it is to prove beyond reasonable doubt that your application does not have memory leaks, and that if will not run into memory fragmentation (out of memory) issues etc. What I like to see as much as possible, are near static "used memory" and "largest contiguous block available" stats over days and weeks of deployed RT code.)
    In my first example (attached, "IPE vs non-IPE.png"), I compared IPE buffer allocation (black dots) for doing some of the operations in an IPE structure vs. "the old way". I see fewer dots the old way, and removed the IPE structure.
    Next I went from initializing an array of size x to values y to using a constant array (0 values) with an "array add" to get an array with the same values as my first version of the code. ("constant array.png")
    The length of the constant array is set to my "worst case" of 25 elements (in example). Since "replace sub-array" does not change the size of the input array even when the sub-array is "too long", this saves me from constantly creating small, variable sized arrays at run-time. (not sure what the run-time cpu/memory hit is if you tried to replace the last 4 elements with a sub-array that is 25 elements long...??)
    Once I arrived at this point, I found myself wondering "how exactly the constant array is handled during run-time?". Is it allocated the first time that this sub-vi is called then remains in memory until the main/top VI terminates, or is it unloaded every time the SubVI finishes execution? (I -think- Mac's could unload, while windows and linux/unix it remains in memory until top level closes?)  When thinking (and hopefully answering),  consider that the the code is compiled to an RTEXE runningg on a cRIO-9014 (vxWorks OS).  
    In this case, I could make the constant array a control, and place the constant on the diagram of the caller, and pipe the constant all the way up to the top level VI, but this seems cumbersome and I'm not convinced that the compiler would properly reckognize that at the end of a long chain of sub-sub-sub VI's all those "controls" are actually always tied off to a single constant. Another way would perhaps be to initialize a FG with this constant array and always "read it" out from the FG. (using this cool trick on creating large arrays on a shift register with only one copy which avoids the dual copy (one for shift register, one from "initialize array" function)).
    This is just one example of many cases where I'm trying to avoid creating memory manager activity by making LabVIEW assign memory space once, then only operate on that data "in-place" as much as possible. In another discussion on "in-place element" structures (here), I got the distinct sense that in-place very rarely adds any advantage as the compiler can pick up on and do "in-place" automatically in pretty much any situation. I find the NI documentation on IPE's lacking in that it doesn't really show good examples of when it works and when it doesn't. In particular, this already great article would vastly benefit from updates showing good/bad use of IPE's.
    I've read the following NI links to try and self-help (all links should open in new window/tab):
    cool trick on creating large arrays on a shift register with only one copy
    somewhat dated but good article on memory optimization
    IPE caveats and recommendations
    How Can I Optimize the Memory Use in My LabVIEW VI?
    Determining When and Where LabVIEW Allocates a New Buffer
    I do have the memory profiler tool, but it shows min/max/average allocations, it doesn't really tell me (or I don't know how to read it properly) how many times blocks are allocated or re-allocated.
    Thanks, and I hope to build on this thread with other examples and at the end of the thread, hopefully everyone have found one or two neat things that they can use to memory optimize their own applications.  Next on my list are probably handling of large strings, lots of array math operations on various input arrays to create a result output array etc.
    -Q
    QFang
    CLD LabVIEW 7.1 to 2013
    Attachments:
    IPE vs non-IPE.png ‏4 KB
    constant array.png ‏3 KB

    I sense a hint of frustration on your part, I'm not trying to be dense or difficult, but do realize that this is more towards the "philosophical" side than "practical" side. Code clarity and practicalities are not necessarily the objectives here.
    Also, I have greatly appreciated all your time and input on this and the other thread!
    The answer to your first question is actually "yes, sort of". I had a RT application that developed a small memory leak (through a bug with the "get volume info.vi' from NI), but to isolate it and prove it out took a very long time because the constant large allocation/deallocations would mask out the leak. (Trace's didn't work out either since it was a very very slow leak and the traces would bomb out before showing anythinng conclusive.) The leak is a few bytes, but in addition to short term memory oscilations and  long term (days) cyclical "saw-tooth" ramps in memory usage, made this very hard to see. A more "static" memory landscape would possibly have made this simpler to narrow down and diagnose. or maybe not. 
    Also, you are missing my point entierely, this is not about "running out of memory" (and the size of 25 in my screen-shot may or may not be what that array (and others) end up being). This is about having things allocated in memory ONCE then not de-allocated or moved, and how/when this is possible to accomplish.  Also this is a quest (meaning something  I'm undertaking to improve and expand my knowledge, who said it has to be practical).
    You may find this document really interesting, its the sort of thing you could end up being forced to code to, albeit, I don't see how 100% compliance with this document would ever be possible in LabVIEW, thats not to say its worthless: JPL Institutional Coding Standard for the C Programming Language (while it is directed at C, they have a lot of valid general points in there.)
    Yes, you are right that the IPE would grow the output if the lenght of my replacement array is not the same, and since I can't share the full VI's its a bit of a stretch to expect people to infer from the small screen dummp that the I32 wires on the right guarantee the lengths will match up in the IPE example.
    Once, on recomendation of NI support, I actually did use the Request deallocation primitive during the hunt for what was going on in that RT app I was debugging last year. At that particular time, the symptom was constant fragmentation of memory, until the largest contiguous block would be less than a couple of kB and the app would terminate with 60+MB of free memory space.. (AKA memory leak, though we could not yet prove that from diagnostic memory consumption statistics due to the constant dynamic behavior of the program)  I later removed them. Also, they would run counter to my goal of "allocate once, re-use forever" that I'm chasing. and again, I'm chasing this more as a way to learn than because all my code MUST run this way. 
    I'm not sure I see what you mean by "copying data in and out of some temporary array". Previously (before the constant array) at every call to the containing sub-vi, I used to "initialize array" with x elements of value y (where x depends to a large degree on a configuration parameter, and y is determined by the input data array). Since I would call to "initialize" a new array each time the code was called, and the size of the array could change, I looked for a way that I could get rid of the dynamic size, and get rid of dynamically creating the array from scratch each time the sub-vi was called. What I came up with is perhaps not as clear as the old way I did it, but with some comments, I think its clear enough. In the new way, the array is created as a constant, so I would think that would cause less "movement" in memory as it at that point should be preventing the "source" array from (potentially) moving around in memory?  Considering the alternative of always re-creating a new array, how is this adding an "extra" copy that creating new ones would not create?
    How would you accomplish the task of creating an array of "n" elements, all of value "y" without creating "extra" copies? -auto-indexing using a for loop is certainly a good option, but again, is that sure to reuse the same memory location with each call? Would that not, in a nit-picking way, use more CPU cycles since you are building the array one element at the time instead of just using a primitive array add operation (which I have found to be wicked fast operations) and operate on a constant data structure?
    I cannot provide full VI's without further isolation, maybe down the road (once my weekends clear up a bit). Again, I appreciate your attention and your time!
    QFang
    CLD LabVIEW 7.1 to 2013

  • Uso de subVI's

    Olá a todos, criei um PI para uso pessoal, porém na hora de tentar implementar uma subVI para tornar o uso mais prático, a resposta da ação de controle fica diferente da resposta sem o uso da subVI. Alguém pode me explicar como consertar esse erro?
    Obs1: Segue em anexo os dois arquivos, usando e não usando a subVI.
    Obs2: Os valores dos ganhos e setpoint são os setados como constantes no arquivo uso_da_subVI.
    Anexos:
    subVI.vi ‏37 KB
    uso_da_subVI.vi ‏16 KB

    hvscherer escreveu:
    Olá a todos, criei um PI para uso pessoal, porém na hora de tentar implementar uma subVI para tornar o uso mais prático, a resposta da ação de controle fica diferente da resposta sem o uso da subVI. Alguém pode me explicar como consertar esse erro?
    Obs1: Segue em anexo os dois arquivos, usando e não usando a subVI.
    Obs2: Os valores dos ganhos e setpoint são os setados como constantes no arquivo uso_da_subVI.
    Ola hvscherer....
    O mau funcionamento de seu conjunto, esta ligado ao fato de que sua Vi principal fica esperando uma resposta de saida de um loop que unca para de executar, ou seja, seu vi principal somente inicia a subVi mas essa ultima nunca termina suas interações .
    Para o seu problema existem varias soluções possiveis, mas antes de apresentalas ai vão algumas dicas uteis:
    Tente evitar possiveis subVI's que executem loops eternos, sempre existe uma outra forma de fazer;
    Quando for necessario a utilização de loops, lembre-se que os dados so seram ixibidos ao fim de cada interação, se esse fim nunca chega , seus dados nunca serão exibidos.
    Vamos as soluções possiveis, (acredito que seu código contenmha varios pontos possiveis de melhorias mas vou me atentar em resolver o problema apresentado por você).
    Eliminando o WHILE LOOP:
    subVI
    VI PRINCIPAL
    2. Utilizando GLOBAL VARIABLE. (essa solução evita grandes modificações em seu código original, mas a utilização em grande escala pode causar problemas em sua aplicação).
    subVI
     VI PRINCIPAL
    Caso tenha duvidas de como trabalhar com GLOBAL VARIABLE esse link pode ajudar:
    https://decibel.ni.com/content/docs/DOC-2143
    Maycon Lazarin

  • How can I make a control inside a loop in a subVI change value when the calling VI's control changes?

    Hi.
    I think this is a pretty basic LV question, but I have not been able to find a good solution.
    I am attaching VIs that show the problem I am having, but obviously, the real application is a lot complicated, which forces me to try to do it this way.
    The issue is: I have a subVI with a Boolean control inside a loop.  When the control is true I want some action to take place.  When the subVI is run on its own, it works fine, acting properly when I set the boolean control to true via the LV FPGA interface from the host.  However, when I use it as a subVI, in which the top-level VI calls several instances of the subVI, I have the Boolean controls in the top level VI.  What is happening is that the false Boolean value with which the top-level VI starts is passed into the subVIs, and not updated, even though the control is inside the loop.
    Can any one suggest a good solution?
    Thanks,
    AlejandroZ
    Attachments:
    CallingVI.vi ‏7 KB
    subVI.vi ‏8 KB

    Hi.
    I know the example I posted might seem silly, but it was just to illustrate the problem I am having.  In reality this is the application:
    I have some LV FPGA code which uses a few FPGA IO to implement a serial link to communicate with a device.  Most of the time we are getting data from the device, so the serial link is used to send a read command, read in the data and put it into a FIFO.  However, I also wanted the VI to support sending data to the device, so I added an array control to put the data you want to send, and a boolean control to tell it you want to send it.
    Since sending and receiving data are done using the same FPGA IO, they cannot be independent operations, because they would garble each other. Therefore, in the subVI I have a loop in which I first read data if there is any to read, then check the boolean write control to see if there is data to write.
    As I mentioned, this works perfectly for talking to a single device.  However, we run into the issue of this topic when trying to replicate this for several devices.
    One easy solution is to not have the loop in the subVI, and have it in the calling VI (I am favoring this simple solution right now).  The only reason why I have not done this yet, is that the subVI has more than one loop, so I am going to have to create several subVIs.  I just posted to see if there was an even simpler solution...
    There have been some other possibly good solutions proposed here, though I am not sure if they work in LV FPGA.
    Thanks for all your responses.
    AlejandroZ

  • Application registration algorithm

    I'm writing a small shareware app that I would ideally like people to register. This is the classic, if they send in the registration code 'xxxxxx', then I can send the unlock code 'YYYYY' situation.
    Three criteria:
    1) I would like the registrtaion code xxxxx to be unique. I am toying with the idea of storing the date in millisecs of when the app was first run on the system. If anyone has any better suggestions, I would love to hear them.
    2) I would really like to have the algorithm myself. i.e. I don't plan to make enough off of this to be worth purchasing a library.
    3) This does not need to be incredibly secure. Just enough to keep the casual person from
    Does anyone out there have an algorithm they are willing to share to accomplish this?
    Thanks all. This falls into the 'I know it has to be a known problem, but I'm not sure where to start' category.

    Unless I am misunderstanding, I think that I'm addressing what you mentioned. Let me recap and see if I can make it more clear.
    1) Client sends you an identifier and saves it to the client's disk.
    String start = "" + System.currentTimeMillis();
    start = start.substring( start.length() - 5, start.length() );
    //this pulls off the last 6 numbers from the first run time and converts to a string. 
    // this is written to a file on the client side and then sent to me for registration.
    2) You (the server) send back a hash of the identifier.
    //registration app
    String start = codeSentFromCustomer;
    String superSecretDecoderString = "Secret Code";
    start = start + superSecretDecoderString;
    String result = MD5.getHashString( start );
    result = result.substring( result.length() - 9, result.length() );
    //this takes the 6 digits provided and appends "Secret Code".
    //  i.e. if the customer's code is "333232", then "333232Secret Code" is fed into MD5.
    //  I then send the customer the last 10 digits from my MD5 hash, say "1234567890" for simplicity sake
    3) Clients types the unlock code ("1234567890") into the registration box, which is then saved to disk.
    // to check on the unlock code's validity, I...
    String superSecretDecoderString = "Secret Code";
    String start = originalCodeFromAbove; //i.e. "333232" in this example
    start = start + superSecretDecoderString;  //now start = "333232Secret Code"
    String result2 = MD5.getHashString( start );
    result2 = result2.substring( result2.length() - 9, result2.length());
    // I compare the result2 to the stored unlock code to make sure they are equal
    //  superSecretDecoderString is stored within the client and the registration prog's code.  i.e.
    //  the customer never sees that string.
    4) At each startup the client code checks the hash of sent ID against the return he has stored.
    // run through the validation code detailed in #3.I think it addresses what you were referring to, but if it doesn't please tell me. It's my first crack at this sort of code, and I'd much rather discover any gaping holes now than later. :)
    thanks again

Maybe you are looking for

  • Urgent - need help, Powerpoint images require quicktime???

    Hi guys, I'm a lecturer and I prepared a powerpoint on my G5 to show to students last week. the text loads on the Dell PC they have in the classroom, but the images come up with a message "requires Quicktime and a decompressor". As far as I know thes

  • Airport Extreme + MBP = No Signal

    Hello All, I've installed a AP Extreme ( fast ethernet ) in my front room, I'm using a new 2.2 Mac Book Pro, I can get full AP signal within about 30 feet, then as i walk to the other end of the house ( a distance of about 70 feet ). The signal drops

  • Planning & HFM Certifications - Advice Appreciated

    Hello All – For those on the board that are certified Hyperion professionals (Planning and HFM). I'd really appreciate your input as to the value of these certifications both from the perspective of 1) Getting onto projects 2) Being able to perform o

  • Shared Folders

    Sun Java(tm) System Messaging Server 6.3-0.15 (built Feb 9 2007) libimta.so 6.3-0.15 (built 19:17:24, Feb 9 2007) SunOS test 5.10 Generic_127112-11 i86pc i386 i86pc imcheck -d lright.db {Userid} Mailbox list [email protected] user/public/Office-Facsi

  • LRT224 Port Range Forwarding problem

    Hi I have a new Linksys LRT224 Dual WAN Gigabit VPN Router. I want to allow trafic to parse on port 9100.  Connection Accepted TCP 91.102.93.5:63261->192.168.0.48:9100 on eth0  I understand that  as it has accepted my request on port 9100 and forward