Producer/consumer architecture - timing

Hello.
I have some question about producer consumer pattern.
People say that consumer shound NOT add elements into producer queue. Lets say that some states in in consumer need to stay active for eg 5 minutes. We also should be able to pause/resume state execution and exit program in any time. 
I ve used functional global timer but consumer adds elements into queue and this should be avoided.
How to solve timing problem? Some people have written about creating another thread - watchdog or asynchornous calls to vi...
Could someone explain this to me?  :

People have consumers add to their own queue all the time.  It is usually in a Queued State Machine though.  If you have a process that just needs to run for so long, then have the consumer run another while loop until the time is up.  It can then process the next item in the queue.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • Progmatically stop vi with producer/consumer architecture

    I can't seem to get my VI to fully stop, so that I can go on to do some more things in the program.  I am trying to progmatically stop the vi (pictured below), so that I can return to my main gui (not pictured).  The main gui just consists of a login, exit test system, and run test.  Once the user presses run test, the vi pictured below opens.
    I am using a producer/consumer architecture with a state machine.  The problem I run into is that when I press the "Main Menu" button, it should close the pictured vi and return to the main gui.  I tried using the vi server, and when the user presses the Main Menu button, it fires an event and then it goes to the Stop state in the consumer loop, which opens a reference to the vi's (one for the strip chart vi and another for the gage vi), closes the front panel using an invoke node and then closing the reference.  I also tried adding in the abort vi method after the close front panel and it still gave me the same result.
    Here is the catch, it does close the vi's, but it does not stop the while loops (producer and consumer), or it stops only one of the loops.  I thought of putting in a constant in the event structure for when the Main Menu event is fired, but that will stop the producer loop before the consumer loop reveices the info to go to the stop state, so the consumer loop does not end.
    I also tried a "dummy" control that was connected to the comsumer loop Stop terminal (for the while loop), and then progmatically changed the value in the stop case to true and then read that value in the producer loop to, hopefully, stop both loops, but it did not work either.
    I am sure that it is something so stuipidly simple that I cant see it right now
    Kenny
    Kenny
    Attachments:
    test system.gif ‏252 KB

    Hi Kenny,
    I think of two solutions to your problem. First, use the message queue to pass the message "stop" or something from producer to consumer or second (and I think, better), use occurrences. I made a little draft how it could work.
       You have to pass the occurence- Refnum to both VIs, the producer and the consumer, when the producer finishes execution, then use "Set Occurence".
       In the consumer blockdiagram you react on the generated occurrence.
    If you set in the VI- properties "Open Frontpanel when called" and "Close if originally..." the VI Frontpanel should disappear itself when execution is stopped.
    Hope this helps,
    Dave
    Message Edited by daveTW on 08-14-2006 04:53 PM
    Greets, Dave
    Attachments:
    occurrence 1.png ‏1 KB
    occurrence 2.png ‏5 KB

  • Producer/Consumer Architecture

    Hello All,
                    I am currently working on an application using State Machine Architecture where I have to monitor various parameters (7 temperature values & 3 pressure values), along with this I have to On/Off a Clutch using a digital Output for set time (e.g. On for "X" seconds OFF for "Y" seconds), but as soon as the pressure and temperature values go beyond upper or lower limits or whenever the user presses the Emergency Stop (that means I have to monitor Digital Input as well) so I am moving to different error cases depending on which values go beyond limits or emregency pressed etc..
                But this realisation is not working fine as I have to monitor and control several other things in addition to acquiring data....till now I just have used State Machine Architecture, I have seen Producer/Consumer Template but not quite sure how to realise such kind of application which involves data acquisition along with user interaction and monitoring.
    Could someone please put some light on giving similar kind of example or what else I can try with this problem.
    Regards
    James

    Hello James,
    A Producer/Consumer architecture will certainly do the trick for you. I am sending you an example that has the Data Acquisition section in the producer loop. However, you can also put your User Interface in the Producer loop and have the Data Acquisition in the Consumer loop. The Queues are used for sending data from the Producer to the Consumer(s) loop(s) (you can have multiple comsumer loops).
    You will just have to design specific cases to react to different user inputs.
    By the way, this example is from LabVIEW Basics II training course. If you have never taken LabVIEW Basics I and II, I highly recommend them. You can self-pace the class or take it with an instructor.
    LabVIEW Courses
    Hope this helps!
    Message Edited by Kalin T on 03-23-2007 09:57 AM
    Kalin T.
    National Instruments
    Attachments:
    ImplementedProducerConsumer.zip ‏250 KB

  • Functinal global variable for producer - consumer architecture

    Hi all,
    I am using a Producer - consumer architecture for my data acquistion as in the belwo diagram.. at some time i am stuck insde the while loop continously acquiring data .. is there any way i use one stop button as a functional gloabl variable and stop inside (consumer while loop) as well as producer architecture....
    Why i need this ?? so many design rules say that global variables are not a good idea...
    Thanks in advance...

    FGVs will work fine for your application.  You can also wire your error cluster to your stop button.  Your producer loop should throw an error 1 when the stop button is pressed, which will in turn stop your consumer loop.  But you would need a slightly different design for this.  Your consumer loop is designed to not advance until the stop button is pressed.  Instead of using and enum, you can use your producer loop to control the trigger to take a measurement.  No need for the while loop in the consumer loop this way.  You could set up your consumer loop to take a number of measurements, and then quit or take measurements for a certain amount of time.  Either way, you can stop your while loop when it times out.
    If you choose to stay with this design, a simple state machine archetecure might be better based on what I see.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • 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

  • State machine VS producer consumer architecture - Time Analysis

    After learning various methods to program efficiently and learn how to use SM and Producer consumer. I built a program to control stepper motor in both these techniques.
    Here is the RESULT. As we can see a simple state machine without any complicated producer consumer technique performs faster than the second one.
    I am not sure which is still the best based on performance and optimization. Please advise which one should I keep and why.
    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 ]

    This is with state machine alone
    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:
    Control 1.ctl ‏6 KB
    Control 2.ctl ‏6 KB
    Motor-UNI_Directiona Dev 3-TIME_ANALYSIS-2.vi ‏54 KB

  • Database producer consumer architecture

    Dear NI supporters,
    I am trying to devolope Producer/Consumer program to communicate with MS SQL database.
    The Producer loop select data from database1 and process them.The Consumer loop insert proccesed data to database2.
    The problem is, fast Producer loop must wait for slow Consumer loop and I have no idea why.
    I have attached really simplified VI. There are two parallel processes (while loops). First loop read large data and the execution time is high. The second loop read really small data, so execution time is low. So if I execute the VI, I would expect the fast while loop (FAST PROCESS) will get much more iterations then the slow one (SLOW PROCESS). But the reallity is, the FAST PROCESS will get the same number of iteration as SLOW PROCESS. It looks like the processes don´t run in parallel or did I just missed something?
    Could you explain me, why this occur, and how can I improve my code?
    Thanks in advance.

    vasicekv wrote:
    Thank you Jim, it really helps me!
    Do you also know any other library to communicate with database in labview which is reentrant?
    I mean I am focused on speed my labview-databse communcation up.
    Perhaps you should be considering why your consumer loop is so slow?  Is your database running on a dedicated server?  Is it getting bogged down?
    Please share a little of your real code so we can try to improve the performance of your consumer loop.

  • 2 producers/ 1 consumer for a Producer/Consumer Architecture

    I am trying to aquire two seperate tasks (one with analog and one with digital signals).  The digital signal needs to be aquired at a much higher rate (10 times higher).  The data from both of these aquisitions is required for writing to the same file and doing calculations.  I was wondering if it is possible to use 2 Producer loops and 1 Consumer loop?  I would need to use an enqueue in each producer loop and then dequeue them both in the consumer loop.  Will this work?
    Thanks.
    --Robert

    knapkerd wrote:
    I am trying to aquire two separate tasks (one with analog and one with digital signals).  The digital signal needs to be aquired at a much higher rate (10 times higher).  The data from both of these aquisitions is required for writing to the same file and doing calculations.  I was wondering if it is possible to use 2 Producer loops and 1 Consumer loop?  I would need to use an enqueue in each producer loop and then dequeue them both in the consumer loop.  Will this work?
    Thanks.
    --Robert
    Certainly.  You can  pass the reference wire for the queue you obtained into 2 different producer loops where you enqueue your data.  The same wire will pass into the consumer loop where you dequeue your data.  Of course with this method, you have no control over which loop puts its data into the queue first.
    It really comes down to what you are going to do with the data once you get it into the consumer loop.  Do you just want to write the data as you get it? What do you do with the calculations,  if you get 8 or 9 pieces of data from the one producer, then get a piece from the other producer, then get 11-12 pieces from the first producer, do you just hold on to the previous values from the older slower loop?
    Do you want to do this with 2 different queues?  If so, you may need to put some timeout functions on your dequeue functions in your consumer loop otherwise it will only run as fast as it gets the data from the slower queue.
    Message Edited by Ravens Fan on 05-07-2008 11:38 PM

  • Producer/consumer w/ScanEngine issue

    All,
    I have a large VI implemented with producer/consumer architecture using 10 events and uses conditional disables to select the data acquisition hardware.  The application is being developed in LV2009 with FPGA & RT on XP.  The application is intended to acquire and control analog signals in a cRIO-9073, but early development is done using LV simulated signals.  I can switch back/forth between the different configurations quickly & easily.  In the simulation mode, the front panel, controls, events, etc; all behave as one would expect.  When the conditional disable is changed to use ScanEngine and cRIO modules, then a very primary control fails to generate an event and does not function.  All other controls that can be tested are functional and generate their events.  I am at a loss and seeking suggestions on techniques to diagnose & fix the problem.  The application behaves as if the 'event structure' for primary control gets corrupted or some size threshold is been exceeded.  The whole concept, scanEngine based and simulated data, were functioning several days ago prior to numeruous edits and I can revert back to not using the scan engine and cRIO hardware with simulated data to validate correct function, but that is not the intended final path.  At the present time, I am stuck and looking for ideas.  All suggestions will be considered and appreciated.  The applicatiion is company proprietary and can't be posted.  Thanks in advance.

    I can definitely understand your confusion, and on the surface it seems like everything should transfer over.  However, when using simulated data you won't get errors that can occur once you introduce hardware.  Errors can prevent events from occuring, there is also the issue of timing, to see if when using actual hardware, the timing causes issues.  As I menationed before, there are a hundred different reasons why it would work with simulated data, but not actual hardware.  Please let me know if you need further direction in your troubleshooting.
    National Instruments
    Applications Engineer

  • First attempt at Producer Consumer Architectu​re: continuous read and dynamicall​y update parameters​.

    Hello,
    I am currently working with two instruments; an Agilent E3646A and an NI 6212 BNC. My objective is to have the 6212 to be continuously taking measurements according to predefined parameters while the E3646A's parameters can be continuously updated. This simple instrument combination is intended to help me learn the necessarry achitecture; continuous measurement, dynamic output control, and more instruments will be added in the future.
    I've previously posted on a similar, but more complicated, setup (http://forums.ni.com/t5/Instrument-Control-GPIB-Se​rial/Split-second-lag-when-controlling-two-instrum​... and was advised to try the Producer Consumer Architecture. I've found relevant literature on the site (http://www.ni.com/white-paper/3023/en/, https://decibel.ni.com/content/docs/DOC-2431), searched the forums and constructed my own VI. While my first attempt at a Producer Consumer Architecture has resolved some of the issues I was having when I first posted on the subject, however, new issues have arisen with regard to reading and stopping the VI.
    I am currently able to run the VI and update the device parameters. Previously, I would get a freeze while the instrument was being updated and could not toggle parameters until it was done. This has been resolved although the read only updates when a parameter has been updated although it is outside of the event structure. Furthermore the Stop button does not work in any context. I've also gotten occasional errors regarding the Deqeue Element but the bulk of the trouble is Error -200279 "Attempted to read samples that are no longer available" at DAQmx Read. I realize that there is a problem in my Producer Loop but haven't been able to figure out how to resolve it.
    This is my first attempt at a Producer Consumer Architecture and already I can see that it is a powerful tool. I read as much as I could and looked at the relevant examples but expected to have some issues in the beginning. Would really appreciate any advice so I can take full advantage of the architecture.
    Hope to hear from you,
    Yusif Nurizade
    Solved!
    Go to Solution.
    Attachments:
    DCe3646A_DAQ6212_Prod_Con_4_13a_2014.vi ‏89 KB

    Jon,
    Thank you for the response and the suggestions.
    I created the Local Variable for the Stop Button and moved the original into its own Event Case. It is now able to stop VI execution although I get Warning -1073676294 which I understand to be the buffer issue. The warning says that this was incurred on VISA Open for the E3646A's Initialize VI which is outside both loops, however, which I don't understand.
    I tried increasing buffer size by decreasing the Number of Samples as per suggestions I found on NI forum threads. I've brought it down as low as 1 but the graph still only updates when an Event occurs and I keep getting the same buffer error. You suggested that the problem could be that they are in the same loop; does this mean that the DAQmx read should be outside both Producer and Consumer Loops or moved into the Consumer Loop? I found a couple of links ( http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Design-Pattern-DAQmx-Event-Structure/td-p/2744450 ,  http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Architecture/td-p/494883 -first response) on dealing with an Event Structure that my own VI is based. Alternatively, I found another link ( http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Design-Pattern-DAQmx-Event-Structure/td-p/2744450 - first response) on a DAQmx Read with an Event Structure that places the graph in the Consumer Loop.
    The core of my purpose in setting up this Producer Consumer Architecture is so that I could read continuously while the instrument parameters are updated dynamically so it's very important that I understand how this works. I am particularly struggling with how the Event Structure is controlling the While Loop's Execution.
    Hope to hear form you,
    Yusif Nurizade
    Attachments:
    DCe3646A_DAQ6212_Prod_Con_4_14a_2014_Edit_I.vi ‏90 KB

  • Input and output on same device, producer/consumer structure

    Hello interested people,
    I have a question about using the same device for both digital inputs
    and outputs.  I have written a simple program of one while loop
    that continuously polls the device, processes, and requests.  I
    have addressed the device using two DAQmx Asst. and I have attached
    them with their error in/out cluster terminals to provide data flow and
    eliminate the chance of addressing the devices at the same time (which
    produces an error).  Now I want to change this program structure
    to a producer/consumer loop foundation with state machine.  
    In this design, I will have the DI in the producer loop and the DO in
    the consumer loop, under one of the states.  I can't simply
    connect the error in/out ports in this configuration, so my question is
    how to avoid the error caused by addressing the same device
    simultaneously with two different tasks (input and output)?  I
    have attached two VI's, the "One Loop" vi is the original configuration
    (simplified), and the Producer-Consumer vi is a NONSENSICAL program
    that simply represents the desired configuration.  (I don't need
    any comments on the programming of this vi, it is only an example for
    illustration of the problem). 
    I am thinking about bundling the input data and the error cluster, both
    from the PXI 6528 DI, into one cluster, queueing that up, and
    unbundling the de-queued elements for some kind of data flow between
    the producer loop and the "Request" state of the consumer loop. 
    Is this the right approach, or am I barking up the wrong tree?
    Thanks
    Attachments:
    One Loop DO DI.vi ‏102 KB
    Producer-Consumer DI-DO.vi ‏106 KB

    Hello,
    It sounds to me like you really have two modes:
    1. user interface actions determine execution
    2. user interface is locked, and execution is automated.
    I think it would make sense to use the producer consumer for an architecture.  Basically you would do the following:
    1. program the producer to handle the user interface as you normally would.
    2. provide one additional event case in the producer which would be your "automated handling" case.  In that case, you could put a state machine which could run until whatever conditions were met to put your program back in "user interface mode".
    Keep in mind that you can use custom USER EVENTS to programmatically generate events ie. you can trigger the start of your "automated handling" form anywhere in your code at virtually any time.
    I think this would allow you to take advantage of the producer consumer architecture in its intended spirit, while integrating an automated routine.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Producer Consumer Start Trigger

    Short Explanation: I'm using a 3rd party device to send a TTL signal to use as my start trigger in my VI. My cDAQ and modules appear to have the ability to send a start trigger independantly but I have been unable to hunt down how to do this in a producer/consumer system.  I do have an idea at the bottom of the long explanation.
    Long Explanation:
    I'm running a test system that monitors the pressure wave from a hydrogen/oxygen ignition. Components are a cDAQ-9188 with modules 9222 (x3 high speed AI), 9481 (x2 relay), 9402  (x1 I/O Module), 9221 ("Low" Speed AI). 
    Based upon recommendations in this forum I've placed my DAQ in a producer/consumer architecture. 
    At this point the system mostly works, I still have a few more things to add for all the information I want to collect. However, it records at high speed and the 9221 and the 9222 modules are synchronized. It has successfully collected good data as of this writing.
    When the system starts it will monitor, but not record. I need to fill the test structure with gas to a specific concentration before I ignite/record. When I press the record button I send a TTL signal from the 9402 to my high speed camera and I close a relay on a 9481 which engages a spark system. The spark system takes a variable amount of time to charge and fire so I have a timer that leaves the TTL and the relay active for a half second.
    My problem, and it's a small one, comes in with the monitoring system and the synchronization. In order to get the system to synchronize properly I had to generate an external pulse into PFI0 to use as a trigger. I attempted to assign the various clocks available as a start trigger but I ended up with unsynchronized data.  
    Is there a way to generate a pulse on my 9402 to use as a trigger? It feels silly to me to use an external device when I have something that can generate the signal I need.
    In thinking about this post I might have solved my problem, at least in my head. I'm thinking I can move the TTL output VI (which I will eventually change to DAQmx) into the producer loop and move my true/false statements to the consumer loop as a 1D array within my queue to start the record. Probably more to it than that but I can only learn by experimentation right?
    Thoughts? Recommendations?
    VI attached. 
    Solved!
    Go to Solution.
    Attachments:
    HUCTA Controls.vi ‏186 KB

    You can't generate a pulse with the 9402 itself. The pulse would actually be generated by the 9188. You should create a Counter Output task to generate a pulse train. Try the attached example as a start point to experiment with the counter.
    This Vi is for LabVIEW 2013, if you have an older version let me know and I will try to convert it.
    Camilo V.
    Applications Engineer
    National Instruments
    www.ni.com/support
    Attachments:
    Pulse Train Generator.vi ‏18 KB

  • Producer consumer waveform x axis

    I've run into a problem and I'm not sure of the source.  I'm developing a program that reads, displays, and writes thermocouple readings at different rates.  I'm using the producer-consumer architecture and while the sample rate will not be an option, the refresh rate of the chart that displays some of the temperatures will be controlled by the user.  I've been working with the attached example trying to understand where the problem lies with no luck.  The consumer loop is set to wait 2 seconds which I can tell it does but the x-axis still counts every second.  How do I sample from the producer loop and have the correct time and temperature displayed by the chart in the consumer loop?
    Thanks.
    LabVIEW 2012 - Windows 7
    CLAD
    Attachments:
    Plot Starting at Zero Seconds-2.vi ‏31 KB

    Sorry I can't look at your code right now as I am still waiting for my beta copy of LV for Android to arrive -- but seriously the x axis of a graph increments by 1 unless you set the multiplier property to something else.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • 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

  • Stopping producer consumer loop at the same time

    In my application I am using producer consumer architecture. In the producer loop, I am acquiring data, processing and outputting the result (feedback control system). Also in the same producer loop I am inputting all the data to a queue and then in the consumer loop I am writing data to a file. I have a stop control on the front panel and error from the queue and  error from the data acquisition all wired to OR gate to stop the while loop. ( I attached the picture of the code). Whenever I press stop form the front panel program wont completely stop. I think it is because consumer loop still running. Is there way to stop  the both loops at the same time. I tried creating local variable but it slows the program. Front panel stop control mechanical action is set to switch when released.
    Attachments:
    app.PNG ‏262 KB

    In the consumer loop you should check the error after the Read Queue function.
    TOn
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

Maybe you are looking for