Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

can I generate a trigger with counter out put?

Hi Puspa,

 

I believe the error is occuring because your merge signal output array has no elements (the #0 on the wire).  Thus, you are never writing anything to the DAQmx Write VI.  It looks like the waveform sampling info cluster on the left has two "#s" components.  Click on one of the "#s" entries and change it to "Fs", and make sure that the values you have wired into "#s" and "Fs" are your sine wave's number of samples and sample rate, respectively.  Also, double click on each of your merge signal VIs and make sure that the "Append only if t0 aligns and dt matches" checkboxes are not checked.

 

A for loop that iterates once and no for loop at all are equivalent in your code.  Similarly, you can remove the case structure around your DAQmx Start VI.  The case structure considers whether it is the first time it is iterating when running the code.  If so, it starts the task.  If not, it does nothing.  Since your for loop will only ever iterate once and there is no other way your code could reach that case structure a second time, the case structure can never reach the false case and is thus unnecessary. 

 

Regards,

David R
Systems Engineer
National Instruments
0 Kudos
Message 21 of 36
(3,739 Views)

Hello David,

Thank you for your reply. I did following change to my VI

a) I changed #s to Fs

b) Unchecked "Append only if t0 aligns and dt matches" box inside both Append Signals VI

c) Removed “for Loop" and "case structure"

 

After making above changes, it solved previous error but now I am seeing different error. Picture below.

 

It says "number of samples to write must be same". As far as my knowledge for both channels function generator, same sampling info wire is wired and I do not understand why it’s throwing this error.

 

Please help,

PJK

Error 200103.PNG

 

0 Kudos
Message 22 of 36
(3,738 Views)

Hi Puspa,

 

As of now, the number of samples you have in each channel is equal to the number of zeroes plus the number of samples (#s) in your waveform data, i.e. 1+1000 and 50+1000 for your two channels.  With the waveform data type, you have to merge signals of identical length for DAQmx Write to interpret it, as it expects to write an equal number of samples to each channel.  Therefore, you could simply append 49 samples of zeroes to the end of your first set of data so that each signal has 1050 samples.

 

An easier solution would be to use a 2D array of doubles.  Arrays will automatically add zeroes to the end of "shorter" rows or columns, as there cannot be rows or columns with different numbers of elements.  To make this change in your code, you only need to do two things:

 

1. Double click on your "Convert from dynamic data" block and change the resulting data type to "2D array of scalars - rows are channels".

2. Click on the polymorphic VI selector on your DAQmx Write VI and select Analog>>Multiple Channels>>Multiple Samples>>2D DBL

 

Any broken wires resulting from step 1 should be replaced by double orange wires (indicating a 2D array of doubles) when you complete step 2.

 

It is also generally good practice to add a DAQmx Wait Until Done VI and a DAQmx Stop Task VI in between your Start and Clear VIs.  This will ensure that the generation completes and the task is stopped before attempting to clear it.

 

Best regards,

David R
Systems Engineer
National Instruments
Message 23 of 36
(3,730 Views)

Hello David,

 

Thank you very much for your help and support. This is been a great learning process for me so far.

 

I made all the changes your recommended and finally my VI is functioning. But have some different issue.

 

The output from my channel one is a complete single sine pulse whereas the output from my channel 2 and channel 3 are not a sine pulse. Its looks like a half sine pulse with some DC offset in beginning. Please see picture attached.

 

Thank you for your help.

 

best,

PJK

 

Newcapture.PNG

 

 

 

0 Kudos
Message 24 of 36
(3,727 Views)

IMAG0073.png.jpg

0 Kudos
Message 25 of 36
(3,726 Views)

Hi Puspa,

 

What are your "sample rate" and "number of samples" values wiring into your DAQmx Timing VI?  If you are doing some sort of math to calculate those parameters, please attach an indicator to the wire immediately before the terminal or use highlight execution to get the actual numbers.  My inclination is that we are probably not writing enough samples in your finite generation task.

 

Regards,

David R
Systems Engineer
National Instruments
0 Kudos
Message 26 of 36
(3,711 Views)

Also, what values of #s and Fs are you writing to the bundle by name block?

 

Thanks,

David R
Systems Engineer
National Instruments
0 Kudos
Message 27 of 36
(3,710 Views)

Hello David,

 

a) Sample clock rate is 1 Meg. I think it is the maximum capacity of my USB 6353.

b) Number of Sample is - 50. Sample Rate/frequency.

 

#s and Fs , Before I was writing 10K on both and now I am writing 1 Meg but it did not make any change to output.

 

My Waveform graph in Front panel shows desired output but Oscilloscope output is different.

Capture1.PNG

0 Kudos
Message 28 of 36
(3,707 Views)

Capture2.PNGIMAG0075.jpg

0 Kudos
Message 29 of 36
(3,706 Views)

Hi Puspa,

 

You are performing a finite output task and are only writing 50 samples to each channel.  Your sine pulse is also 50 samples.  Since on your second through fourth channels you are adding extra samples to your waveform but are never actually writing them to your device FIFO, you are seeing your signals cut short.  If you set the samples per channel on your timing VI to the number of samples of your sine pulse plus the maximum number of samples of silence you are writing, you should get your complete waveform.  In other words, you need to write 50 (sine pulse) + 40 (max number of 0 samples) = 90 samples on your DAQmx Timing VI.

 

As for the offset you are reporting, it looks like the positive peak of each channel is the same distance above the t=0 voltages, which leads me to think that the flatline voltages preceding it are actually nonzero voltages.  This is confirmed by the fact that the voltages they flatline at before starting the task are the same voltages as the last value written to each channel when the sine pulses get cut short.  You should see this behavior stop after changing the samples you are writing to each channel to 90.  You can also check out this KnowledgeBase article that talks a little bit more about the behavior:

 

http://digital.ni.com/public.nsf/allkb/FA35E2F2B29A75638625727E0001F3F4

 

Regards,

David R
Systems Engineer
National Instruments
0 Kudos
Message 30 of 36
(3,692 Views)