Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

square wave down convert and synchronized AI AO!

Hi Guys!
I am trying to acquire data in real time usign
PCI 6251. My code is attached. I'll be grateful if anyone can help me to modify my code or give some suggestions how to make the acquisiton in real time e.g using double buffer etc.
Thanks
AM
0 Kudos
Message 31 of 34
(1,837 Views)
AM,

Thanks for posting to the NI forums.  A couple of things:  First, the code was not attached.  Second, this sounds like a completely new issue from the last posts that you made.  Typically, we recommend that a new post is started for each issue.  This keeps the posts to a more readable length and makes them more useful to other forum users.  If you generate a new post just mention my name and I will be happy to answer your questions there.

Regards,

Neil S.
Applications Engineer
National Instruments
0 Kudos
Message 32 of 34
(1,812 Views)
 
Hi Kevin,
I have been using the code you sent me more than a year ago very successfully. Now I want to make a small change. I want to change my sampling frequency from 8kHz to 16 kHz, so I have to change the master clock from 200kHz to 400 kHz. I want to keep carrier frequency 50Khz as before. When I do this using the same code on PCI 6251 and labview 7.0. I don't get any error. The carrier frequency is perfectly 50kHz. But the received signal is not what I expect. When  I change it back to carreir freq. 50Khz, sampling frequency 8kHz and master clock to 200 kHz, it works fine again. Moreover, if I change carrier freq. to 40kHz or 25kHz and change the other parameters accordingly, everything works fine. Can you advise me on this please that how can I make it works for smapling frequency 16Khz, which is used for sampling incomming signal through PFI0. You can find the vi in this thread name  
 I tried to upload it but having some problem. But this code is there already in the thread .
Thanks
AM
 ************************ Following is what you wrote to me more than a year before***************
 
DSPGUY,
 
In the meantime, here's a really quick-and-dirty example to show you one way that can work.  I tested it on an M-series device with AO capabilities. 
 
Scheme:
1.  Generate master clock using the AO subsystem -- the AO sample clock.  I simply wrote 0V values to the output buffer b/c the actual output doesn't matter, only the sampling clock.  Note that the original default freq is 200 Hz so that UI indicators could show operation usefully, but it can also operate at 200 kHz.
 
2. Master clock is used as "Source of Ticks" for 2 counter pulsetrains.  They generate 50% duty cycle divided-down clocks that are sync'ed to the master clock.  The divide-down factors can vary independently.
 
3. Output of "clock 3" (your term from earlier in thread) is used to drive analog input.  It becomes the AI sample clock.
 
4. "Count" properties of each of the 4 tasks are continually queried in a loop so you can observe that all are functioning.
 
Try it out & see if this gets you going...
 
-Kevin P.
 

Attachment M-series 3 synced clocks.vi (161 kb)

0 Kudos
Message 33 of 34
(1,581 Views)
I had just a few minutes available to toy with this a bit.  I *think* this should be workable and I got it to run with a 6259 board, though I couldn't look at any hardware signals to verify actual behavior.
 
1. You must have done some mods beyond the posted code -- it never performs a "Read" on the analog input data.  I can only comment on what's posted, but there's a possibility that the problem is in the changes.
 
2. When I added a call to DAQmx Read, I was prone to seeing buffer overwrite errors.
 
3. I noticed that my code didn't explicitly set a buffer size.  Also, I had hard-coded a dummy value of "1" as the external sample clock rate.  So the DAQmx driver picked a buffer size automatically. Unfortunately, it would pick a pretty small buffer because I had lied about the sample rate.  When I changed that value to 16000 to represent the true new sample rate, the buffer overwrite errors stopped.
 
My successful runs used a 400 kHz master clock and "divide-down" factors of 8 and 25 -- for the 50 kHz carrier and 16 kHz sample rate respectively.  I made only 2 changes from the posted code.  (1) I added a call to DAQmx Read inside the main loop, but simply discarded the analog input data.  (2) I wired the value 16000 as the sample rate in the call to DAQmx Timing.
 
If these thoughts don't help, please post the actual code and/or describe what seems wrong about the "received" signal.
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 34 of 34
(1,569 Views)