Producer consumer with inputs and outputs analog and digital

Hello world

I'm working on a program of control system for some practical test work. Currently, I am working on the data acquisition of the Labview program component. My architecture is consumer-product loops with a what. My system will have analog inputs, outputs, analog inputs and digital outputs. It is not a criticism of time sytem, but I wish that all the acquisition of data to synchronize. I enclose my program because it is at the moment. I have difficulties to get all the data in the since that I have two types of data. In addition, I don't know if I have synced the four sequences of read/write correctly. I would be very happy if someone could take a look at my program and give me some advice. Thanks in advance.


Tags: NI Software

Similar Questions

  • Producer consumer with the third loop model

    Hello everyone and thank you for looking at this.

    I have a problem that I thought for a while now on the execution of a third loop in a design model of producer consumer (with events).

    I use this type of model for a UI and am happy with how it works. However if I want to add a continuis loop model to test for example how can I control the loop?

    In my example (see table), I use a local variable to run them (or stop) the test and the same to close the application.

    I don't know why, but this feels wrong to me. Is there a better way?

    Thanks in advance

    Chuck

    Nickelback says:

    Is the problem with the consumer loop only runs when it receives a message from producer loops event.

    Nothing says that you can't have a consumer loop enqueue States to itself.  Of course, this is more in a State Machine in queue with the possibility for another loop to the States of the queue.

  • Producer-consumer mode, PDM and Acquisition journal continues

    I created a VI based on events to control the parameters of data acquisition. I created a queue of producer-consumer in TDMS file in the loop of the consumer.

    Question 1: Why should I get DAQmx TASK through each defined event? If I don't, I get error task DAQmx.

    Question 2: I need the QUEUE of each event? If I don't I get error in the file close TDMS (consumer loop)

    Question 3: When I look at the data file, I get manily in the near TDMS file loop of consumer-related. Since there is no element in the QUEUE why should - I get this error.

    Please advice.

    Thank you

    This is certainly not how I would like to start to create a Soft Front Panel for a task to HAVE.  Leave to file logging asside for now (appearing, it is actually very easy to add later.)

    As food for thought - and because that create a FPS really involves a slightly different thought where you started I whip a 'start' of a FPS.  It also shows how to create a simple API around a 'resource Module.   (Just a natural extension of a "motor action - if you haven read the nugget of community is always a good read.") http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/m-p/503801)

    What I compressed is not complete - but you should get an idea of what to expand and where.  You could even have there more faster here than when you are now.

    An approach like that can really help when you go to unwind the problems as you mentioned in your code when you are unable to move around the information that the GUI can't really do use anyway and not IS NOT NECESSARY at this level.  the guys from 'Computer Science' will use terms such as 'Hide data', "Functional Abstraction" and "Encapsulation".

    The capture below is meant to tease the project so that others can get the idea of code - (sorry no LAVA TDC today! )

  • events producer consumer with notifiers

    Dear users of LabView,

    I would like to ask your advice on my project (see the attachment of files). For the beginning, I did only the "backbone" of my project, that's what you can see in my VI. My project will have the following features:

    -Start and stop action possibly (and also plot data to the chart and saving the data to the file)--> here is some time a loop to record data ranging from DAQmx (USB6009) and another while loop with rates of different loop to rise in voltage output amplifier of the magnet.

    -During the measurement, or if the system is idle, the user is able to read files of measured data and evaluate the measured data, etc... (so there will be more features...)

    I decided to use producer consumer structure with events and the authors of notifications, and I also use the dynamic user event to be able to communicate to the consumer with the producer (where I have my machine of the State as in a shift register).

    Please comment on my VI, what do you think? Maybe I should use the state machine (the shift with the pole of the State Register) in the lower loop? I could also use up queues of the notifier, but since I send only orders and the values of the parameters (not streaming broadband data) I guess that the declarant is fine?

    Thanks for the tips!

    The code you posted looks like a good start.  The architecture is very similar to the measurement sample continuous project comes with LabVIEW 2012.

    A few things I noticed:

    1. I would usually use queues instead of filers (unless you want to manage only the last command and not all orders in the order they are received).
    2. You don't need the registry change in the top loop (structure of the event).  You inadvertently send a length of measure and other commands parameter since you replace only the command.  Probably, this is no problem for now but could be a problem later.
    3. I think the user events are a great way to manage cases of judgment where the consumer is able to report to the producer that the application must exit loop (this is how we do in the sample project).
    4. Your case 'Init' confuses me a little.  It is read length control measure and send a user event in the event that, in the structure turn immediately place a measure command. Once I see a control in a loop of consumer as it hurts a bit uncomfortable. Why not have the value "start_measurement" to change event read the length of measure command and send it as part of his message to the consumption loop. Then the loop of the consumer can Init and self talk to start the measurement.
    5. You may need to rethink your strategy mistake in the case of the measure. Currently you do not stop a loop if an error occurs, and allows you to keep the error between iterations of the loop information shift registers.  Therefore, if an error occurs in one of these loops you can never hear about it.
    6. In general, using the error state as the main way to stop a loop from consumers is a bad practice. I'd rather see a "Shutdown" command which causes the consumer to stop loop. It is more scalable and less likely to be triggered by the accident.

    Good luck with the rest of your application.

    ~ Simon

  • Using the producer/consumer with GPIB/VISA model

    Hi all

    So I have a .VI I learned to communicate with my camera, I joined. I tried strip down as much as possible, just to understand the concept. It basically just takes a resource VISA name, use this open VISA, then uses the same resource VISA to write a command that reads the data from my machine (xall?) and then bed in 500 bytes and which prints. If it works, and it's good.

    I try to use producer/consumer model for doing essentially exactly what this guy. I have a RLC, I want to press a button that starts my measure, I want him to taste several times per second, save the data in a text file or .csv and then stop when I press the stop button. Thus, he will be given indefinitely potentially.

    I would like to have the data in a format something like:

    Time C R

    0 5.0 4.3

    ... etc.

    I read the link of model p/c above, but my LabView knowledge is still low. Currently, my plan is to take the part of read/write of my attached VI, which are a sub - VI and then put that in the pink box in the VI for the producer/consumer above page that is labeled "produce data to be placed in the queue":

    What prevents me to do this, it's that I can't get the piece of read/write to work properly as a standalone Subvi.

    What is the right way to go about this?

    Thank you!

    I put if you actually found data of your instrument.  Your instrument is not made to take new measures or just send you the last reading, she did.

    Insofar as the file IO, I recommend that you learn to use the palette for the file IO functions.  You need to create your file before your loop, write in a text file inside and then close after the loop.  I don't do the thing the comment on the express VI entry will do what you want.

  • change my model of producer consumer with different types of orders


    Right,

    Sorry I was not clear about that. I meant add the enum that I mentioned to the cluster.

  • Master/slave producer/consumer Feeback?

    We know that in the models of master/slave and producer/consumer can send information of the master loop or a producer to the loop of the slave or the consumer.  But what to get information of the loop of the slave/consumer back to the master/producer loop?  I think it may return some sort of output or a message saying something like "I finished my work successfully.  This can be done with local variables, but is it really a good idea?  Is there another better way?   In addition, in this case can I just use a sub - vi?    I don't know that I always get the PARALLEL treatment offerred by master/slave and producer/consumer with a sub - vi.

    You can use a notifier to send a return message.  You can use a local variable, but unless you know what you are doing, you might encounter problems with race conditions.

    Sub - VI have nothing to do with producer/consumer architectures.  You can do a p/c with or without sub - VI.  Sub - VI is a way to break the code in significant functional blocks.

  • FPGA and digital i/o Modules

    Hi all

    We have NI 9421 digital input and digital output NI 9472 Modules. We can run these modules into a VI under the 9073 cRIO chassis. While we have added the FPGA target under the same chassis, we cannot use the modules. We also install the scan engine.

    How can we use FPGAS and i/o Modules at the same time?

    Once you add a target FPGA in CompactRIO chassis, when you deploy the code, the cRIO is configured for the FPGA mode, which requires a bitfile compiled to connect with the C Series modules.  Remove the target FPGA or changing the mode of chassis in the project and by redeploying must reconfigure the cRIO for scan Mode, which allows you to use the IO module directly from the RT VI.

    For more information, see this post.

  • acquisition and recording of analog data with producer consumer model

    Someone on this forum, in a separate last week discussion, suggested that I use the producer model consumer data acq.  My ultimate goal is to acquire analog channels 1-4 continuous data, display graphical band style and save the data on the boot disk when the user presses the 'Start Saving' button (and will continue to display recorder cards).  Economy will stop when the user presses the button "Stop Saving" but strip map will continue to operate.

    My attempt to use the producer-consumer model is attached (LV 8.5 only).  It does not work.  I have not tried to implement for recording user controls - just trying to make simple continuous display and save (1 channel) at this stage, using this model.  VI runs, but the graphic Strip is never updated with the actual data, and the data file that is saved has zero byte inside.

    Thank you.

    WCR,

    Looked at your code, and you are right.  It won't work.

    Take a look at this example:

    http://decibel.NI.com/content/docs/doc-2431

    The VI of the acquisition must be inserted in the loop of the producer.  In addition, you must tell him how many samples for (otherwise, it will get 0).

  • Synchronization of the inputs and outputs with different sampling frequencies

    I'm relatively new to LabView. I have a NOR-myDAQ, and I am trying to accomplish the following:

    Square wave output 10 kHz, duty cycle 50%.

    Input sampling frequency of 200 kHz, synchronized with the output that I get 20 analog input samples by square wave, and I know what samples align with the high and low output of my square wave.

    So far, I used a counter to create the square wave of 10 kHz, display on a digital output line. I tried to pull the document according to (http://www.ni.com/white-paper/4322/en), but I'm not sure how sample at a different rate than my clock pulse. It seems that this example is intended rather to taste one entry by analog clock pulse. There may be a way to create a faster clock (200 kHz) in the software and use that to synchronize the analog input collection as well as a slower 10 kHz output generation square wave?

    I eventually have to use the analog inputs to obtain data and an analog output to write the data channel, so I need the impetus of the square wave at the exit on a digital PIN.

    How could anyone do this in LabView?

    Hi Eric,.

    All subsystems (, AO, CTR) derive from the STC3 clocks so they don't drift, but in order to align your sample clock HAVE with pulse train that you generate on the counter, you'll want to trigger a task out of the other. I would like to start by a few examples taken from the example Finder > Input and Output material > DAQmx. You can trigger GOT off the train of impulses, start by Gen digital Pulse Train-keep -you probably already use a VI like this to generate 10 k pulse train. AI, start with an example like Acq Cont & chart voltage-Ext Clk - Dig Start.vi-you'll want to use the internal clock so just remove the control of the "Source of the clock" and it uses the internal clock. From there, simply set the "Source of the command" either be the PFI line generates the meter, or ' //Ctr0InternalOutput '-assuming that you are using the counter 0. You'll want to make sure that the start of the task HAVE faced the task of counter I is ready to trigger off the first impulse. They should be aligned at this point.

    For debugging, you can use DAQmx export Signal to export the sample clock - you can then brought the train line and the PFI pulse to make sure that they are aligned.

    Hope this helps,

    Andrew S

  • Toggle the analog inputs and tasks of output on the same card in LabView

    Hello

    I'm relatively new to LabView and am trying to find the best way to switch between reading and writing tasks on my PCI-6024E. It seems this would be a common thing to do, but I found no good documentation or any relatable example program. Basically, I would like to be able to monitor certain analog inputs and then write that some outputs if an entry is in accordance with certain specific conditions (say > 4 Volts voltage). It is my understanding that you can only signal (input and output) types associated within a single task in DAQmx. I also understand that you cannot have multiple tasks running at the same time on the same material/map, otherwise you get a: 50103 error 'The specified resource is reserved. Calendar is not really all that matters to me, but quite synchronous and effective would be nice.

    I have attached a sample program that shows more or less what I'm trying to do. I want to follow several analog input lines (AI0 AI1, AI2 and AI3 and) effectively at the same time. If certain conditions are met, AI3 > 4 Volts, then write 5 Volts for analog AO0 and AO1 outings. I also want to maintain output at 5 Volts up to AI3 falls below 4 Volts. Is there a better way to pass the task to read and write than what I've done here? In a sense, all I really do is toggle of a state machine if the required conditions are met and if start/stop tasks of reading/writing necessary.

    One last question, is there a way to display the four channels in the waveform graph using the 1 d NChan 1Samp mode so I can have a time chart and indicators?

    P.S. I'm under LabView 2011 on Windows 7. Your ideas and suggestions are appreciated.

    Thank you

    KJ

    I also understand that you cannot have multiple tasks running at the same time on the same material/map, otherwise you get a: 50103 error 'The specified resource is reserved.

    This is incorrect.  You can't have two tasks of the same type running on a single card.  You can have an analog input and analog output task running simultaneously on the same hardware.

    You are right that each task can have only one type of task (entry or exit).  Discover DAQmx examples in the example Finder to get examples of synchronized input and output.

    PRO TIP: In the Finder of the example, go to the drop-down list in the lower left corner.  Pull down and select Add Hardware.  In the pop-up window, add your PCI-6024E to the right pane.  Click OK in this window.  Then in the main window of Finder example select your hardware from the drop-down list and check the filter results by the hardware.  The example Finder then only you will show examples that are out-of-the-box compatible with your hardware.  I am sure you can find something to fit your needs here.

  • How do I get the analog input signal and send it to output analog (real time)

    Hello world

    I do a simple task in Visual C++ and I use PCI-6221(37 pin).

    Basically, I want to send the same signal of "analog input" to the "analog output".

    at the same time (or almost), to make real-time application.

    Can someone provide me with sample program please.

    I would be grateful if you could provide me with the great tutorial that explains

    step by step everything about NOR-DAQmx for C/C++ programming.

    Best regards

    Khassan

    This is my code in C++, you can optimize it if that seems too messy. This code reads the analog input signals and exports it through the analog outputs.

    To make this code additional work of the directories include and library directories must be added to OR.

    I hope it helps someone.

    #include
    #include
    #include "NIDAQmx.h".
    #include

    #define DAQmxErrChk (functionCall) {if (DAQmxFailed (error = (functionCall))) {goto error ;}}

    int main (int argc, char * argv [])
    {
    Int32 error = 0;
    TaskHandle taskHandleRead = 0, taskHandleWrite = 0;
    Read Int32 = 0;
    float64 context [1000];
    char errBuffRead [2048] = {'\0'};
    char errBuffWrite [2048] = {'\0'};
    bool32 done = 0;
    Int32 wrote;

    DAQmxErrChk (DAQmxCreateTask("",&taskHandleRead));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleRead,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleRead,"",100.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,0));
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleWrite));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleWrite,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleWrite,"ai/SampleClock",100.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));

    DAQmxErrChk (DAQmxStartTask (taskHandleRead));
    DAQmxErrChk (DAQmxStartTask (taskHandleWrite));

    While (! fact &! _kbhit())

    {

    DAQmxErrChk (DAQmxReadAnalogF64(taskHandleRead,1,10,DAQmx_Val_GroupByScanNumber,dataRead,1000,&read,));

    DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleWrite,read,0,10.0,DAQmx_Val_GroupByChannel,dataRead,&written,));

    }
    _getch();

    Error:
    If (DAQmxFailed (error))

    {
    DAQmxGetExtendedErrorInfo (errBuffRead, 2048);
    DAQmxGetExtendedErrorInfo (errBuffWrite, 2048);
    }
    If (taskHandleRead! = 0)

    {

    DAQmxStopTask (taskHandleRead);
    DAQmxClearTask (taskHandleRead);
    }
    If (taskHandleWrite! = 0)

    {

    DAQmxStopTask (taskHandleWrite);
    DAQmxClearTask (taskHandleWrite);
    }
    If {(DAQmxFailed (error))
    printf ("error DAQmx: %s\n",errBuffRead); ")
    printf ("error DAQmx: %s\n",errBuffWrite); ")
    }
    printf ("end of the program, press the Enter key to quit\n");
    GetChar ();
    return 0;
    }

  • analog input and output synchronization

    Hello everyone, I seem to have a problem of synchronization of the analog input and output on my M-series USB-6211. My request is quite simple. I want to the production and to acquire a sinusoid at the same time. Theoretically, I should have the same 4000 data points through the input and output channels. The reality, however, captured on an oscilloscope, shows that the analog output is off more than 4000 data points. The entry (acquisition) shows 4000 samples. Please see below an excerpt from the creation of task, timing and execution. I'm afraid that the analog input and output are not attached correctly. Do you see something suspicious? Thank you very much! The task was created: DAQmxCreateTask("",&inTaskHandle); DAQmxCreateTask("",&outTaskHandle); Analog output channel Configuration, with 20Ksamples/s: DAQmxCreateAOVoltageChan (outTaskHandle, physChanOut, ' ',-10, 10, DAQmx_Val_Volts, NULL); DAQmxCfgSampClkTiming (outTaskHandle, "OnboardClock", 20000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 4000); Configuration of the analog input strings: DAQmxCreateAIVoltageChan (inTaskHandle, physChanIn, "", DAQmx_Val_RSE,-10, 10, DAQmx_Val_Volts, ""); DAQmxCfgSampClkTiming (inTaskHandle, "OnboardClock", 20000, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 4000); Set up the trigger: sprintf ("/%s/ai/StartTrigger", local_port, deviceName); DAQmxCfgDigEdgeStartTrig (outTaskHandle, local_port, DAQmx_Val_Rising); Output: DAQmxWriteAnalogF64 (outTaskHandle, (numberOfSamples * oversample), 1, 40, DAQmx_Val_GroupByChannel, input, & sampsPerChanWritten, NULL); Acquire: DAQmxReadAnalogF64 (inTaskHandle, 4000, 40, DAQmx_Val_GroupByChannel, readArray, 8000, & sampsPerChanRead, NULL); The tasks stop: DAQmxStopTask (outTaskHandle); DAQmxStopTask (inTaskHandle);

    Hello

    Change the finished continuous sampling method seems to solve the problem:

    DAQmxCfgSampClkTiming (inTaskHandle, "OnboardClock", 20000, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 4000);

    Also, I wanted to say earlier to write 4000 samples:

    Output:

    DAQmxWriteAnalogF64 (outTaskHandle, 4000,1, 40, DAQmx_Val_GroupByChannel, input, & sampsPerChanWritten, NULL);

    Thank you

  • I have mac pro 3.1 and it is insufficient for what is his is. I need an internal card with more flexibility to the inputs and outputs as used in windows systems.

    A sound card internal Mac pro 3.1 what they do?

    And if yes where can buy one?

    I need more input and output it attach to my PA and recording, hardware as I do with a windows PC.

    The mac comes with a microphone and a single output with terrible impact when it is connected to my sound stuff.

    A few people responded to your post above. Might be better to explain what your needs are, rather than starting a new discussion here.

    http://www.Sweetwater.com/C703--PCI_Audio_Interfaces

  • How to synchronize the analog input and the output of two different USB data acquisition boards

    Hi all

    I have two tips very different USB NI USB 6008 case, which I use to acquire the data (analog input) and a USB of NI 9263 is a output analog only site I use to route a signal (in this case a square pulse). The reason why I use the outputs analog 6008 is because I need to deliver negative tension and need the full +/-10 v range.

    Looking at similar positions, I'm pretty sure that I can't use an external trigger or a common clock, I also tried to use the timed synchronization of the structures but no cigar.

    I'm including a quick vi I whipped showing how the jitters because of the lack of synchronization signal. The OD of the 9263 connects to AI in the 6008 in this example.

    I talked to a specialist in the phone and tols me that's not possible.

Maybe you are looking for