LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing 2 sine waves

 

I'm new to Labview and NI-FGEN so things are taking a bit longer than i think they should, the problem is im trying to synchronize sine waves from 2 PXI 5421 cards.

 

what im fundamentally trying to do is have a slide bar and at one end of the bar one sig gen is at 5V and the other sig gen at 0.1V and when you slide it to the middle the amplitudes are both at 2.5v and at the other end of the scale the first siggen is at 0.1V and the second 5V.

 

i can get this bit to work but when i connect the sig gens to a scope one signal is drifting.

 

on another note if any one knows an easier way of creating the signals, I've "butchered" some examples. So there's probably loads of stuff that I don't need inthere.

0 Kudos
Message 1 of 3
(3,046 Views)

I do not have the FGEN VIs so my comments are general rather than specific.

 

1. Unless the frequencies are EXACTLY the same, the signals will drift relative to one another. There are at least two frequencies involved for each generator, (a) the user-specified signal frequency and (b) the D/A clock frequency. Your front panel has two controls for frequency. If they are set the same, then the nominal signal frequencies will be the same. It is important to be very careful with fractional numbers because of the way they are represented in binary in the computer.  The clock frequencies will be nominally the same. Many devices use quartz crystal oscillators which have a frequency tolerance of +/-100 ppm (parts per million).  While 100 ppm is a small fraction, two signals gnereated by clocks which differ by that much will drift.

 

Fixes: (a) Use only one frequency knob on the front panel and feed the value to both FGEN modules.

(b) Use the same clock for both modules. I do not know whether these devices have a connection for an external clock. If they do not, you will never get perfect synchronization. Somewhere you will need to configure subVIs to tell the modules what clock to use.

 

2. The Amplitude slider will be read only once at the beginning of your program. That value will be used throughout the run. Any changes made later will be ignored. This is due to LabVIEW's dataflow paradigm.

 

Fix: The terminal needs to be indside a loop. Better fix: Learn about the Producer/Consumer (Events) Design Pattern. This will have a parallel loop with an event structure to handle the User Interface, in particular, the changes in the slider. It will send the new values to the FGEN loops via queues.

 

3. Same as 2 for Frequency. 

 

Lynn

Message 2 of 3
(3,033 Views)

Two things:

 

When you want your signal frequencies to be the same, use only one signal generator and split off the signal to both channels, as Lynn said. Only run two independent signal generators when the signal frequencies have to be manipulated independently.

 

Your amplitude control is not symmetric around 2.5V. On one side, you can go down only 2.4V, on the other you can go up 2.5V. If you want things to meet in the middle at precisely 2.5V, you'll have to take care of this (such as letting the amplitude go down to 0V and up to 5V).

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 3 of 3
(3,028 Views)