Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

square wave down convert and synchronized AI AO!

Hi,
First  I want to generate a square wave at 200khz then  to down convert it to 50 kHz square wave and then send it out i.e Analog output. At the same time  I want to sample the analog signal i.e Analog input at let us say frequency=200KHz/N; where N is a number e.g. 10. In other words my sampling frequency for analog input is 20khz .,which is FM modulated signal.  I want 200khz square wave in sync with 50 khz (down converted) square wave as well as sampling frequency for analog input.
I'll be thankful  for help in this regard. If you have a vi written for traditional DAQ or DAQmx . Please send it to me.
Thanks
AM 
0 Kudos
Message 1 of 34
(7,006 Views)
Hi AM,

In your post you stated that you are wanting to generate 2 separate square wave signals and then sample an analog input channel.

You may want to just take a look at one of the examples for digital output.  If you are using LabVIEW 7.1 then you can go to Help > Find Examples > Browse > Hardware Input and Output > DAQmx > Analog Generation > Voltage > Cont Gen Voltage Waveform.vi  If you look at this example you will see how it generates a particular waveform.  You simply need to do this for two channels, so you could build the data into 1 Y array of 200 kHz data and 1 Y array of 50 kHz data, then merge those arrays and write them to the DAQmx Write.vi

Secondly you want to synchronize your measurements with an analog input.  There are some great examples for doing that too.
Help > Find Examples > Browse > Hardware Input and Output > DAQmx > Synchronization > Mulit-Function > Multi-Function Synch AI-AO.vi
Once you get the first part done, it should be almost identical to merge that application with this example.  Basically you just make sure to share the clock and the tasks will happen at the same time.

Unfortunately I don't have an example already written that does everything you want, but without too much effort you could create the system you desire with the above starting point.

Regards,
0 Kudos
Message 2 of 34
(6,945 Views)

Hi otis,

I think I did not frame my question properly. Let me put it like this.

I want to generate a  clock at 200 Khz using NI card e.g. PCI 6120. Then I want to count down this 200 KHZ Clock to 50KHZ ,  while making sure  it is in sync. By sync I mean rising edge of 50KHZ must concide every 4th rising edge of 200KHZ  and same for trailing edge. Now I want to send this signal out of my card to a signal generator(Analog Device ) into its syn input and generate a analog 50 KHZ  signal from my signal generator , which in other words is in syn with 50 KHZ signal from the card.   Now this ouput from signal generator goes through some other stuff and we have now  FM signal with carrier 50 KHZ and now I want to feed this FM signal to NI card and sample it at e.g 20KHZ but I want to make sure incoming signal to the card and outgoing signal are in sync.

I need your valueable suggestions or help in this regard. Like if you have some code you think be helpful , could you please send it to me.

I hope this time my question is clear.

Thank

AM

 

 

0 Kudos
Message 3 of 34
(6,928 Views)
If you know digital hardware, a standalone divide by 4 circuit is a quick and simple solution  for the 200Khz to 50Khz down-conversion.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 4 of 34
(6,918 Views)
Hi AM,

One other way that you could do the same task without extra external hardware is that you could use one of the counters and create a task on that counter that makes it base it's measurements off of the number of ticks from another source.  Attached is a file that should show you how to do this.  Essentially if you use a task that outputs a 200 kHz signal then you will input that signal as the source for the other operation that will downsample the number of ticks. 

In this case if you have a 200 kHz signal and you want to divide it down by 4, then you might want to say that the 2nd counter task is low for 2 ticks and high for 2 ticks.  This will have actual hardware timing too, so it should work just fine for your purposes. 

I hope this helps you,
0 Kudos
Message 5 of 34
(6,890 Views)

Hi Otis,

Thanks for your prompt reply. I 've just scanned this VI  and it looks helpful. But I also want to see the outgoing signal i.e. 50KHZ  on graph. I find it  hard in these magic VI's to connect graph since it works in task in task out fashion. Regarding your suggestion that  I don't need to have external source. If I can make 50KHZ pure sine wave which looks like it is obtained from signal generator using PCI 6120, then it's even better. But I am bit skeptical about generation of 50 KHZ signal  using card .  The other thing I could  not see appearnt  in the  VI is simulataneous  clock  for  AI and AO and also 200 KHZ and 50KHZ having same clock. I hope you understand what I intend to say.

I'll be thankful for your reply.

AM

0 Kudos
Message 6 of 34
(6,884 Views)
Hi AM,

I am a little unclear about some of the things that you were trying to say in your last post, but I will do what I can.
  • I find it  hard in these magic VI's to connect graph since it works in task in task out fashion
I'm not sure what you mean by this.  To view a graph all you have to do is wire the input data to it and that data will be displayed on the front panel.
  • If I can make 50KHZ pure sine wave
The solution I gave you above was to create a 50 kHz Pulse Train.  If you want a 50 kHz sine wave, then you could make one quite easily by taking a look at the example (Help > Find Examples > Browse > Hardware Input and Output > DAQmx > Analog Generation > Voltage) Cont Gen Voltage Wfm-Int Clk.vi.  Keep in mind that you will need to generate at least 10 points per sine wave to generate something that actually looks like a sign wave.
  • The other thing I could  not see appearnt  in the  VI is simulataneous  clock  for  AI and AO
If you want to synchronize various tasks then you will need to use the same clocks.  In the case of the 200 kHz clock and 50 kHz clock, you know those are in sync since they are based off of one another.  About the analog task, if you want to synchronize the starting of that with your signal, then you should make all of the tasks work with a start trigger or something to make sure that everything is starting at the same moment.  For more information you might want to take a look at the Synchronization (Help > Find Examples > Browse > Hardware Input and Output > DAQmx > Synchronization > Multi-Function) examples.

I hope this extra information helps you,


0 Kudos
Message 7 of 34
(6,870 Views)

Hi Otis,

Let me reframe my question. You sent me a VI which generates two pulse trains  one at 200 KHZ and other at 50 KHZ from the same base. Now I want t o see them on graph. But how? If there is  any data output  I can put a graph indicattor and see it but here we have task in and task out in  DAQmx sub vis.

The next thing I want to do is to write 50 KHZ pulse train at Analog Output . Since I wanna use it to get a synchronized singal from my signal generator  like we use TTL .

I'll be glad if you could let me know how can I see these two  pulses train on the screen first and then write one of them i.e. 50 KHz on AO.

Thnaks

AM

 

0 Kudos
Message 8 of 34
(6,857 Views)

Hi AM,

When you generate pulse trains you are simply setting the characteristics that you want a pulse train generator to have.  Unfortunately that means that you don't actually write a waveform that you can see directly.  However, if you wanted really wanted to see what you just generated then you could always wire the signal into one of your analog input lines. 

You also said that you wanted to generate an pulse train with the analog output line.  While you could do this, I would still recommend doing that with the counter.  However, a workaround would be to use the 200kHz pulse train you are generating as an external clock for the analog output operation, then write an array of [0,0,5,5].  You will then get an analog signal that looks like a 50 kHz pulse train. 

If you want to read the signal coming from your analog output lines, then take a look at this KnowledgeBase:
Read the Value of Analog Output Channels

Keep in mind that if you want to see these signals you will need to sample at a rate at least twice that of the highest frequency you are trying to measure.

Regards,

0 Kudos
Message 9 of 34
(6,843 Views)

Hi Otis,

I have a couple of  questions regarding the Vi  DownSample Counter” you sent me. I have hooked the output of counter output through ctr0 OUT on National Instrument BNC- 2110 to the oscilloscope and I can see the output of whatever frequency I give it. On counter output I chose Dev1/ctr0. Since on BNC-2110  I have only ctr0 out.

Now I want to see the frequency of the downsample output on the oscilloscope using the same arrangement like through BNC-2110 and PCI- 6251. Could you please advise me how to set the parameters in Counter output, downsample counter output and source of down sample ticks? Please keep in mind I don’t have ctr1 on my BNC-2110. Can I see these two out puts separately i.e. counter output before dowsampling and after downsampling?

The 2nd part of my question is regarding data acquisition. Now I want to acquire data using clock that is in sync with Downsample counter output. Like we do in case of Multi-Function Synch AI-AO.vi but I want to make use of this downsample counter.

Actually I am trying to implement the “Sampling of Bandpass signals” for I & Q signal generation .

 

0 Kudos
Message 10 of 34
(6,662 Views)