Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating 4 analog output waveforms with different frequencies

Solved!
Go to solution

Hi John,

                    1. Today i met  our NI field engineer as part of tech support but could not find a proper solution for acquiring CCD pulse and converting  into a toggle digital DO pulse. So i decided that this approach wont work for me. 

 

2. I have looked at your vi which generates multiple DO pulses with control over pulse width , to generate two digital pulses with different frequencies.  I get error -200292. The error image is attached. This error occures at writing digital array.

 

Could you tell me what was wrong with the code? i just downloaded from decibel.ni.com which was written by you. 

 

3. Does it possible to run multiple DO.vi along with multiple AO.vi waveforms in sync? ( i.e. I would like to implement AO vi as a aub vi in DO vi) Thanks very much for your help.

0 Kudos
Message 31 of 65
(4,107 Views)

Hi viswa,

 

Sorry for the delay--I've been out of the office for the Holidays (Thanksgiving here in the US).  It sounds like TTL voltages are acceptable on the output, so I would use an Externally-timed Digital Output example to get started (output the pattern [H L] repeatedly so the signal will alternate between high and low on each clock edge).

 

If the input signal is clean and drops below .8V and above 2.4V, you should be able to use this directly as the sample clock by wiring it to one of the PFI lines.

 

 

The appropriate shipping example to get started with should be:

Cont Write Dig Port Ext Clk.vi

 

(found under Help >> Find Examples... >> Hardware Input and Output >> DAQmx >> Digital Generation)

 

 

Let me know how if you have any questions about it.


Best Regards,

John

John Passiak
0 Kudos
Message 32 of 65
(4,074 Views)

Hi viswa,

 

Just noticed your second post

 

1.  You might be able to configure an analog trigger and use the analog comparison event to generate the sample clock based off of your ccd pulse (see M Series User Manual for diagram of Analog Comparison Event)

 

2.  The error you are getting means that space is not becomming available quickly enough in the output buffer (by default the DAQmx Write function has a 10 second timeout).  What are you using as your sample clock source for the DO task?  If you were not providing a TTL clock signal to your task then this would explain the timeout.

 

3.  It is indeed possible to synchronize DO and AO tasks--the easiest way to do this is to simply use the AO sample clock for your DO task.  If doing this, make sure to start the digital task before the analog task to ensure both tasks start simultaneously (off of the first sample clock of AO).

John Passiak
0 Kudos
Message 33 of 65
(4,069 Views)

Hi John,

                  Thanks for your informative reply.

 

1. I am using Ctr0internaloutput as the source for DO task and multiple digital lines. I used integer multiple clcok rate to the desired frequency as you mentioned in the vi code.   I tried number of samples as 1/8 of clock rate and even tried lower and higher clock rates. But could not over come error-200292. I have atatched the code with default values here. 

 

2. I guess with Ctr0internaloutput as clock source DAQ board could generate multiple digital pulses with desired frequency and duty cycle and also mulitplte AO waveforms in synchronisation. This will make my life simple and easy, can certainly address everything what i need. But frustrated with this error-200292.  

 

 

 

 

Message Edited by viswa on 11-30-2009 11:36 AM
0 Kudos
Message 34 of 65
(4,063 Views)
Do i have to connect ctr output physically on the board to digital out put task? i guess ctr0internaloutput means it is given from the board itself, am i right?
Message Edited by viswa on 11-30-2009 11:54 AM
0 Kudos
Message 35 of 65
(4,055 Views)

Hi viswa,

 

The code doesn't set up the counter output task, so even though you are using the Ctr0 Internal Output it doesn't sound like there is any signal present on the line.  You would have to run a continuous pulse generation example on counter 0 concurrently with the digital task to provide the clock.

 

You can also use the AO sample clock as the sample clock source--if you're trying to sync AO and DO then using the AO sample clock might be the best bet.

 

 

-John

 

John Passiak
Message 36 of 65
(4,052 Views)

Hi John,

                     Thanks very much, now the programme works. I did generate continuous ctro internal output usin gexample vi for continuous ctr generation vi concurrently with DO vi. I want to give these pulses to CCD, so if i use generation of DO only (with out using PWM vi) i am afriad that i could not control pulse width precisely, is that true??

 

If there is any other way to generate DO with precise pulse width then that could make code pretty simple for whatever i want to do, but i remeber that you were saying about generating DO with precise pulse width is the trickiest part. 

 

I really appreciate your invaluable help!!!

Message Edited by viswa on 11-30-2009 01:02 PM
0 Kudos
Message 37 of 65
(4,050 Views)

It's true that generating the DO with the precise pulse width is the trickiest part, but the example program is meant to take care of that for you. 

 

If everything is working properly there might be no need to modify the way you are doing things, but the CTR Internal Out can simply be changed to AO Sample Clock if you want to base your DO off of the AO task.  You would need to tell the task what rate the AO Sample clock is running so it will build the correct waveform for you.

 

-John

John Passiak
0 Kudos
Message 38 of 65
(4,044 Views)

Hi John,

               Finally i almost got all the waveforms needed for my application, but a little problem with triggering all the waveforms at once with an external trigger. Please refer to the attached vi which was modified for my need.

 

The routene generates 3 analog waveforms and 3 digital waveforms at sampling clock rate 250000S/s nd 20000 samples.

 

Analog output clock has been given as clock source for both AO and DO as you suggested and it works. The only thing i tried to do was trigeering all of the waveforms at once using an external digital clock from PFI0 which was originally generated by a counter at frequency 250000 Hz and 0.5 duty cycle.

 

I executed the vi and looked at two waveforms on oscilloscope. The first (Top) waveform is digital waveform which has 50Hz frequency and 2% duty cycle  which can be fed to CCD. The second (bottom)one is analog square waveform of frequency 25Hz. These waveforms were never generated at the same instant even though externally triggered.

 

Could you find any reason? I might be going wrong in triggering the signals. 

 

I will mark this thread as solution accepted soon....Thanks a lot for your constant support all the way until now!!!! I am sure this thread will be very valuable for interested forum members.

 

 

0 Kudos
Message 39 of 65
(4,016 Views)
Solution
Accepted by viswa

Hi viswa,

 

Glad to hear that we are close to wrapping this one up (hopefully others can find this thread useful as well).  I can spot two things you will need to do to fix the code to effectively synchronize the two tasks:

1.  You should remove the Trigger from the Digital Output task.

Since the Digital subsystems don't have any timing or triggering circuitry on M Series boards, you can't actually configure a trigger directly for the digital task on your USB-6229.  This configuration should return an error but you don't have the error out connected so are likely not seeing any warning.

 

2.  The digital task should be started before the analog task in software.  Right now they are started in parallel so there is no guarantee which thread will execute first.

Since we can't trigger the digital task directly, we will instead begin on the first sample of the AO task (which is triggered by the external signal).  To guarantee that this happens, the digital task must be started before the AO task in software so it is ready for the first sample clock edge when it comes.

 

You should be able to put both tasks into the same while loop to make it easier to control which starts first.  Make sure to keep the #s and Fs parameters for each waveform the same to ensure that neither of the tasks underflow...

I noticed that you are using the "SampleClk.Rate" property for the frequency of the analog task but the user input "Sample Clock Rate" for the digital.  At frequencies that evenly divide down from 20 MHz this will be OK, but if you try to specify a frequency that is coerced the analog and digital data will be generated with different sample clock rates in mind (the result will be a digital waveform that is a different frequency than desired). 
 I would use the output of the property node for both waveforms to be on the safe side.

 

Following the above two steps should take care of the synchronization problems--if you have any problems implementing them or run into any other issues please don't hesitate to let us know!

 

-John

John Passiak
0 Kudos
Message 40 of 65
(4,012 Views)