Timed structure for output in producer consumer data acquisition

Hello LabVIEW community,
I have a bit of a problem.  I am writing a program that is primarily for data aquisition but has a few control features as well.  I need the program to aquire and write several channels of data at a relitively high speed.  The program does this fine ( in the top 3 loops fo the program).  I need the program to also send a seires of two output signals in response to a particular condition.  When a certain channel registers a value of above a specified number, I need an output channel to write an anologue signal for 225 seconds and then a signal of a differnt value to the same channel untill the condition occurs again (not for several hours).
 I put this action in a timed structure inside of a case structure. The case structure and timed structure are inside of a second consumer loop.  I have no idea if this is ligitimate.  This event takes much longer than any of the other loops which run at 1 or 2 seconds. When I exicute the program with "highlight exexutuion" this longer (case/ timed ) loop never executes. I asssume this has to do with the mismatch in time scales of this loop and the other loops in the program.  I also didn't really understand the help information on timed structures, so its possible that I just need better/ different inputs to the timed stuctures.  
If anyone can see any obvious problem in the code or suggest a better way to do the output function I would really appreciate the help.  My code is attached.   
Thanks,
Jo

I can't figure out how to fix your code, but I can point out the things I see wrong with it.
1.  You are dequeueing elements from the same queue in the same loop.  In one you are not taking the element, and in parallel, you are taking an element.  I see that in your bottom two loops.  Why?  That code won't execute until the queue gets two elements in it.  And which dequeue gets it first and which gets it second is an arbitrary race condition.  So there is no certainly of order (first 4 vs. last 4 currents in the one loop), or which gets kept and which gets discarded (in the other loop.)
2.  You are creating and/or clearing DAQ tasks in every loop iteration.  Tasks should be created before a loop, used inside the loop (read or write), then cleared once the loop is done.  Anything else is wasteful, time consuming, and could lead you to run out of resources.
3.  You are using the STOP function which is pretty much like hitting the abort button on the toolbar.  No program should ever stop that way.  All loops should exit gracefully.
4.  You have a data dependncy between your bottom two loops because of the boolean wire running from one to the other.  That bottom loop will only run once (if the value is True), or run forever (if the value is false).
5.  Use of the dynamic datatype.  You are taking waveforms, converting them to a blue wire, then coercing them into another datatype such as just displaying a scalar in an indicator.  A lot of unnecessary conversions there.
6.  Your thermometer indicators have a digital display you can make visible.  Then you won't need the separate numeric indicator to display the value.
7.  For loop that runs only 1 time because of the constant wired to the N terminal.  Get rid of the For Loop.
8.  Check your spelling.  The word "Temperatures" on the graph, and one instance of "distillate" is missing an "l".
Until all of these problems are fixed, it is not worth talking about timing of timed structures.  Some of these problems were discussed in your other thread.  http://forums.ni.com/t5/LabVIEW/producer-consumer-missing-channels/m-p/3159757#M911255   But now it seems like you've made things even more complicated without fixing the basic problems.

Similar Messages

  • Techniques for a synchronous long-life data acquisition

    Hello All
    I have a digitizer, which needs to run at a constant rate for ever. When some condition occur (reading exceed treshold level), other data processing must take place.
    The data processing last for much longer time that the successive sampling, which means that I can not fit data processing in the same thread as the sampling process.
    It looks like I need some kind of buffer, which will be filled and keep track of the sampled data, and another thread for data processing and analizying.
    Can somebody give me a link, or advice about this kind of problems. What are the techniques for long-life data acquisition.
    Thank you in advance.
    Pawel

    Indeed a challenging application! Here is what has been done successfully in other applications:
    1) to separate the DAQ task from other tasks, put the data into a Queue. This creates a second software buffer for your data.
    2) for large buffers, so you can extract pre and post trigger data, use two files (a double buffered file buffer) and stream the data to each file successively within your DAQ VI.
    3) when you detect the threshold trigger in your DAQ loop, note the block number and pass this as part of the queue
    4) your processing loop, can then use the block number to get pre and post trigger blocks for further analysis.
    Hope this helps you get started.
    Preston Johnson
    Preston Johnson
    Principal Sales Engineer
    Condition Monitoring Systems
    Vibration Analyst III - www.vibinst.org, www.mobiusinstitute.com
    National Instruments
    [email protected]
    www.ni.com/mcm
    www.ni.com/soundandvibration
    www.ni.com/biganalogdata
    512-683-5444

  • Where are the guidelines for how to interface customized data acquisition equipment to LabVIEW?

    I have a need to do some very specialized data acquisition that may require building special hardware. I would still like to use LabVIEW as the front end and perhaps even carry portions of the interface over into the final product. However, I cannot find the documentation. Where is that kept? I have seen references to a number of generic protocols, without any links back to the details, that may be suitable. The data is high bandwidth, but bursty with sampling rates up to 40 MHz and events that last about 100 milliseconds. Can anyone recommend which of the various methods would best suit this application?
    Solved!
    Go to Solution.

    Once you have figured out your communication bus, it is just a matter of how to format your commands and data.  You will need to do this regardless of programming language you choose.  Formating the data is quite simple in LabVIEW.  You just have to write the data to the right thing.
    Quickly based on the limited parameters you have given us, I would go with an Ethernet connection.  I'm not completely sure if the Ethernet bus will be able to handle your bandwidth, though.  If not, then you will need to go to a PCIe or PXIe connection.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions

  • How to create a bc model for sharepoint 2013 that consume data from two Sql tables?

    Hi everyone!!!
    I have created several external contents using SQL Server databases as datasource. The thing is every time I created one, only consume one table and define operations for that table. I would need to create an external content that can contain the
    information of two tables. I tried to export the bdc model and type the query using left joins but nothing happens...I did it in that way for sharepoint 2007 and works!!!
    I know if a create a view in the database I can have the data that I want and I can create the external content using the view. But the thing is I don't have access to the database for creating anything, just read it.
    can anybody can help me, please?
    Thanks.

    Please follow this article to write SSRS reports with data source as SharePoint list/calendars etc. All document libraries, list and calendars are derived from base list class so you can use any of this type as a data source
    http://www.mssqltips.com/sqlservertip/2068/using-a-sharepoint-list-as-a-data-source-in-sql-server-reporting-services-2008-r2/
    Once your SSRS report is developed, you have multiple ways to show it in SharePoint
    - upload to SSRS server and show in sharepoint in a page viewer web part or simply open it as a link in new window
    - configure SharePoint environment with integration to SSRS and upload report to SharePoint library. Display report in a web part page using SSRS web part.
    Moonis Tahir MVP SharePoint,MCTS SharePoint 2010/2007, MCPD.net, MCSD.net, MCTS BizTalk 2006,SQL 2005

  • Table  for Output condition record's data

    Hi
    In which table are the values of an output condition record stored?
    Regards

    go to the desired tcode  in display mode ex:"VV33" to see that condition type tables, then give ur condition type and press CONDITION INFORMATION button in application tool bar and u reach one screen and press "execute" in application tool bar  and u reach one more screen and in that screen press "control+F8" then u can reach one more screen there it dispalys the desired table of urs.
    reward me if it is helpful.

  • Producer/consumer architecture over network variables with Real-Time target.

    Hi all,
    I am maintaining a producer/consumer data acquisition program to be deployed on a real-time target. The main code is deployed to and run on the real-time target during experiments, but was having trouble because the program was originally designed to write all experimental data to disk on the real time during acquisition, which puts the whole experiment at the mercy of the hard drive. I am now trying to rework the code so that the host takes care of logging, so that my time-critical loops don't have to wait.
    I am currently using LabVIEW 8.5
    I have two questions:
    First, how can I programmatically call the data-logging subvi on the host so that it runs in parallel with the main vi which runs the experiment and collects data on the real-time? I have attached the test code that I have been working with to figure this out, but it does not run the logging vi continuously in the background. I am aware that there is better functionality for this in newer versions of LabVIEW, but I would prefer not to upgrade unless there is no other option. I would like to be able to run my data-generating vi and have it start the data logging remotely.
    Second, is there a way in the host VI to read values off the network variable using an event structure rather than polling it for updates?
    Any help would be sincerely appreciated!
    Attachments:
    testRemoteLogging.zip ‏124 KB

    VI server
    Mark the target VI as served on the machine on which it will execute and use VI server Call by reference to invoke the served VI.
    This used to be taught as THE way to communicate syncronously with an RT app.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • 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

  • Producer consumer of images

    can someone please help me. I am totally stuck and lost. I am trying to build a procuder consumer architecture but the template from labview is not very clear. many books does not go over this concept.
    i have created a vi. but i dont know what to do with the image in buffer.
    can someone please guide me. thank you
    Best regards,
    Krispiekream
    Attachments:
    ProducerConsumerData 1.vi ‏115 KB

    One problem is that you created a queue that
    transfers Imaq references.  But in your consumer loop, you are
    transferring a string called elements.  (The red coercion dot on the
    Enqueue element gave it away.)  You would need to enqueue the purple
    wire.
    On the other side you would need to dequeue the
    purple wire (Imaq reference).
    One problem is that the
    purple wire is a reference to a particular memory location and is not a
    particular instance of an image.  As Mark was saying, you could wind up
    overwriting the memory location with new image data before you had a
    chance to do anything with the previous image data.
    Hi  Ravens Fan! First off, I want to thank you and Mark for looking over my vi.
    I formatted the code exactly how example did using this.
    I don't see any red coercion dot on my Enqueue element. 
     in order to get my program working, I added a wait timer of 200 ms and it did the trick. But I am loosing the frame rate I needed and that's the main reason for moving to producer/consumer architecture.
    Can you show me what you mean? I never worked with this time of architecture before and don't know how to use it.
    Thanks
    Best regards,
    Krispiekream
    Attachments:
    mltcoreimaqdx.vi ‏90 KB

  • Top level application structure with parallel data acquisition

    Hey all LabVIEW-forum members!
    I have some experience programing  LabVIEW, but mostly concerning smaller for the simplest form of data acquisition. Now I need to develop a larger application that might be continuously run for several weeksin a row and for that reason I woiuld like to make sure the application structure is stable! I turn to you in hope of some input regarding the most suitable approach to my problem or some pointing in a good direction.
    -The project involves making hardware communication with a few different hardware interfaces, such as GPIB and NI’s DAQ-card (analog and digital reads/writes on PCI-6221).
    -Save acquired data to disk.
    -The communication and data save are based on condition of elapsed time (for example there could be a need to make parallel analog measurements med DAQ-card every 5th minute but GPIB-measurements every 30th second).
    -At the mean time I would have to regularly the status of the test object and update the user interface. (However, while in test the user won’t be allowed to interact with the application other than to monitor the UI or pause the test).
    The project isn’t really time critical (in case I need to make one type of data-acquisition while another one is already initiated, they can be carried out in sequence).
    I’ve started with programmatically control the user interface by using the “Top Level Application Using Events”-template and produced code that will let the user set up a new test or load an existing test. All the data concerning the status and configuration of the test I’ve saved in two clusters that can be passed along to different events.
     I’ve reserved one subdiagram in the event structure for the actual execution of the test. It is the structure of this subdiagram I am a bit confused about…
    Could I use another while-loop/event-structure inside this subdiagram and use user-registered events for the different data acquisition? Or is there some type of state-machine that is better suited to monitor time elapsed and can make a transition to a suitable state when it’s time to make any of the hardware measurement required? It would be nice to avoid using polling loops but maybe that is best way to go?
    I’ve checked the “Continuously Generate Occurrences.vi”-example and that might be a way to go? What seems to be good with this approach is that I could let the different parallel hardware acquisitions actually be parallel, right?
    I am really confused right now, hope someone has some helpful inputs!
    Regards
    Oscar

    This post here can be proved as a great starting point for your application.
    I am not allergic to Kudos, in fact I love Kudos.
     Make your LabVIEW experience more CONVENIENT.

  • How to create new structure for SOP?

    How to create new structure for SOP? and transfer data for long term planning?

    hi dear
    For SOP there are two types
    1. Standard SOP : this the standard SOP  configured by SAP consider the Level by Level planning and planning done for product group .
    2. Flexible planning SOP: this option is given, so that Rough planning/SOP planning can be done as per the client requirement.e.g planning structure can be sales orgn., distribution channel, division, plant, material
    For configuring the flexible planning SOP follow steps
    1. Define info structure in IMG
    where u define the characteristic and Key field
    2. Set parameters for info structures and key figures
    Sales & Operations Planning >Master Data>Set parameters for info structures and key figures
    where u define  Planning method
    Consistent planning
    Level-by-level planning
    Delta planning
    and aggregation type
    1. Average calculated
    2. Total created
    3. No aggregation
    3. create Planning type with reference to info structure
    Regards
    Suresh

  • Data Acquisition Stops Randomly

    We are using a timed loop to read, display, and write data from a CompactDAQ device. Normally, the data reads, displays, and writes correctly, however there have been several occurrences where the write function failed without notice. When we went back to open up the data after a test, we found that the data ended early, ranging from 30 seconds in to a minute into the test. Has anyone encountered an error like this? Thank you for your help.

    Thank you for the quick response. I have attached our VI for reference. To answer your questions:
    Data is read with the DAQ assistant. Write to measurement file is used for writing the data. Both are within the same timed loop.
    Errors are propogated across the timed loop and through the DAQ read and write functions.
    Not sure if there were errors reported. How can I tell?
    The data I opened after running the test was logged into a .lvm file. I have some code in the VI to automatically generate a timestamped filename, however it does not seem to work so I have been naming files manually in the settings of the "write to measurement file" function.
    I apologize for the vague first post. Hopefully the VI sheds some light on the problem. Thank you for your help.
    Attachments:
    Data Acquisition - ANelson.vi ‏149 KB

  • High Accuracy Analog Input,Data Acquisition Modules questions

    At present,i produced a Data Acquisition Modules,but work not well,pls give me some suggestions.i produce according to a product from USA,but i only produce one channel.pls check the link.
    http://www.sun-yuan.com/english/readnews.asp?id=71
    Thanks for your help.pls send to my email:[email protected]

    I haven't done this with NI-DAQmx, but I assume Read.vi works the same way as it does with traditional NI-DAQ.  The way I do it is to give Read.vi the number of samples that it will read in 1 second.  For example:
    4 channels, 1000 Hz, read 4000 samples in Read.vi
    All you have to do to accomplish this is multiply your scan rate and number of channels and pass the answer in as the number of samples to read.  It will always read a second of data, even if it gets behind on one iteration of the loop it can catch up on the next.  I also use a Wait Until Next ms Multiple and wire like 400 to it as not to bog down the CPU.  Then you can just keep track of the elapsed time and stop the loop after 24 hours.  Just be sure to clear the acquisition after the loop now that you're using a continuous acq, otherwise the buffer will overflow.
    As I said, this is how AI Read.vi works for traditional NI-DAQ, I'm not positive that DAQmx Read.vi works the same way, but I don't see why it wouldn't.
    Message Edited by Marc A on 01-16-2006 05:07 PM
    Message Edited by Marc A on 01-16-2006 05:09 PM

  • 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. 

  • Copying data to an external server during data acquisition

    I need to copy out data to an external server for backup during an extended data acquisition session (days long).  What is the safest data format for this operation that won't corrupt the primary data file?  *.lvm, *.tdm, *.tdms?
    Thanks 

    Hi Velveeta,
    I would think that you would rather save to multiple files and then back them up on the server rather than try to make a copy of a file in the middle of its creation; as this would be more likely to cause corruption issues.  If you are very concerned about this, I'd recommend breaking up the data to a couple of files and then backing them up.  So, to answer your questions:
    1.  You can set up the express VI Write to Measurement File to create a new file every X data points.  I'm unsure of how you are planning to programmatically copy this to a back up disk. 
    2.  Don't copy a file in the middle of its creation (for example, if you were creating one file and tried to back it up in the middle of your acquisition). 
    3.  The file format shouldn't matter for this functionality in particular. 
    Cheers, 
    Marti C
    Applications Engineer
    National Instruments
    NI Medical

  • I2C interface (Sensor Data Acquisition) LabVIEW

    Hi all!
    Hope you are doing great!
    Well I have a question which is more about asking all you for an idea!
    The Situation:
    I have a circuit board which has an On-Off Valve, Digital pressure sensors (manufacturer AMD) and Humidity/Temperature Sensors (make- IST Hygrosens). On the board all the sensors communicate as I2C slave devices and all the data from the sensors is read into an I2C --> USB adapter chip which further connects to the PC via normal USB cable.
    Additional to this board, There is a Relay circuit with a simple 1-pole relay which controls an on-off valve on the above Circuit board. This valve is controlled totally separate via a coaxial cable from the relay directly to the Valve. But the relay board has a I2C interface and it also acts as a slave device. The relay board has the same I2C --> USB adapter chip.
    Both the Relay board and Sensor board connect via USB to the PC which I suppose is the Master device.
    The software code written for this arrangement and Sensor data acquisition is too old and there are a lot of problems coming. I have almost given up troubleshooting..
    I now want to translate this automation system onto LabVIEW. I searched the NI website where there is a DAC card called - USB8451 which supports I2C interface... I am a beginner in LabVIEW and cant really make sense out of how should I go about implementing this system on LabVIEW..
    If you guys can please help me out to atleast start (like what all hardware I would need etc..), to have a clear picture, it would be great help!!
    Looking forward to your inputs and Thank you so much in advance!
    Cheers!
    Pramit

    NI provides a LabVIEW API for the USB8451.  If you use the USB8451, you would use the provided API to write a program that controls the USB8451 and you would do all of the I2C communication in your program.  This would mean using functions / SubVI's to connect to the USB8451 and then perform I2C operations through it.
    If you use USB already on your device, then you would probably use NI-VISA as the driver and have to get / write your own API to talk to the specific device.  The manufacturer may have a LabVIEW (or other) API available for talking to the device that you could get.  If not, then you would have to understand the details of how to communicate with the device and then write an API using NI-VISA serial functions.  This would mean making NI-VISA be the assigned driver for the device and then using VISA Serial functions / SubVI's to send the messages and receive the responses.

Maybe you are looking for

  • How to get the full name of the Account Owner?

    Hi, I would like to ask if there's a way to display the full name of the Account Owner in a report where the subject area is Opportunity? Currently, the Username (under Owned By User) which displays the full name is equal to the Opportunity Owner. Th

  • Problem with Guided Procedure

    Hello, using the Guided Procedures I have modeled an approval workflow. After a requester submits a request, the request should be delegated to an approver. However, when the requester actually submit the request, I get an error message which reads "

  • Why does the ipad not have the apps wheather and stocks

    The iPad doesn't have stocks and weather

  • Databse of 1888 Byte Per Record with 259 Fixed Fields Stumped CR?!?

    My Database of  15 million records/rows at 1888 Byte Per Record with 259 Fixed Fields STUMPED CR?! Executive Summary : I have lots of data. There are 15 million of records in some of my database files. But I need to drill into the data and get counts

  • Going out of country, need info about charges

    I'm going out of country & still want to be able to use some features like Data, check email, translate language, use on plane.  Is there a way to do that without being charged international fees?   Can I use wi-fi on my phone free?  If so, what are