Discrepancy between execution time of state machine and flat code

I am trying to optimize the performance of my application, and I've found that the same code executed as a case in a state machine, and flat on the block diagram takes a dramatically different amount of time to run. I'm trying to figure out what I'm missing here. The picture shows a test vi I threw together (the next post will have the diagram image for the "Add New" case of my Buffer Engine.vi - basically the same as what is in frame 5). The fifth frame in the sequence is what I am concerned about. It shows that executing the case in the state machine takes ~700ms, and flat, ~113ms.
Any thoughts?
Chris
Attachments:
Test Times.jpg ‏124 KB

Thanks for the suggestion Altenbach. I had to insert a for loop to replace array subset indivually for each column of new data to place in the buffer, but even with the extra processing, the result was about 80% faster. I guess I'll have to come up with a system to track where to place the data (it was convenient to always drop the data at the end..), but that shouldn't be an issue.
However, this suggestion doesn't address the original concern. The same array resizing was going on in both the subvi and the sequence frame. This improvement should increase the performance of each, but doesn't explain the difference.
As an aside, I contemplated using a queue, but without the ability to dequeue from both the beginning and the end, I don't see how I can use them for this. I want to trash the oldest data, not hold up the acquisition. In any case, I don't think it would be faster because the memory isn't pre-allocated. Now I am considering just storing the data in a control, and passing the reference as necessary. The question is, is reading the value from a control faster than reading from a shift register?
Thanks again.
Chris

Similar Messages

  • Difference between execution mode of Print preview and Print for Output

    Hello,
    Can anybody tell the difference between execution mode of print preview and print for an output (For eg. PO output or Invoice)?. I am trying to download some documents linked to Purchase order to desktop. The code is written in the same driver program for printing PO and it is executed after smartform function module is called. It works fine in print preview mode and it fails in print mode. The reason why download fails in print mode is that GUI not available (just found from debugging).
    Any ideas?
    Thanks
    Anil

    HI
    try using any other printer and find out if you are getting the correct output. The printer needs to support Multiple Unicode encoding schemes like UTF 8, UTF 16BE, and UTF 16LE, plus special characters and logos, bi-directional text layout, and custom characters..

  • What are the differences between the Time Capsule MC344LL/A and MD032LL/A, do both havethe same make of server grade HDD, also any changes in WiFi coverage and networking abilities?

    What are the differences between the Time Capsule MC344LL/A and MD032LL/A, do both have the same make of server grade hard drive, also any changes in WiFi coverage or networking abilities?  Thanks

    Found this info regarding original question:
    What are the differences between the Time Capsule MC344LL/A and MD032LL/A, do both have the same make of server grade hard drive, also any changes in WiFi coverage or networking abilities?  Thanks
    http://www.hardmac.com/articles/402/page1
    http://www.applefritter.com/node/23907
    Hope this helps -
    ; >}

  • Discrepancy between birthday entries on my iPhone and my MacBook Pro Calendar

    How do I correct the discrepancy between birthday entries on my iPhone and my Macbook Pro Calendar? Say I entered June 11 on my iPhone and it will appear in my Calendar as June 12-- one day late! I use iCloud to sync Calendar and Contacts in my Apple devices.

    Make sure you have iCloud setup correctly >  Apple - iCloud - Learn how to set up iCloud on all your devices

  • Discrepancy between weblogic-ejb-jar.xml DTD and documentation

    There seems to be a discrepancy between the DTD for the weblogic-ejb-jar.xml file
    and the WLS7 documentation: Which source of information should I treat as
    For example, the WLS7 documentation contains no information on the <idempotent-methods>
    element (and its child elements)
    (There is also a (larger) discrepancy between the weblogic-application.xml DTD and
    the docs - I will post that Q under application deployment)
    Regards,
    Nick

    Yep, I noticed it too. I used DTD, of course.
    "Nick Minutello" <[email protected]> wrote
    in message news:[email protected]..
    >
    >
    There seems to be a discrepancy between the DTD for theweblogic-ejb-jar.xml file
    and the WLS7 documentation: Which source of information should I treat as
    For example, the WLS7 documentation contains no information on the<idempotent-methods>
    element (and its child elements)
    (There is also a (larger) discrepancy between the weblogic-application.xmlDTD and
    the docs - I will post that Q under application deployment)
    Regards,
    Nick

  • State Machine and producer consumer design patterns

    Hi!
    In my application I am using state machine(for top level VI) and producer consumer(for subVIs) design patterns throught out.
    If there is no activity on the front panel for 1min then the ideal state is invoked. Following are the situation of the ideal state:
    1. It checks for any hardware present on the network . If no hardware is found on the network within 1 min then the application and LabVIEW exits.
    2. While the ideal state checks for the hardware, and user clicks on any front panel button then it should exit the ideal state. The control
    should be in the respective button state.
    I am able to achive the point#1 mentioned above but could not get the point #2 to work. I am including the snap shot of
    the state machine(default case) and prouducer consumer(deafualt state).
    Each screen has the concept of the ideal state. The only additional step in the subVIs is that when the ideal state is reached and the time has expired then it will close the subVIfront panel.It will go to the exit state of the Main(top level) VI. Thus closing the application and quitting LabVIEW.
    Any ideas or suggestions. Will multithreading and notifiers help?
    TIA
    Rachana
    Attachments:
    Sanpshot_Of_Design.zip ‏75 KB

    Hi Rachana,
    I was thinking about using event structures wherein there would an event case that would handle any value change event for any of the buttons on the front panel. But before suggesting that, I would need to know more about the Ideal State subvi( more specifically, how is it checking for any hardware present on the network and where is the one minute wait coming from?).
    Please feel free to respond to this post with your questions/comments.
    Regards,
    Ankita A.

  • Recipe Management Using State Machines and DAQ Assistants

    I am writing LabVIEW code to control a conversion process for up to 4 devices on one apparatus.
    The operator will select from these 4 devices which ones will go through a conversion process. Therefore - they can select some or all of the devices to go through the process.  The process is the same for all 4 devices. The difference between the 4 are the digital outputs used for the conversion process.
    Clearly a state machine is applicable. However, I would like to "reuse" the process conversion code of the state machine by creating a separate recipe for each device and merely change the digital outputs (their physical location) for the device under conversion. Presently I have DAQ Assistants controlling digital ouputs for the conversion of one device. Is it possible to "reuse" the code by creating a recipe or a lookup table to reassign the DAQ Assistants to their proper physical location (the digital output lines) for the device under conversion?
    I could - copy and paste the code, go into the process and reassign every DAQ Assistant to the correct physical channel of each digital output for the other 3 devices. I was curious if there was a more efficient way.
    I see documentation online for recipes; however they are dated 2006. I thought there may be some updated examples.
    Using:
    LabVIEW 2011
    cDAQ-9188 chassis

    Hi MgDAQ,
    DAQ Assistant is a quick way to start acquiring data, however it's not the most efficient.
    Everything that DAQ Assistant does can be acompished with basic DAQ functions on the
    Measurement I/O -> NI-DAQmx pallete. For example, you can use DAQmx-Create Channel.vi and
    a Channel Constant to select the channel from which you want to acquire data.
    To get started with using the DAQmx functions you can browse through Hardware I/O examples in the Example Finder.
    Open up a new LabVIEW VI and then go to Help -> Find Examples -> Hardware Input and Output [folder] -> DAQmx -> Digital Measurements
    Now, as you probably know, copying and pasting code is inefficient and it's not a good programming practice. So what I would do is create the code for your conversion process and then simply change the channel constant to read the digital output you need.
    Mikhail
    RF Toolkits, Product Support Engineer
    National Instruments

  • How can I establish an enum typedef for use with state machines and action engines?

    Hey all--
    I have an action engine with several instances.  Any time that I add a method to the engine, I have to modify all of the calling code to update the constant that determines the method being called.  There must be a smarter way to address this problem but my LV experience is insufficient to identify it.  Can any of you wiz-bangs tell me if it is possible to make a type def (I can do this) and use it with each instance of the action engine call so that changing any instance also updates the typedef?
    Thanks.

    Take your enumerator.  If it is not a control (ie constant), change it to a control.
    Under File Menu, select New > Custom Control.
    Move (or copy) your Enum Control to the Custom Control.  Change the Control to Strict Type Def (the selection to the right of the wrench).  Save it.
    (EDIT: ** OOps, the picture shows the wrong one.. sorry**)
    Copy that new Strict Type Def control to your code.
    See images below.
    OR.. If you're using LV8.x, and using a project, I would recomment that you do it from within your project explorer.  Simply insert a new "Control".  The rest of the steps are similar, except that you can insert it from your project. 
    R
    Message Edited by JoeLabView on 07-08-2008 06:47 PM
    Attachments:
    TypeDef.PNG ‏33 KB

  • Nested State machine - Loops continuous​ly

    Hello ,
    I implemented a program for first time using state machines and Enum (type def). 
    I have 2 state machines (nested) 
    I am not sure if the data flow between the Main state machine and the Sub state machine is correct. The program loops continuously ( this is a MOTOR PROGRAM) and I see that the motor keeps working continuously. It is supposed to run the mentioned Number of Steps once and then stop.
    Please have a look at my code and tell me where I could have gone wrong. 
    Thank you.
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Motor-UNI_Directiona Dev 1.vi ‏49 KB
    Control 1.ctl ‏6 KB
    Control 2.ctl ‏6 KB

    Figured out ! Thank you. One of the ENUM was not defined to the correct state.
    Thank you. 
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]

  • Difference between dispatch time in po and scheduled time in job

    Hi all ,
    can any one please explain me
    what is the exact difference between dispatch time maintained in po and time/date set for job schedule
    here my question is ,i maintained dispatch time as send job with periodically in PO and i had maintained date/time in job process steps with some period.
    when po message is triggered ,which time will be consider system.time specified in job schedule or dispatch time in Po.
    which one consider first?
    Thanks
    konidala

    Dispatch time that is set up as part of the message output condition records, drives at which event does the output be transmitted. Conversely, the date/time during the batch job set up is the time when the batch job must execute the program.
    For example, if you had selected the dispatch time for output NEU in the PO to be '1' and you had set up ME9F program as a background job running daily once at 1PM, when the PO is created and saved at 10AM, the output type NEU will be triggered and will be held in queue. At 1PM when ME9F program is run as part of the background job, it'll pick up this output type for execution and transmission.

  • Need help created state machine that is time based

    I need help with my labview program. My goal is to write a program that allows the user to turn a toggle button on/off. When they do this it will start a loop witch turns on a digital switch for 45 minutes then off for 30 seconds and on and on till the user toggles the switch off. The timing does not have to be precise. I am using the NI 9476 digital output card.
    I have written the code to turn the switch on/off. I know need to add the looped fuction for on 45 minutes/off 30 seconds. I assume the most efficient method would be using a state machine, but I was having trouble figuring it out.
    Attached is the program I have written thus far without the loops.
    Thanks,
    Barrett
    Solved!
    Go to Solution.
    Attachments:
    Test Setup X01.vi ‏16 KB

    I cannot see your code since I don't have 2010 installed. A state machine would be good approach but in order to allow the user to cancel and possibly abort the process at any time your state machine should have a state such as "Check for timeout". In teh loop containing the state machine use a shift register to pass the desired delay value and the start time time for that particular delay. Once the user starts the process set the delay time to your desired time (45 minutes expressed as seconds) and have another shift register that contains the next state to go to after the delay completes. Use a small delay (100ms to 500ms depending on how accurate you want your times to be) to prevent your state machine from free running and then check the delay again. Use the current time and compare it to the start time. If the desired time has passed then go to the next state. You can store the next state in a shift register. No do the same thing for your Off Time state.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    Simple Delay in State Machine.vi ‏14 KB

  • LabVIEW2012 has long execution time to write string than LabVIEW2011 on XP SP3

    in for loop, each execution will output string and display it on front panel by value property.
    But after upgrade to LabVIEW 2012, the execution time doubled on Chinese XP OS, I really want to know this difference between LabVIEW 2011 & LabVIEW 2012, pls advice.
    "I think therefore I am"

    This is no way to measure the execution time. Your parallel while loop spins as fast as the computer allows, consuming all CPU it can get in the process, and starving everything else. Your code is highly flawed!
    Eli: actually I add 10milliseconds delay inside both for and while loop. 
    In addition, get date/time in seconds is also a relatively expensive function, not to mention all these local variables! Your benchmark is completely meaningless! All it does is slow down your regular code, nothing else. How do you know in what order things start? Where is the "start time" initilized (where is the terminal?!)
    Eli: I am using the states machine, and set the "start time" during the program initialization, then calculate "test time"in next case (running block). 
    A proper benchmark uses a three-frame flat sequence with to high resolution relative seconds timers, on in each outer frame and the code to be benchmarked in the inner frame. (here is an example). The difference between the two timers is the exection time of the inner code in seconds. Make sure to only have wires in the benchmarking code. All controls and indicators belong outside the sequence. Also make sure that no other code can run in parallel to the sequence.
    Use this and you'll be surprise how fast your code actually runs.
    Then you should also disabele debugging.
    Please attach your actual code (including the subVI) so we can see what else you are doing wrong.
    Eli: if possible, give me your mail address, then I can sent more actual code to you separately. 
    "I think therefore I am"

  • Producer Consumer with a state machine within the consumer

        Hi All,
    I have been trying to develop a data acquisition system with the producer consumer architecture.  To the left of the two main loops I initialize the serial port and any constants and variables im using.  I also have an obtain queue VI needed for enqueue and dequeue. Then in the producer loop i have a state machine.  The first state is where I wait for a button press on the front panel to write a GO signal on the serial line which will tell the device connected to the serial port to begin sampling data.  After this button press I go into the next state which is called my read state.
    In the read state I use a property node to read all of the available bytes at the serial port and then enqueue this collected data into a queue.  The state machine then is directed to continously go to the read state again and collect more data.
    Now this is where my dilemma is......  The consumer loop has the dequeue VI inside it and after this VI i have a state machine (while loop and case structure) which contains the following states
    1.  Build Array - build an array from the dequeue element and if there is any left over data from the parsing states it will build an array with the left over data and the dequeued data
    2.  Determine packet type - this state looks for the packet type byte(not necessarily the first byte in the message) and also check the next byte (packet length) to ensure that I am at the begininng of this chunk of data.  This state may be a little slow because there can be three different packet types and based on this byte and the packet length it may have to search the array several time to find the valid starting point.  This state also determine the next state to go to based on the packet type.
    3 packet type 1 parsing - parse data and store the remaining data it leftOver array.  Go to exit state.
    4 packet type 2 parsing - "" ""
    5 packet type 3 parsing - "" ""
    6 exit - leave this state machine and fall back to the consumer while loop.
    After it exit I think it should fall back to the consumer while loop and dequeue more data and enter the state machine again to build a new array with the dequeued data and leftover data.  It seems to work when I trace the execution using the Highlight execution feature, however when I run this all at full speed, it seems to go into the consumers 1st and 2nd states back and forth and not completely go through the state machine.
    I tried adding in a delay in the producer loop to give the consumer loop time, but I didnt notice any difference.  Is it possible that my dequeue element is retreiving more data while im still in the state machine, causing the execution to leave the state machine before it finished all states?
    Is there a better approach to take to solve this problem. Basically I need to read data at a 1,000,000 baudrate and parse it as quickly as possible so that I can break it up into 3 different packet types, write the data to a file, and graph the actual data (header info removed) in realtime.  I need to also ensure that I am not losing any of the collected data.  Data loss cannnot occur.

    A couple of things more to go along with Ben's pointers:
    You convert your data from a string, to a U8 array, to a Hex string array in the producer loop, then convert back to a integer to determine what to do with it.  In the process, you create two or three copies of your data, slowing yourself down quite a bit.  The code would be quite a bit more efficient if you left the data as a U8 array.  You can change the format of the controls and indicators to show hex values instead of integer by right clicking on them and selecting Format and Precision...
    Your search code is fairly inefficient.  I made a whack at making it a bit better.  See attachment below.
    If you continue to run into race conditions, you can debug them using a calls to the Windows debug write sprinkled liberally about your code.  Check out the post here for more information.
    Don't let your lack of format LabVIEW training stop you.  The biggest thing to get is the data flow paradigm (aka data is wires, not registers).  Once you get past that and learn how to pass data around using shift registers, queues, events, etc, you are most of the way to mastering LabVIEW.  The rest is just learning the plethora of functionality LabVIEW gives you (yes, I have reimplemented LabVIEW native code more than once in the process of learning).
    Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.
    Attachments:
    serialUtil_V3_DFG.zip ‏137 KB

  • Clustering of SQL query execution times

    In doing some query execution experiments I have noted a curious (to me, anyhow) clustering of execution times around two distinct points. Across about 100 tests each running 1000 queries using (pseudo-)randomly generated IDs the following pattern emerges. The queries were run from Java using all combinations of pooled/non-pooled and thin/oci driver combinations:
         100          *
         90          *
    R     80          *
    u     70          *
    n     60          *
    s     50          *
         40          *                                             *
         30          *                                             *
         20          *                                        *     *     *
         10          *     *                              *     *     *     *     
              0     100     200     300     400     500     600     700     800     900     1000     1100     1200
                                       Time(ms)Where about half of the total execution times cluster strongly about a given (short) time value with a smaller but broader clustering at a significantly slower mark, with zero intermediate values. The last point is the one I find most curious.
    What I would have expected is something like this:
         100          
         90          
    R     80          
    u     70          
    n     60          
    s     50          
         40                              *                         
         30                         *     *     *                    
         20                    *     *     *     *     *     *          
         10          *     *     *     *     *     *     *     *     *     *          
              0     100     200     300     400     500     600     700     800     900     1000     1100     1200
                                       Time(ms)The variables I have tentatively discounted thus far:
    -query differences (single query used)
    -connection differences (using single pooled connection)
    -garbage collection (collection spikes independent of query execution times)
    -amount of data returned in bytes (single varchar2 returned and size is independent of execution time)
    -driver differences (thin and oci compared, overall times differ but pattern of clustering remains)
    -differences between Statement and PreparedStatement usage (both show same pattern)
    I know this is a rather open-ended question, but does the described pattern seem faniliar or spark any thoughts?
    DB-side file I/O?
    Thread time-slicing variations (client or DB-side)?
    FWIW, the DB is 9.2.0.3 DB and the clients are running on WinXP with Java 5.0 and 9i drivers.
    Thanks and regards,
    M

    Further context:
    Are your queries only SELECT queries ?
    Yes, the same SELECT query is used for all tests. The only variable is the bind variable used to identify the primary key of the selection set (i.e. SELECT a.* from a, b, c where a.x = b.x and b.y = c.y and c.pk = ?) where all PKs and FKs are indexed.Do the queries always use the same tables, the same where clauses ?
    Yes, the same tables are always invoked. The where clauses invoked are identical with the excepton of the single bind variable as described above.Do your queries always use bind variables ?
    A single bind variable is used in all invocations as described above.Are your queries also running in single user mode or multi user mode (do you use SELECT FOR UPDATE ?) ?
    We are not using SELECT FOR UPDATEDid something else run on the database/on the server hosting the database on the same time ?
    I have not eliminated the idea, but the test has been repeated roughly 100 times over the course of a week and at different times of day with the same pattern emerging. I suppose it is not out of the question that a resource-hogging process is running consistently and constantly on the DB-side box.Thanks for the input,
    M

  • How to use a event structure with a state machine

    First, I would like to inform you that I only work on LabView part time, and have much to learn.  Anything I do learn, I usually forget until I need it again, because I only work on it part time.
    Using your StopWhileLoopMOD[1].vi, I am trying to put a state machine inside the event structure.  
    Related link: http://forums.ni.com/t5/LabVIEW/How-to-stop-while-loop-in-Event-case/td-p/465564/page/2
    Here is my application:  on the front panel, the user can select any combination of 7 different tests.  I have created cases to perform each step of each test in the correct order, but if the user presses stop, the tests won't stop because some of the cases have a while loop inside the event structure (like you mentioned is a bad idea).  The user should be able to stop the test, reselect tests to perform, and re-start the tests. 
    When the start button is pressed for the event structure, I need all the cases to run in the proper order, unless stop is pressed.
    In the past I have indexed an array and used that to run the state machine, but it won't stop immediately.  
    I have sub VIs that are built in while loops because the outputs of the product needs time to stabilize.  The state machine stops and waits up to a certain number of iterations.  If it passes the test, the while loop stops and the next state starts.  If it takes too long, it exits and reports an error.  Maybe I need to just use the state machine and not an event structure?
    Is there a good example of an event structure?
    metzler CLAD
    Solved!
    Go to Solution.

    I'm not sure exactly what you are asking, but it sounds like you want to script a bunch of tests and if the user says stop, to immediately stop the current test and abandon the others?  I'm going to assume that you know how to clear the array so that it will abandon the others, so I'm guessing that you are having trouble abandoning the current test?  If this is indeed the case, then the problem is that you are not able to propagate the message from the main VI FP which is the GUI to the sub vi which is the test, where the test may or may not have a GUI (FP visible) of it's own.  Threading was the first thing to come to mind, but this may not be necessary using events.
    You can do this by passing a refnum of the stop button to the subVI, where you can then add that wait to the event case structure.
    I've attached 2 VIs, mainvi.vi which is just a loop displays the count*2 (number of seconds passed since running) that will call subvi.vi and then check to see if the stop button is pressed.  mainvi.vi is by no means a state engine, it is just a simple loop for demonstration purposes.  subvi.vi just waits 2 seconds and leaves, it is a better structured state engine with an init state to start a poll case to wait for events and an exit state to clean up.  You can modify this any way you wish to get it to do what you want.  You will note that even if subvi.vi is being executed, it will terminate immediately when the stop button is pressed.
    Hope this helps.
    A
    Attachments:
    mainvi.vi ‏17 KB
    subvi.vi ‏33 KB

Maybe you are looking for

  • DV imports - iMovie vs Final Cut - Another question

    I'm importing NTSC VHS content through a Canopus ADVC-55. 1) Audio Capture via iMovie produces a DV files that works well in iMovie. If I use this same DV file (produced by iMovie) in FCE, audio will not render in FCE (red line above the track). Taki

  • Creating index  at the end

    I am new to Reports 6i How do I print the index at the end of a report (group above or group left). What I want is the key field and the starting page number. Thanks.

  • CONFIGURE FILE ADAPTER ,get files one by one.

    HI,  I have cinfigure one system of FILE ADAPTER TO JDBC ADAPTER, is working OK, but I need to Know  how configure The FIle adapter to get files one by one from the folder , I have the channel configure between 30 seconds, but when come to look for t

  • New report in ABAP

    We got requirement to convert Bex report into ABAP report..Conside like Income statement standard report it needs to be convert(develope) in ABAP. This has lot of restriction on it and in which tables will get the data. I checked the master data obje

  • How to use the List in this case.

    I got sample code from http://developer.java.sun.com/developer/technicalArticles/ThirdParty/WebCrawler/. But when I compiled it, there was error message like "webcrawler.java:16: reference to List is ambiguous, both class java.util.List in java.util