Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating 1 Digital Pulse Train + 4 Analog Pulse Trains (with Custom Amplitude)

Solved!
Go to solution

I have the following hardware setup and was hoping for some advice on how to approach pulse train generation with my DAQ (USB-6343).

 

I have a TTL input coming into my DAQ.  When I see a rising edge, I would like to generate:

  • 1 Pulse Train to a Digital Out with 1,000 Pulses, at a Frequency of 1 kHz, Duty Cycle of 0.5.
  • 4 Pulse Trains, each to an Analog Voltage Out, with 1,000 Pulses, at a Frequency of 1kHz, Duty Cycle of 0.5.  The "low" value of the pulse train should be 0V, and the "high" value of the pulse train should be some constant pre-set value (between 0-2V).

These pulse trains should all by synchronized to trigger when the TTL input sees a rising edge.

 

I have figured out how to do the first part, which is to generate a pulse train to a Digital Out by using a counter.  However, I had a few questions about the 2nd part:

 

  1. What is the best way to generate the analog pulse trains?  I found this VI (http://www.ni.com/example/29787/en/) but am not sure exactly how it works.
  2. Is it possible to use the same TTL input as the digital edge trigger for both the Digital Out and the Analog Voltage Outs?
0 Kudos
Message 1 of 5
(3,368 Views)

So after doing some research, it looks like I can use a function generator to generate my square wave signal, and feed it into a MultiSample in an AnalogSingleChannelWriter.  Is that heading in the right direction?

 

A few follow up questions.

  • If I want my square wave frequency to be 1 kHz, then what would be my sampling rate?  Is 2 kHz enough (thinking of Nyquist sampling).
  • Is there any disadvantage in terms of performance of using a function generator?  Can I expect my square wave to be reasonably sync'ed with the pulse train that was generated from the counter?
0 Kudos
Message 2 of 5
(3,342 Views)

1. Your X-series board supports AO retriggering directly so no need for the extra complexity of the linked example that comes from a time before X-series hardware was introduced.

 

2. Yes, both tasks can be triggered from the same TTL input

 

3. You'll need all your AO channels to be in a single AO task, but fortunately it sounds like you can write the same data to all channels.  An array of waveforms will probably be the easiest format.

 

4. Yes, for square waves, you'd be fine generating a 50% duty cycle 1 kHz pulse train using a 2 kHz sample rate.  AO values from multifunction boards don't decay, so there's nothing to be gained from a faster sample rate and more samples per cycle.

 

 

5. Are you talking about a Function Generator vi to calculate the AO data?   I'd probably skip it and just create the data array manually for a simple case like yours.  It'll just be an alternating series of 0 and 5 volts.  

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 5
(3,327 Views)

Kevin,

 

Thanks for the helpful response.

 

  1. When you mean the X-series board supports AO re-triggering directly, you mean that I can use a DAQmx Trigger Property Node to set Retriggerable to "True", correct?
  2. Why do my AO channels need to be a single AO task?  I think in my problem description, it was not clear, but each of the analog square waves might have a different range (e.g. one might be 0 to 1.2 V, another might be 0 to 0.8 V).  Would I then use a AnalogMultiChannelWriter and generate my waveforms manually (i.e. via my own code)?
  3. So the last question I have is that when I go to generate my AO task, I need to set the DAQmx Timing (Sample Clock).  What should I be setting the Timing to?  Should I just be using the Internal Output of the counter (that I'm using to generate my digital pulse train), as its Clock Source (as long as the duty cycle of my digital pulse train, and the duty cycle of my square wave are equal)?  Would I set the sample mode to continuous?
0 Kudos
Message 4 of 5
(3,322 Views)
Solution
Accepted by topic author airoll

1. Yes, use DAQmx Trigger property node, set Retriggerable==True

2. The AO subsystem can only support 1 hw-clocked task.  Multiple channels of hw-clocked output must all be part of the same AO task.  All channels are clocked simultaneously, but each channel *can* output different voltages.  I'm not familiar with "AnalogMultiChannelWriter" and can't comment.

3. No, you can't use the Counter ouput which is at 1 kHz b/c you need to observe Nyquist for your AO and output at 2 kHz.  You can just set a rate and leave the SampleClock source unwired, which will default to using an internal clock. Within the same board, the Counter and AO tasks will have no relative timing drift.

   Also, no, don't use Continuous Sampling mode.  That's at cross purposes with being Retriggerable.  Use Finite Sampling, 2001 Samples at 2 kHz, voltage values similar to [0,5,0,5,0,5...0,5,0].   One extra sample at the end to bring the voltage back to 0.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 5 of 5
(3,317 Views)