03-09-2009 02:51 PM
Well, I thought I had this all figured out, but we finally had time to go to our lab and test it, and there seems to be an issue with the digital outputs here. I will address what the point of this VI is, and then describe the issue
Analog input is input and analyzed at the same time that digital outpt is being sent on on multiple (3) lines. The digital output is used to send a single, user defined delayed TTL pulse to other instruments as triggers. I have set this program to create an array of digital waveform for each channel, each of which are the same length as the analog input. A "1" is inserted at the proper place in the array, replacing a "0" value, creating the array required. This array would then be written on a digital line (1 channel, N samples). Three of these subVIs are used here, so three different waveform arrays are created and writtin to its respective lines When the program runs, the analog input seems to work fine, but only one digital output is executed. I need all three lines to write simultaneously.
I am using a USB-6221 with LabView 8.2
I have attached all of the files necessary to execute this program, and if the folder "LabView Programs" is saved in the C drive, I should think that the file paths should be correct.
Thanks in advance
Solved! Go to Solution.
03-10-2009 09:15 AM
Hi LVhelpMe,
Thanks for your post and I hope your well today.
I would suggest only using 1 DAQmx Digital Task and writing a waveform with all the channel information.
When you ran the code do all the subVIs excute? Or do you get some errors?
My concern is with your current code is could the sample clock AI be closed/erased before the Digital tasks have finished - this would be a problem as your using the AI sample clock as the clocked digital otuput source.
Could you try the follow example from the NI Example Finder -
Write Dig Chan - Ext Clk.vi for seeing how to use one Digital Output task for more than one channel.
Cont write Digt Port - Ext clk.vi to see how I would suggest starting, waiting, and then stopping the tasks without removing the sample clock to early.
I hope this helps,
03-10-2009 01:48 PM
Hillman
Thank you for getting back to me, I compiled the digital triggers into one task, which seems to make sense to me, I also changed the sample clock mode for the digital waveform generation to continuous samples. I also wrote in some simple case structures to turn on on or off the various triggers. I am still running into the same issue, it seems to stick on the "wait until done" function within the "waveform trigger" subVI. I know that the write to spreadsheet file paths are incorrect for this particular program, but that is not my concern right now.
I am wondering why the "wait until done" function never seems to finish, once the digital waveform arrays are written, shouldnt that finish?
Thanks again
Chris
03-10-2009 01:50 PM
I seem to have forgotten to attach the updated version, it is the March 10th version
03-11-2009 07:24 AM
Hi LVHelpme,
Thanks for the update and I hope your well today - sorry for the delay in getting back to you, but I support the forums in my 'spare' time at NI UK.
Also I am sorry I didn't stop this sooner,
Your Digital Output DAQmx task has been setup as continuous.. therefore this never finishes - hence wait until done never happens. You need to configure the task to be finite, much like your Analog Input task in the main vi. You can setup by changing the sample mode enum for the sample clock to finite.
Please let me know if this resolves the issue your having, it certainly seems like it should do.
Hope this helps,
03-11-2009 11:43 AM
Hillman
First of all, thanks for the reply. I made that change, and whether that was the cause of the problem or not, it makes sense. That did not solve the problem as why the task moves past the "wait until done" function. I decided to try removing it, and put an indicator for the number of samples per channel written and this shows that all the samples are written, but they dont seem to be writing at the proper sample rate (way too fast).
I am starting to wonder whether or not my understanding of digital waveform data may be flawed. I have the arrays written to be the same size as the analog input, and the task should write one sample from that array until the entire array has been written. The fact that one value in that array is a "1" acts as the TTL output for the other instruments.
Again- I attached the most recent update, which is located in the USB-6221 folder
Chris
03-11-2009 04:30 PM
Hillman and anyone else out there
Since my previous post, I connected my USB-6221 to an oscillascope, and wasn't able to see any pulses using the digital waveform Nchannel Nsample function, even using the "write digital channel, ext clock" example. I have been using the AI sample clock for this, and am honestly stumped. Once again, the subVI "waveform trigger" is used to write the digital data, at the same time that analog input is acquired.
Thanks
Chris
03-12-2009 03:44 AM
Hi Chris,
Good Morning and I hope your well today.
Thanks for your updates.
I think it my be best if we start from the begining,
1. Could you try the example Correlated Dig Write with Counter.vi from the NI Example Finder?
It produces a counter output as the timebase for the digital output - to get clocked digital output.Do you see the waveform being outputted on your outputs which match the Digital Waveform Graph on the Front Panel?
If not, try using one of the other examples such as, Write Dig Port - this is a simple VI just to send one value to each digital line. If this doesn't work, there is a connection problem.
2. If we have got this far without problems, then the next part would be to modify the waveform so you could write the data you wish..
The digital waveform can be made from a boolean array and then using the DWDT Boolean Array to Digital.VI to convert to the digital waveform type. The waveform will have X number of samples. Therefore upon every clock pulse you will output 1 sample onto each channel. So if you set the rate to 1000 and number of points to 1000 (samples) it will output the waveform one a second. (as its continuous the DAQmx will loop back through the buffer and start outputting the waveform again).
Note, have you seen the Digital Waveform palette? It can be found under waveforms and has more vi like the DWDT Boolean Array to Digital.
Please let me know how you get on,
03-12-2009 10:59 AM
Hillman
I ran the correlated Dig Write with Counter VI and that worked fine, I was told to use the analog input as the source of the sample clock for the digital signals so the ai is syncronized with the DO. I have tried to modify the example VI to use the ai sample clock and get error -89120. Would it be better (or even possible) to use a counter as the source of both, or should the analog input be used for both?
Thanks for all your help so far
Chris
03-12-2009 03:33 PM
Hi Chris,
I quickly read through your posts with Hillman and I see that you need to synchronize your analog input with your digital output. I created a quick example based on the developer zone article:
Synchronize Two Counters using a Dummy AI and an Arm Start Trigger
http://zone.ni.com/devzone/cda/epd/p/id/6081
I attached a copy of the code (LV 8.2) and a screen shot of the code below (if the code does not work). This may not be exactly what you need in your appilcation but it shows how you can use the ai/sample clock as the source for the digital output. Hope this helps!