Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate repeating analog signal + synced TTL

Hi,

 

I'm using labview 2013 and USB-6343.

 

I have two question:

1) I'm trying to generate an analog triangular signal and use the card's internal clock to run it. Sometime I might need the triangular signal to repeat once and other times it might be a 1000. If I use the Voltage - finite output example then I need to generate the entire output array. Depanding on how many times I need to repeat the triangular pattern the output array can get pretty large. Is there a way to generate the output array once (for one repeatition) but run at continously for i amount of repitions ?  

 

2) I need to generate a TTL with twice the frequency of the triangular wave + some constant phase shift. It is very important that the TTL and the triangular wave are perfectly synchronized. I tried using the Counter - finite output example together with the Voltage - finite output. I put the start task for both the TTL and analog output in the same case structure. I think I have an unwanted phase shift between the signals. What is the best way to sync the TTL and the analog signal?

 

Thank you,

Eyal

0 Kudos
Message 1 of 8
(5,192 Views)

1.  Yes, generate one period of the output signal.  You can specify whatever number of samples you like when you configure the timing for your task.  If you configure a finite task with N times the number of samples in your waveform you will get N periods of output.  So for example, if you write a single period of triangle wave and it is 1000 samples long, if you configure a finite output task that is 9000 samples, you will get 9 periods of the triangle wave.

 

.  Example1.png

 

2.  You could either generate your TTL signal using a clocked digital output or using a counter output:

 

For the digital output, you would build an array of digital values to be clocked out.  If you use the AI sample clock as the sample clock for your digital output task, you wouldn't really need any additional synchronization (just make sure to start the digital output task before the analog output task).  You would implement the phase shift by modifying the output waveform.

 

For counter output, you simply tell the counter at what frequency and duty cycle to generate.  However, to synchronize the tasks together you must share a start trigger (I'd suggest using the AO Start Trigger signal as the start trigger for the counter).  To implement the phase shift, configure the Initial Delay property.

 

I'd go with the counter output myself assuming you don't need the counters for anything else (your device has 4 counters).  If using digital output makes more sense to you, you can use this instead.

 

 

Best Regards,

John Passiak
Message 2 of 8
(5,185 Views)

Thanks John! That is exactly what I needed.

 

I have a follow up question about the trigger. I was experementing with the trigger earlier today - I used a start digital edge trigger for the AO signal and used the counter output as the trigger. That seemed to work okay although I didn't test it extensively. What are your thoughts about that?

 

Thank again,

Eyal 

0 Kudos
Message 3 of 8
(5,180 Views)

You could use the counter output to trigger the AO.  To incorporate a phase shift you would have to manipulate the data you are writing to the AO task (since the AO subsystem doesn't have an initial delay property like the counter output does).  You would end up with a discontinuity at the beginning of your output (assuming it is at 0v at t=0).

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 8
(5,170 Views)

Hi John,

 

Thanks for your previous suggestions. It worked well until I added an additional AO channel. 

 

I need to generate a raster pattern. One channel scans in a triangular pattern and the other is a step function (see attached image). It seems like I have to generate a 2D array for this purpose and run both channel using one AO task. Therefore, I cannot use the trick of generating a pattern once and repeating it. The sample clock runs at 100 kHz so if I scan for 30 seconds the 2D array for the AO is huge and I run out of memory. 

 

If I could separate the channels then I could repeat running the AO1 pattern with the trick you thought me above. The second channel can run off a much slower clock since its value changes much less frequently. But when I combine both channels in one task I can't reduce the size of either one of them. Any suggestions?

 

I attached an image of my code.

 

Thank you,

Eyal

Download All
0 Kudos
Message 5 of 8
(5,078 Views)

Indeed, you do have to run both AO channels in the same task.  The output channels share a timing engine so you can't clock them out at independent rates.

 

100 kHz * 30 seconds * 2 bytes per sample * 2 channels is only 12 MB of data, you should be able to generate this without running out of memory (even if you build the waveform using 8 byte doubles, 48 MB isn't all that much).

 

If memory is an issue, you can instead dynamically generate the output in smaller windows (increments corresponding to 1 period of AO1 seems convenient enough) and continuously write new data to the output task using "non-regeneration" mode.

 

 

Best Regards,

John Passiak
0 Kudos
Message 6 of 8
(5,065 Views)

Yes. You are correct about the size of the data. Labview was complaining that I ran out of memory but at some put I realized that the data is not that large and I restarted labview and it worked fine.

 

Thanks for the help!

0 Kudos
Message 7 of 8
(5,061 Views)

Hi, I am using NI6361. I am transmitting 60 kHz signal with finite samples through AO. And receiving it through AI. My problem is, i would like to repeat it frequently like: i should send 60 kHz of one period and receive it the same time. Then again and again after 5 seconds, it should repeat the same till i stop. Can anyone help me in that case? Thank you in advance.

0 Kudos
Message 8 of 8
(3,105 Views)