Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

synchronous demodulation

Hello to all.


I´m facing a key problem with my research now. I need to make synchronous demodulation. Qute simple, isn´t it? Let me explain, I have external generator of, let´s say 1kHz signal, using for modulation of laser signal. From photodiode I have analog signal, with output volage dependent on laser wavelength. And now here goes the problem, I need to acquire the generator signal and also the output signal from diode. and create synchronous demodulation. I tried to simply acquire signal from NI card, but unfortunately due to latency between sampling-conversion the signal is time shifted. My problem can be imagined, that I need to create something like your osciloscope does, when you use as input signal a sinus wave for instance, and you have always the zero point at the begining of the screen. 


I add the sample code I use for acquiring of data. The signal generator is included. LV 2011


Could someone help me with that? Which NI card/platform to use? Or is there any mistake with the code?


Thanx, Jan

0 Kudos
Message 1 of 9

Hi Aiken,


am I right that your problem is only phase shift? If you need to acquire two signals without phase shift you need hardware with simultaneous sampling (S series). You can also manually shift one signal to make them synchronous but it is not a good solution. I would also like to suggest you some improvements
1. Merge DAQmx Start output error cluster on AI side and DAQmx Write and pass the result to DAQmx Start on AO side.
2. Double timing is not necessary and Wait (ms) function does not need to be in a Flat Sequence Structure because it is started after iteration finishes.
3. Try to look at Wait Until Next ms Multiple VI. Usually it is better.
4. Splitting of an error cluster inside while loop is not a good practise. Use only one.
5. What HW do you use? Because HW with multiplexed AI is not an appropriate solution for you.

If you have another question please post it with explanation what is your issue.



0 Kudos
Message 2 of 9



The data is still synchronous in the sense that the samples have a fixed and known time relationship. You should be able to compensate for the small phase shift which occurs between the sample on one channel and the sample on the next channel. Depending on exactly what you are doing with the data no compensation may be required.


The basic theory of synchronous demodulation is based on the multiplication of two sine waves.  If the frequency is the same, one component of the product of the two signals is the cosine of the phase difference.  By doing an inphase and quadrature measurement you can get amplitude and phase information regardless of any (fixed) phase difference between the signals.


I notice that your only measures one channel.  By changing the Read to NChan NSamp you can record both the excitation signal and the photodoide signal.  It might be good to record an attenuated version of the raw laser signal so that you can determine how much delay or phase shift might be occurring in the modulator and any driver circuits.


To test the interchannel delay on your DAQ device, simply feed the same signal to all the channels.



0 Kudos
Message 3 of 9

HI Aiken,


as johnsold told you needed to measure both signals. I suppose that you are using generated sinusoide (which is passed to the hardware) and measured values from AI. Of course, there is some delay. So you should measure both signals. As mentioned in previous posts there is some delay between channels if you are using card with multiplexed analog inputs. You can calculate the delay between channels from specifications manual according to the sampling rate and numbers of channels used (if you are using card with multiplexed 250 kSa/s speed and 2 channels, the delay between samples is 4 us).



0 Kudos
Message 4 of 9

Hi Martin


Thank you for your intel. It is correct that my problem is phase shift, but not only. As the main goal is to be able to synchronize two signals up to their zero passing.

Also thanks for code corrections but I have some questions

1) how it wil efect the code?


3)instead of Wat(ms)? what is the difference?

4)but as best I need to paralellize those processes

5)unfortunatelly X series, so that is the main problem


thank you, Jan

0 Kudos
Message 5 of 9

Hi Lynn


 Yes, you´re right. This program acquires only one signal, but that gives me information about unsynchronized acquiring. I was acquiring only one signal asumming that acquired signal will be shown as on osciloscope synchronized with rising edge, but it is not. sine wave on the screen is oscilating and phase shifting.


Thank you, Jan


0 Kudos
Message 6 of 9

Hi Martin


Thank you for comment, the main problem is that inapropriate hardware.


0 Kudos
Message 7 of 9



Some AI devices are capable of analog triggering.  If your signal is noisy or too small, the triggering might not be sufficiently reliable.  On the other hand, to do synchronous demodulation, you need to have the reference signal and that must be clean enough for good triggering.



0 Kudos
Message 8 of 9



As was discussed, I use signal generated by card so I suppose it is strong enough



0 Kudos
Message 9 of 9