03-21-2011 10:51 AM
Hello,
I want to modify my program and before I start I would like to ask you for your ideas and hints.
Current state: I am using the NI USB 6009-Module and I have created a program, which acquires data, displays and stores it. It consists of a consumer producer structure.
Target: The same program should also acquire, display and store data from another USB-I/O-module (HBM espresso). The computer can be connected to the NI-module or to the HBM-module or to both at the same time.
Modifying the program so that it can handle both I/O-modules is easy but I am not sure what to do, to make it work when only one of the two modules is present.
Maybe the program should ask the user first, which modules are connected, and then it runs the relevant VIs? Maybe it should load the relevant VIs dynamically?
I wonder if I should place both daq-subVIs in the producer structure or one in the producer and one in the consumer structure at the place, where the data is over given from the producer?
I have no idea which way would be the best and I'd appreciate your help.
I will post the VIs in a few minutes.
03-21-2011 11:38 AM
Here are the vis. I haven't uploaded their sub-vis. Is that ok?
The HBM-vi is stil under constuction and it should somehow be included in the Steuerung-vi. I could either add some I/O-terminals to the HBM-vi or I could overgive the data via global variables. What do you think?
Please don't complain about all the local variables - I know that I should have better used clusters 🙂
03-22-2011 10:45 AM
Hi Johannes,
I had a look at your VIs. You are using a Producer/Consumer Design Pattern in terms of user input. In terms of the actual task of your application - data acquisition and displaying - you are implementing a simple loop structure.
Consider implementing a producer/consumer design pattern for data acquisition as well with acquisition being the producer and display the consumer. You could have a producer loop for each acquisition device and one display (consumer) loop procing both cues. Make sure to use a timeout as you do not want the display loop to hang as one device is not attached to the PC.
This, of course, would require a rewrite of your program and not a modification to the existing VI. Modifying your current VI seems not resonable to me as the result is likely to be poorly maintainable.
This document describes how to tell if your USB-6009 is present in your system:
Programmatically Determining What DAQ Devices Are In My System
http://digital.ni.com/public.nsf/allkb/AE521D8AEFD27E1E86256F9F007DF570?OpenDocument
Regards, Topp
PS: I advise you to use type defined enum constants for your queue commands. This way, no spelling mistakes can happen and it is easy to add a new command.
03-22-2011 11:35 AM
Topp, thank you for your help!
The HBM-vi has a producer/consumer structure to handle user events, which is not usual. I noticed that too, but I did not create that VI. It came as a demo together with the hardware (HBM espresso I/O module).
The other vi (Steuerung_V2_51) is my own vi and it is made for the NI USB 6009. I hope I have implemented the producer/consumer structure correctly!? I also implemented an event structure for some user events.
As you can see the data goes from the producer (in the lower section of the block diagram) to the "analog in" state in the consumer structure.
Thanks for the hint concerning two producers – I think I will implement it like that.
If I upload a vi in this forum, should I also upload the sub-VIs? Should I zip it?
03-23-2011 07:36 AM
Hi Johannes,
your producer/consumer design pattern is implemented with a notifier. This pattern is usually referred to as Master/Slave. Producer/Consumer uses Queues.
Application Design Patterns
http://zone.ni.com/devzone/cda/tut/p/id/5218
You can upload single VIs directly, if you have many VIs, it is probably more convenient to zip the files. Only upload what is necessary to describe your problem.
Regards, Topp
03-23-2011 07:50 AM
Hi Todd,
there is a reason, why I use a notifier: The transferred data has to be up to date. If there is a delay in the consumer structure for any reason, the notifier sends always the latest measurement value. A queue would send "accumulated" old data instead and I don't want that. I hope you understand what I mean.
Is my program still a producer/consumer even when I use notifiers instead of queues?
04-04-2011 02:20 AM - edited 04-04-2011 02:20 AM
Hi Johannes,
sorry for my late reply.
As you are using a notifier I would call your design pattern master/slave (of course, still one loop produces data and the other loop consumes data).
The difference between master/slave and producer/consumer is exactly as you described:
In a master/slave design pattern only the most recent data is processed. The slave only works when the master tells it via a notification.
The producer/consumer design pattern processes all data that the producers creates. The consumer is working as long as data to "consume" is available.
Regards, Topp