11-08-2011 12:46 PM
It has been something like 15 years since I did this kind of thing in LabVIEW and hmmmm, things sure have changed.
Anyway, I cannot seem to get a grasp of how to do the following with the incredible maze of VIs that now exist (each "task" seems to have been blown apart into many tiny parts with little intuitive sense as to what must go where).
Here's what we'd like to do:
Open a shutter which is initially blocking a light beam used to provide the light source which is converted to voltages by a light-intensity measuring device.
10 ms later, start acquiring voltage data.
10 ms later (after data acq starts), provide a single pulse to trip a flash device.
Continue measuring until 1000 data points have been collected at 10 microsec resolution.
Close the shutter.
The equipment we have:
- cDAQ 9174 chassis
- NI USB-9215 (ai)
- NI USB-9401 (dio)
Attached is a diagram of the experiment. (Also pasted here.)
I would really appreciate pointers as to how think about going about this and whether there are examples of how to do this. Also, is it possible to do this using simulated instruments (I'm working off-site without the actual modules attached to this laptop)?
Thanks.
11-08-2011 01:46 PM
Hi pfurbacher,
Welcome back to Data Acquisition. Things have certainly changed quite a bit since 15 years ago.
The image you attached shows 1000 data points at 10 us resolution, which would only be 10 ms. I'll assume you want 10000 data points instead which would give you the 100 ms of data depicted in the drawing.
Here is the basic idea of what you need to do:
The external signal created by the shutter can be used as a start trigger for your analog and counter output tasks (if you intend to use the 4 counters for other purposes then you could substitute a digital output task instead of the counter task). Both of these task types have a delay property which can be used to achieve your timing requirements.
A couple caveats are:
1) The line direction on the 9401 is only configurable by nibble (i.e. lines 0:3 must all be the same direction, lines 4:7 must all be the same direction), so the trigger source and counter output terminals have to be on separate nibbles.
2) The Read function will block until the desired number of samples are available (or the timeout has occurred--default 10 seconds). If you'll be waiting for a long time for the trigger, you might instead want to make your program event-based (or at least poll the available samples before calling DAQmx Read) to prevent the code from being unresponsive while waiting for a trigger or from receiving timeout errors. I didn't show this in my example which is intended to show the hardware configuration.
Best Regards,
11-08-2011 01:56 PM
Thanks for the quick response.
In your design, you seem to suggest that the shutter is human-controlled, not VI-controlled. I was intending (but failed) to indicate that the VI would drive the shutter on a DIO line (5V). Hence, all operations would be done programmatically. The operator would just set the VI (eventually a larger program for configuring parameters and saving captured data) to run. From there, the shutter would be opened, the DAQ started, and the flash popped.
I'm guessing that I'd use another digital output (or counter out?) to control the shutter. Is that right?
Thanks.
11-08-2011 02:09 PM - edited 11-08-2011 02:11 PM
Hi pfurbacher,
Ah you are correct, I had assumed the shutter was external.
You could use another counter to control the shutter, or you could use digital output. It's up to you which one you decide to use.
Digital output would require building the correct waveform to give you the correct spacing of the two pulses (if you use digital output, it would make the most sense to use it for both pulses). You can trigger the digital output and the analog input together by sharing a start trigger between the tasks.
If you use a 2nd counter for the shutter pulse, you can use its internal output as the trigger for the other tasks (make sure the shutter pulse counter starts after the other tasks in software to guarantee that they are armed and can accept the trigger when it is generated).
Best Regards,
11-17-2011 10:06 AM
It took me some time to work this out but I think I have it now. We'll see when it is tested in the lab. (I'm working remotely and can only use a simulated chassis and modules.) If you have a moment, please take a look at the diagram. It uses the internal output of counter 0 which is the counter which drives the timing for the shutter pulse. Although I don't like using sequence structures, I used one to make sure that the shutter control counter starts after the arming of the DAQ and flash counter.
Thanks for your help.
11-17-2011 11:01 AM
Seems as though I wasn't following the correct procedure for inserting images. Let's try that again.
Also, here's the image which is missing from my first message. It shows the timing (it may also have mistakes in the number of data points, resolution, etc. -- just ignore them).
11-21-2011 08:23 AM
Greetings,
its looking good, also, I must add that you can find excellent examples of master/slave templates on LabVIEW by browsing to Help > Find Examples for reference.
Once you have the NI Example Finder, navigate to Hardware Input and Output > DAQmx > Synchronization > Multi-Device and from there, you can open a variety of sample VIs which can help out.
Keep me posted on the status of your set-up.
Regards,
Aldo A
11-21-2011 09:33 AM
Thanks for the suggestion, but I had been through those long ago in this process. Didn't seem to help much -- they don't explain the rationale behind the design. That is, they need some tutorial text wrapped around them, at least for me. I have little problem thinking visually, but I do have a problem when someone doesn't explain why one VI has to follow another. Why would I put a sample clock VI after a counter task creation VI, and so on. Or, how would I know that there are internal connections between devices/functions (counters and AI or DIO operations)? I'm not sure that I have yet found the text-based explanation of these intricacies which are vital to understand for wiring things up the way I needed to.
That's why I came to this discussion forum, to get text-based explanations as much as diagramming examples.
11-22-2011 02:56 PM
Things have progressed fairly rapidly from the 15 years since you've last used LabVIEW. We pride ourselves on our forums and the opportunity to have NI Engineers assist customers.
If you like, we do offer courses that go over various topics and ways of using our software and hardware. NI Courses The Multifunction DAQ course covers the topics related synchronization and DAQ hardware.
If you are curious about the sample clock being placed after the counter task, the sample clock vi creates a buffer for the data values to be stored when the gate input is toggled. This is mainly useful for very fast events where the latency to actually read from the counter is longer than the time before a new count is written to the counter register. The following tutorial that shows buffered event counting and how its set up in LabVIEW. Buffered Event Counting Tutorial
In Measurement and Automation Explorer, you can look up your particular DAQ device and find a routing table that shows all the possible connections and all the features of your particular card. These are great when you need to route triggers or any other signal on the board.
For text explanations of what is happening with examples, tutorials would be your best area to look in. If one of the tutorials doesn't make sense to you or you just have some questions about ways of tailoring an example to your needs then make a post.