Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

transforming counter output to analog output

Hi to all forum members!

I need to produce a very stable square wave with adjustable frequency (1-50 Hz), duty cycle and amplitude (0-5 V).
For stability reasons I would like to use to counter output of my device (NI 6036E).

The question is the following: how can I transform the TTL pulse train produced by the counter in an analog output with adjustable amplitude?

I tried to re-acquire the counter square wave as "analog input" and then, after suitable rescaling, to send it an "analog output" channel, and for this purpose I changed some Labview given Examples. The tentative vi is attached (Labview 7.0).

In this vi I have many many triggering and timing problems:
1) I look at the acquired input signal with a chart: is the square wave in the chart at the same frequency and duty cycle as the counter square wave?
I know the frequency of the acquired wave depends on the buffer size and sampling rate, but HOW?
In other words: which numbers have I to write in the "analog input timing parameters" box on the front panel?
Is really the sampling rate the same as the wave frequency, as written in the LV example I changed?

2) If I look at both the analog input chart and at the chart  that represents the waveform to be sent to the analog output  I can see an agreement, but what really happens is terrible:
with the counter wave at 40 Hz, in the analog output channel I can see an extremely instable signal, composed by 3 or 4 wave periods at about 1 KHz, followed by a long continuous high or low state, then some other  wave periods at  high frequency, etc.....

Could anybody, please, help me?

Thank you in advance
ely


0 Kudos
Message 1 of 2
(2,937 Views)
Hi ely,
I read your post and I would like to help you with some practical suggestion..
A) I saw your code and the first suggestion I can give you is to link the tasks' DAQmx vis together connecting the error terminals. It will confer a proper tasks timing and synchronization. The way to link them together is starting from the DAQmx Create Channel and including all the following DAQmx tasks' configuration vis (Timing, Read or Write vis) till the DAQmx Start Task vi (excluded). You should start from the task you expect your signal generation start from (the counter output, in your case). Linkling process should follow till the last task to start (in time). This last task should be the first to connect to the DAQmx Start Task vi. From here link sequentially the others tasks' DAQmx Start Task vis.
Error line can be split before entering the While Loop.
At the end of this process, your tasks' vis should appear bundled in snake shape way 😉
 
This process ensures you that the counter analog input signal acquisition starts when exactly the input signal is present on your line. At the same time it ensures that analog output is submitted after your counter square wave was rescaled.
 
 
B) The output waveform frequency depends on the update rate and the number of cycles of the waveform present in the buffer. The formula for calculating the frequency of the output signal is as follow:
 
signal frequency = [(cycles) x (update rate)] / (points in the buffer)
 
You can find a vi (Waveform Buffer Generation (multi).vi) that implements this operation in the block diagram of the following example: "Cont Gen Voltage Wfm-Ext Clk-Dig Start.vi" [NI Example Finder»Hardware Input and Output»DAQmx»Analog Generation»Voltage]
 
I really suggest you to try to modify your code taking advantage of the small suggestions I'm giving you here.
Starting from this point we can try to go on and answer, if still necessary, to the others questions you posted.
 
I hope it can help you. Let me know.
0 Kudos
Message 2 of 2
(2,881 Views)