Data acquisition in a state machine

I've recently learned how to implement state machines, but I have a question that I haven't been able to find an aswer to.
Question:
How do I record uninterupted data (presently i'm using the DAQ assistant to record a single channel at 10kS/s at 1kS intervals) without interfering with my state machine?  
Background:
I have a time sensitive test setup (measuring pressure in a rocket chamber), and I'm using labview to both record a single pressure transducer as well as operate the valves (O2, N2, igniter, etc).  I'm using a state machine Labview architecture (just learned how).  Presently, the DAQ assistant sits in the "Idle" state, and timers (valves need to be turned on at specific times) and manual buttons control when the other states are activated.  I have a 10ms timer controlling how often each state is run, and this is the root of my concern.  
Main concerns:
I'm worried that:
1)  I'm forced to change my data recording to 10ms intervals to match the 10ms timer, and
2)  The 10ms timer will interrupt my data recording when it's in another state.  
It's very important that the pressure data is recorded without interruption but that I have high time resolution in controlling my valves as well.
Thoughts:
1)  Maybe I put the 10ms timer in the "Idle" state only, and this way the other states won't interrupt the data acqusition
2)  Maybe there is a way to completely isolate the state machine for controlling the valves and the data acqusition.  I'm not sure how to do this.
3)  People on the forums have been talking about Queuing their data acqusition, but I'm not sure how this would benefit my situation.  
Thanks to everyone for their feedback!

The data acquisition and state machine timer do not have to be equal, you should however have the same data write rate as you have data read rate, otherwise over the course of long running programs you can build up a large buffer of data to be written using a lot of memory, or lose data.
Your data acquisition should be continuous, the most common way of doing this is every time you receive data write it to a queue, then when you are in other states except your data write stage you simply build up data in the queue that is to be written when you enter the write state again.
Think of it as traffic reaching a set of lights:
The traffic represents the data acquisition, there is a constant flow of it always coming through, the state of your state machine is the lights, green is the data write state clearing the queue, red is when in any other state, letting the traffic build up behind the lights.
It is just important that the light is green long enough to let the traffic not build up too much, otherwise you have a jam.
EDIT: For the basics of how queues work, look at the Queue basics example from the example finder. 

Similar Messages

  • 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

  • Audio playback from within a state machine without halting execution

    I have created a state machine that acquires and analyzes an input signal and transitions states based on triggers detected within that signal.  In one particular state I need to play back a prerecorded file (right now I am just using a .wav file for testing purposes).  I understand that due to the data flow model the state machine hangs up during the playback state until the playback is finished, but I need to find someway around this.  Obviously, whenever the machine hangs up it cannot continue acquiring and analyzing the signal.  How can I start the playback from within the state machine without halting its execution?
    Solved!
    Go to Solution.

    Do you use the sound output VIs? If you do, try this. On the "Play Sound File VI" set the timeout value=0
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Data acquisition & state machine

    Hi all,
    I am working on a project that is capable of data acquisition, analyse, and record processes. I have to acquire data of temperature from 8-32 channels and that of pressure from 7 channels. After analysis, I have 48 outputs. I want to record raw data (acquired) and analysis data at the same time.
    1) Is it possible to record two text files (raw data and analysis data records) at the same time?
    I also want to adjust acquired sample rate but I have doubts about utilizing it in a state machine. For now, I have just used time elapsed function to acquire data once in 60 seconds.
    2) How could I set sample rate of acquisition except using time elapsed function?
    I also have one more doubt about timing. If I needed to acquire sample once in 60 seconds, but the analysis took more than 60 secs, what would happen?
    3) How can I prevent data loss in this case?
    I have not prepared a user interface yet.
    4) How can I utilize it? Do I put graphs and indicaters in the same VI or is it better to prepare another vi just for user interface?
    Thanks in advance
    Egemen
    Attachments:
    Program.llb ‏433 KB

    Hi Egemen
    -          If we need to acquire data and analyze it at the same time we recommend the architecture producer-consumer to prevent data loss, and yes you can record two text files at the same time. Please take a look to this architecture.
    -          http://www.ni.com/white-paper/3023/en
    -          Basically you use the first loop to acquire data and the second one to analyze and record data (using queues).
    -          https://decibel.ni.com/content/docs/DOC-2431
    -          You can also find examples about this architecture at the developer zone.
    Regards

  • How do I add new data to the same file in a State Machine?

    Hello,
    I have a State Machine, with a State where 3 samples of data are collected in a For Loop. I would like to save this data in a file and keep adding new data to the same file each time I get to this state. The problem I'm running into is that each time I reach this State, my old data in the Excel file gets replaced with the new data instead of being continuously added in the same file.
    Ive tried Shift Registers but I may not be using them correctly since my file keeps displaying only 3 new data points.
    Any ideas will be appreciated!
    Thank you, so much.
    -Peter

    Where should I place these shift registers? Where should I place my File I/O VIs? Is it possible to use the Write to Spreadsheet File VI in this situation?
    Ive attached a very simple example of the problem. Thank you.
    Attachments:
    StandardStateMachine 2.vi ‏16 KB

  • Best method for state machine design for multi-dimensional clustered data

    I have an application that is collecting analog tag data(1000 points) and displaying on a graph. In each vi, I may collect data for as many as 32 channels, but only one channel at a time. Usually this is collected in numeric order, but maybe not all the time. I am also saving an "expected profile" to a file for each channel. I display both expected and actual data on the graph and select which channel to view with a ring control. My question is about how to design the state machine for best memory usage/execution speed/... If I use a shift register with a cluster datatype, that holds both 1000 point arrays, some statistical data like max/min/pass/fail/test limits for 32 channels, won't all of the u
    nbundle/bundle functions use a ton of memory??? Right now I am writing the cluster data to memory tags for each channel. I use the ring control to determine which tag to read. I have the tags grouped by channel into several groups for actual data, expected data, results data,... What design methods would provide the best function using a shift register/queues and notifiers/memory tags in the tag engine?? I also use CITADEL to read the max and average as a trend display on each channel and to select a specific 1000 point dataset to view if the max and average are out of limits. Does anyone have similar applications??

    It sounds as if you will be working with alot of data here so I can understand your concerns for memory management. If you were to unbundle and bundle data in your application, you are correct in saying that it will require more memory. It is somewhat difficult to get the overall picture of what you are needing to set up, but from what I can gather, it sounds as if you could have an array of 32 elements; each element a cluster of your data as well as the statistical data, and then you could index through that array to determine what to display on the graph. The shift registers will be reusing the same memory over and over so there should not be a problem there. Queues wouldn't necessarily help you in any way in this situation. Depending on how many memory tag
    s you are using, you could increase the amount of memory usage required by Citadel and the tag engine, but if you are needing to write your cluster data to the database, then there is not much you can do about it. Ultimately it sounds like a pretty involved application and will require a fair amount of memory regardless to ensure smooth functionality.
    In general, questions about the LabVIEW architecture and memory management are typically better answered if they are posted to the general LabVIEW discussion forum area. But I hope that this has addressed some of your concerns. Have a good day.
    Patrick R.

  • Data between states of the states machine

    So I have two tables that I generate in one state of the state machine.  My question is what is a proper, aesthetic way to propogate these two tables into one another state of the state machine. Please see the attached  code.  State machines rock!
    Attachments:
    flag.jpg ‏166 KB

    The shift register is the right tool for this job.  It follows the left to right data flow paradigm, unlike other solutions (such as using a local variable).  I am sure you will get a few other opinions but I think that the shift register is the way to go.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • Wiring Data in a State Machine

    I have a state machine with about 20 cases all handling different user interactions and all completely independent of one another. That is, what one case does has nothing to do with what another does (for most of them anyway). They just execute one case and then go back to the default case. Some of them though do require data to be passed out of one case so that it can be read in another (actually not the data but just the data structure to be reused). Shift registeres work just fine of course, but this requires me to wire this data through all the other cases that don't need it just so they can have an output for the tunnel. Is there anything else I can do to avoid wiring paths through every case that doesn't actually need the data?

    Here's a real simple example. I can't give you too much insight with respect to the memory usage, except to say that I've never had any problems doing things this way. I've written a couple of big vi's with 30 - 40 variables clustered this way.
    Attachments:
    Clustered_Variables.vi ‏35 KB

  • How to save data in a state machine.

    Need to save 2 data points in a state.  Or how to add both data points from state to the array that is saved in write to file vi.  Please use the vi for reference.
    Thank you for your help.
    DOG
    Attachments:
    State.zip ‏32 KB

    I'm not entirely sure what it is that you are trying to do here, why are you trying to record the states?
    What do you mean by both data points?
    There are about a million different ways to do this many of which seem more logical then your current system, If you can explain a little we would probably be able to help a great deal more.
    If you are asking about passing out the two numbers from the User state 1 I would suggest building all of the numbers into arrays and passing them out through a concatenating exit to the while loop.
    Attachments:
    State Mod.zip ‏34 KB

  • Data acquisition driven by encoder

    Hi everyone,
       I need to sample a capacitive sensor that measures the radial run-out (radial small displacement) of a rotating spindle. LabView v. 7.1 is employed to acquire the data by means of PCI-6036E card commercialized by National Instruments (NI). The spindle rotates at 100 rpm and a rotary incremental encoder is fixed at rear of spindle. The encoder gives two types of digital pulses as follows: a) A-quad-B pulses (it will be used only “A” pulses in this experiment); b) index pulse (one pulse per revolution). This encoder provides 1024 pulses type “A” per revolution. The measurements made by the sensor are driven by “A” pulses which are used as “external clock”. Therefore, every “A“ pulse, the card acquires one sample from sensor. Thus, 1024 data/rev are acquired. I want to sample 5 consecutive revolutions of the spindle. To start the data acquisition, the index pulse of the encoder is used as “start digital trigger”. Also, the index pulse should be used to count the number of revolutions of the spindle. In this way, when the number of revolutions is equal to 5, the data acquisition finishes. By contrast, the programmer also can set the number of samples equal to 5x1024 in the VI. The data acquisition is finished when the number of samples reaches this value. Similarly, the sampling process is started by the index pulse which is the “start trigger”. Note: 1) the sampled data should be put in a buffer. After the sampling process is finished, this data should be saved in a file of LabView; 2) In fact, the data acquired by the sensor are voltage analog input. Questions:1) Could you make a VI for this problem, please? Note: You can use the DAQ ASSISTANT EXPRESS VI or DAQmx TASK NAME CONTROL method.2) How to program the LabView in order to sample data triggered by the rotary encoder (pulse “A”)?3) What should I do to stop the data acquisition at the end of 5 revolutions?4) Could you send examples (VIs) similar to my problem above?5) How can I know if the program (VI) looses an “A” pulse? Is there any kind of error in VI that indicates a miss pulse?  In anticipation, thank you very much for any help. My e-mail: [email protected]                                                                                      Bruce

    Hello Bruce,
    I have a complete solution for this but I cannot give you the VIs because my customer has paied for it and all rights are transfered to him.
    What you need are two tasks.  One task is the analog in task. You must use the DAQmx Timing.vi and the DAQmx Trigger.vi to set it up as needed. Or you create a task in MAX with this setup. The other task is a counter task just counting the pulses from the z-Index.
    Next you need a small state machine with the states:
    init, start, wait and stop.
    init will initialize and start the tasks
    start will read out the z pulse counter and wait for a change from 0 to 1
    wait will read out the z pulse counter or the available samples property, when the desired number of z pulses or samples are available read the buffer with DAQmx Read.vi
    stop will stop both tasks and clear them.
     You will need two additonal counters which you don't have to check for lost A pulses and a external flip-flop electronic. The flip-flop will change it's state with each z pulse and the output will be used for gated counting. With each change of the z pulse counter you need to read out one of the additional counters to check if he had seen the correct number of pulses.
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • Data acquisition loop with queue

    What I would like to do is have a data acquisition loop that samples a load cell at 500Hz and have another loop that runs much slower to run a state machine and display some data in real time.  The reason I want to sample the load cell so fast is to filter out some noise.  Making producer/consumer loops with a queue kind of makes sense but I don't really care about all of the samples, I just want to be able to read a real time filtered signal at certain times.  I looked at having just two parallel loops, one to acquire the data and the other to run a test and retrieve a real-time signal when I want but not sure how to pass data between the loops without using a queue.  You can do it with local variables but you are at risk of a race condition.  I hope this make sense.  I am sure this is a simple problem I just don't know what direction to go.  Thanks

    Good Evening secr1973,
    It sounds like you are on the right track.  You already know about the producer/consumer architecture; this is almost always the first step to the separation that I think you are after.
    The step that I think you are missing is a Case Structure around the enqueue element VI.  You likely have some event or specific pattern that you are looking for in the input signal.  You can have the output from this algorithm (likely a boolean) determine which case of the Case Structure to execute (Case 1: enqueue the element or Case 2: Do not enqueue the element).
    This, of course, leads to processing being done in the producer loop, which is quite the opposite of what you are trying to accomplish with the producer/consumer architecture.  You will have to decide if your processing is very simple or more complicated.
    If it is easy/fast, you can likely get away with doing this processing in the producer loop.  My guess is that your program falls under the category of do-it-all-in-the-producer loop because you are only acquiring at 500 Hz.
    If the application requires faster acquisition rates or if the logic is going to require some processing, you may want to implement a double layer producer/consumer architecture.  In this setup, you would pass all of the data from the DAQ producer to a second loop (using queue #1) that determines what to do with the data (to enqueue or not to enqueue...) and, if appropriate, write to a queue (queue #2) that the third loop can read.  The third loop would be where your state machine executes.
    If you have a quad core machine, each of these steps will execute on its own core.  If not, you will have a little more thread swapping; not a huge concern in most cases.  Here, we get into the art of programming more than the science.
    In any event, I think you will be OK with a little processing for the enqueue or not algorithm in the producer loop.
    Regards,
    Charlie Piazza
    Staff Product Support Engineer, RF
    National Instruments

  • New LabHSM Toolkit - Agile development of complex event-driven maintainable LabVIEW applications with active objects / actors based on a universal Hierarchical State Machine / statechart template.

    Dear Fellow LabVIEW programmers:
    Most of the systems you deal with are reactive. It means that their
    primary function is constant interaction with their environment by
    sending and receiving events. But most likely, they can have something
    happening inside them too, even when they are not processing messages
    received from outside. So, such systems have to continuosly react to
    external and internal stimuli. Right? Moreover, most likely, they
    consist of subsystems that are reactive too and, in turn, can have
    their own "life", to an extent independent from other parts (with
    which they still communicate, of course). Reactive (event-driven)
    systems are more naturally modeled with active objects. So, why then
    should we try to model and code them with GOOP and its passive
    ("dead"!) objects?
    "Flat" State Machines have been known for decades to have severe
    limitations. It's been more than 20 years since Dr. Harel invented
    Hierarchical State Machines (statecharts) to fight those limitations.
    Then why does NI still tout the same old good Moore FSM as the
    ultimate tool for event-driven programming in LabVIEW in its $995
    State Diagram KIt?
    The LabHSM toolkit we are happy to present, makes it possible to
    easily create and then maintain complex event-driven applications in
    LabVIEW as a collection of HSM-driven active object VIs using a higher
    level of abstraction and agile software development methodologies.
    These active object VIs are created based on a universal Hierarchical
    State Machine ( HSM or statechart ) template. So. all your code looks
    similar regardless of its functionality!
    We all love just jump to code, right? However, to be good boys, we
    need to do design first. Then implement it in code. If the logic is
    modified we need to redo the design first and then redo the code. When
    using LabHSM where behavior information is abstracted into a separate
    HSM data file editable with a supplied editor, there is no need for
    coding separate from design any more. The modified behavior becomes
    code automatically as soon as the HSM file is saved. Design is code!
    The implementation basically follows Dr. Samek's Quantum Programming
    paradigm. (see http://www.quantum-leaps.com). However, as already
    mentioned, LabHSM stores the behavior information in a file separate
    from the code itself. It also adds state dependent priorities to
    events, a separate queue for public events/messages, and, of course,
    some LabVIEW specific code like capturing front panel user events and
    putting them into the private Events queue. Communication and
    instantiation functions are also rather specific for LabVIEW.
    It is available for UNLIMITED PERIOD trial. Please visit
    http://www.labhsm.com for details and download. The site also contains
    references which you may want to check to learn more about
    hierarchical state machines and active object computing.
    Since this is our debut we will appreciate any comments and
    suggestions. Our contact information is available on our site, of
    course.
    Have a G'day!

    Symtx is currently hiring the following position. Please contact me if interested.
    Amy Cable
    Symtx, HR
    [email protected]
    Symtx, the leading supplier of functional test equipment, hires the brightest & most talented engineering professionals to design & manufacture complex custom electronic systems for advanced technology leaders in the defense, aerospace, communications, medical, transportation & semiconductor industries. Symtx’ challenging & dynamic work environment seeks to fill openings with highly qualified electronic engineering design professionals.The ideal candidate will be responsible for defining the requirements, software design and code development, and integration of test control software for custom functional test systems. Candidate should be familiar with data acquisition concepts, instrument control, complex test, measurement and calibration algorithm development and definition and implementation of control interfaces to hardware. Prefer familiarity with instrument control via GPIB, VXI, MXI, RS-232 desirable. Requires BS/MSEE and 3 -7+ yrs of experience in one or several of the following test applications in a Windows NT/2000/XP environment using Labwindows CVI, TestStand, Labview, Visual Basic, C++ and knowledge of RF systems is a plus. Job responsibilities will include software design, development, integration, team leadership, and interfacing with customers( includes PDR’s & CDR’s).

  • Choice of design pattern for data acquisition system

    Hello all
    I have a trouble about selecting the suitable design pattern / architecture for a data acquisition system. 
    Here is the details of the desired system:
    There is data acquisition hardware and I need to use it by observing parameters on User interface. 
    the data acquisiton period, channel list to scan should be chosen on User interface. Besides, there are many user interface interactions. e.g. if user selects a channel to add scanlist, then I need to enable and make visible some other parts on user interface. 
    When user completes the channel selection, then he will press the button to start data acquisition. Then I also need to show the scanned values on a graph in real time and log them in txt file.
    I know that I cannot use producer consumer pattern here. because the data acquisition loop should wait for parameters to scan channels. and it works in a given period by user. so the user interface loop performs higher rate then consumer loop (data acquisition loop). it means queue will be bigger bigger. if I use notifier it will loss some data come from user interface. 
    is there any idea about that ? is there any suitable design pattern for this case ? 
    Thanks in advance
    best regards 
    Veli BAYAR
    Embedded Systems Software and Hardware Engineer 
    "You live in a graphical world. Why not program in one?"
    Solved!
    Go to Solution.

    johnsold wrote:
    Veli,
    I recommend the Producer/Consumer model with some modifications.
    You might need three loops.  I cannot tell for sure from your brief description.
    The User Interface loop responds to the user inputs for configuration and start/stop of acquisition.  The parameters and commands are passed to the Data Acquisition loop via a queue. In this loop is a state machine which has Idle, Configuration, Acquisition, and Shutdown states (and perhaps others). The data is sent to the Processing loop via a different queue. The Processing loop performs any data processing, displays the data to the user, and saves it to file. A notifier can be used to send the Stop or shutdown command from the User Interface loop to the other loops.  If the amount of processing is minimal and the file write times are not too long, the Processing loop functions might be able to occur in the Timeout case of the UI loop Event structure.  This simplifies things somewhat but is not as flexible when changes need to be made.
    I am not sure that a Design Pattern for this exact setup exists but it is basically a combination of the Producer/Consumer (Events) and Producer/Consumer (Data) Design Patterns.
    Lynn
    Check out this thread: http://forums.ni.com/t5/LabVIEW/Multiple-poll-case-structures-to-event-help/td-p/2551309
    There are discussions there about a 3-loop architecture that may help you.
    Jeff
    Jeffrey Zola

  • Run Code Continuously in Event Driven State Machine

    Hi there, I was wondering what is the best way to run code continuously in an event driven state machine. Particularly, I am going off the JKI state machine. At the moment I put the code I want to run continuously (acquire from an instrument) in the timeout case of the event structure. When the user presses the button, the event sends the value 0 to the timeout terminal of the event structure (through a shift register). If the user stops the acquisition then the value -1 is sent to the timeout terminal. This is a tip that I took from an article by Mike Porter.
    Would it be better to run this process in a separate loop? Is a state machine a bad design choice for running code continuously? I don't like my current solution because if I have another process I'll have to start putting case structures into the timeout case. Also, if the process takes a while then the event structure will take a while to respond.
    Thanks for your input!

    AKA_TG wrote:
     Adding to that I believe Preview Queue element to read the data and Lossy  enqueue to transfer the I/O output, especially if the I/O device responds slowly. This should keep your event structure polling along very nicely during I/O calls to the other structure.
    I actually prefer to use an User Event to send the data to the main event structure and/or whoever else needs it.  I am not a fan of the lossy enqueue (loss of data).  At that point, I might as well just use a Notifier and/or global variable.

  • 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

Maybe you are looking for