LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send counter/digital outputs while acquiring analog data

Solved!
Go to solution

Hello all

 

I am looking to acquire analog inputs on several channels, and send single TTL pulses out at different times during acquisition using a UBB-6221 board.  The delays from the beginning of acquisition and the output of the TTL's should be handles by a control on the front panel.  I have gotten this to work using software timing and an inexpensive board before, but the program needs to be more accurate than this (hence hardware timing).  I am writing the program using LabView 8.2 and DAQmx, but if needed, I have 8.5 available as well.  I am plenty familiar with the general LabView program, but am not comftorable with DAQmx, which I assume I need to use (I have only really used the Assistant).  If there is an example of this somewhere, or if someone has done this in the past, I would really appreciate the help!

 

thanks!

0 Kudos
Message 1 of 12
(5,431 Views)

Hey,

 

You will find a lot of examples on low-level programming under [LabVIEW Folder]\examples\DAQmx\....

I would suggest you to have a look at the analog in examples to simply understand how to work with the low level vis, then to have a look at the synchronization folder so that you can see how to synchronize different tasks with each other.

 

You will need to synchronize your DIO with the AI task timing. However out of your description you will need to implement a kind of logic to exactly write the digital patterns at the desired times.

 

Hope this helps,

Christian

Message 2 of 12
(5,430 Views)

I came up with this, simply by modifying the analog input/digital input example, and putting a counter output in, I am not sure how to make the timing work, but does this make any sense at all?

 

Thanks!

0 Kudos
Message 3 of 12
(5,407 Views)

Hello,

 

I am wondering if you could be slightly more specific on what kind of pulses you wish to output based on the AI signal and the situations in which you want to output them. Are you going to be outputting a pulse train after the AI task starts, or will you be generating a single pulse? It sounds like you may be trying to generate a single pulse based on some trigger, and that you would like the option of setting a delay and to also change the duty cycle (high ticks and low ticks). Is this pulse supposed to be synchronized with the AI sample clock in any way (this appears to be true since you are trying to share the ai/sampleclock signal in your program)? If so, the best option would be to perform a retriggerable pulse generation, in which the trigger is the AI sample clock. An example of this type of program can be found in the Example Finder under Hardware I/O » DAQmx » Generating Digital Pulses » "Gen Dig Pulse-Retriggerable.vi". Please let me know if this is the type of behavior you are trying to produce or not. Thanks!
Daniel S.
National Instruments
Message 4 of 12
(5,374 Views)

Thanks for the reply

 

What I am trying to do is send a single TTL high (5V) pulse from the board to other instruments in the lab.  There will be multiple outputs when the program is finished, (more channels of outputs of single pulses to different instruments).  The pulses needs to be synced with the analog input because the data acquired from the other instruments is related to the data that is being acquired which changes in the course of time.  When I get this figured out, the delay should be started at the same time as the analog input, and send at its respective time.

 

As an example

 analog data 20,000 samples at 100 Hz

 Delay 1 = 0 seconds

 Delay 2 = 10 seconds

 Delay 3 = 15 seconds

 

 

Time:         t=0 sec___________________________________t=10 sec______________________t=15 sec________________t=20 sec

 

Analog:    Analog input starts__________________________________________________________________________ analog input finishes

 

Digital:     TTL to instrument 1____________________Single TTL to instrument 2______Single TTL to instrument 3                       

 

 

 

0 Kudos
Message 5 of 12
(5,364 Views)

Hi LVhelpME,

 

Thanks for the details. Based on the type of application you are creating, my suggestion would be to use a digital output task and correlate this with your analog input. In this way, you can create a digital waveform which consists of 20,000 samples and you can place the pulses within this waveform at the exact position you would like. Once you share the ai/sampleclock as being the source of your digital output sample clock, you can have the tasks synchronized together such that the pulses will occur at the exact moments the analog input acquire a sample.

 

You may find a good example of performing this type of correlated digital output using an external clock in the LabVIEW Example Finder under Hardware I/O » DAQmx » Digital Generation » "Write Dig Chan-Ext Clk.vi". In your case, you would want to also have your analog input task running and sharing the ai/sampleclock as the source instead of an external source. Additionally, as in your first example, you will want to make sure that the digital output task is started before the analog input task since it will wait for the ai/sampleclock to start.

 

Additionally, I wanted to point out that you can create a digital waveform programmatically or manually, but the easiest method I have found for creating digital waveforms is to use the NI Digital Waveform Editor. This is a very good tool to use and makes creating these waveforms very simple, especially when dealing with increasingly complex waveforms and multiple channels.

 

Regards,

Daniel S.
National Instruments
Message 6 of 12
(5,338 Views)

Daniel 

 

I finally got a chance to look over my program again this morning, I think I got the tasks rolled into one sample clock, If what I did is correct how would I go about incorporating a delay in it while still sampling analog data? 

 

Thanks again for all your help!  

0 Kudos
Message 7 of 12
(5,308 Views)
Hi LVhelpME,
 
It does not appear that the VI you created will function properly because you will need your analog input and digital output tasks to be separate. I have attached a screenshot of what the block diagram should look like in order to run properly. Additionally, in order to implement the pulses you want with the appropriate delays, you will want to create your own digital waveform accordingly, rather than using the method in the example program which just creates a standard "toggle" pattern. I have also included a screenshot of a simple waveform which may be created using the NI Digital Waveform Editor. As you will see in the picture, your waveform should just consist of single pulses corresponding to the points in time you wish for these pulses to occur, on a single digital line. In the picture, I have shown a pulse occurring at the 10 second mark. If you do not wish to use the Digital Waveform Editor program, you can simply create your own array of data and include the same number of samples, with the pulses occurring at the proper points in time based on which sample this happens at (ie - if using a rate of 100 Hz, a pulse at t=10 seconds would occur at sample number 1000). Hope this helps,
Daniel S.
National Instruments
Download All
Message 8 of 12
(5,289 Views)

Hello all

 

I am back at it again, I have gotten the program written as Dansch said, and it seems to be working fine, however, the program seems to be held up by my digital waveform generation.  I do not have the waveform editor, and don't have the funds to purchase it, so I used a for loop to create an array.  Is there some other way to create an array of waveform that I am missing that would not take up all of this space?  The array would need to be low until a time specified from the front panel, where a single high pulse would be sent and then low again.

0 Kudos
Message 9 of 12
(5,090 Views)
Solution
Accepted by topic author LVhelpME
Hi LVhelpME,

 

There are a number of different ways to do this, but I created a quick method which makes a digital waveform with the requested number of samples and rate, and then allows you to specify at what time you want to insert a "trigger" (which basically means it will place a high in at that point in the waveform). I did this by using only 3 functions and a for loop which iterates depending on how many triggers you wish to insert. You can use a similar method or just make this code into a subVI that will create your correlated digital data according to total number of samples, sample rate, and what specified times you want the triggers to occur at. I have attached the VI below for LabVIEW 8.0 and later, as well as a screenshot showing what the digital waveform will look like based on what values are entered for trigger times. In the screenshot below, you will see that there are 2000 total samples which are output at a rate of 100 Hz. Thus, the total waveform will last for 20 seconds, and the trigger times are entered as 5, 10, and 15 seconds.

 

 

 

The next image shows a zoomed in view of the trigger that is created at the 5 second mark, which will last for the sample period of 0.01 seconds (period of 100 Hz sample clock).

 

 

 

Hope this helps,

 

Message Edited by dansch on 11-22-2008 04:24 PM
Daniel S.
National Instruments
Download All
Message 10 of 12
(5,065 Views)