LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronizing AnalogInput on PXIe-4302 with a AnalogOutput on USB-6221

Dear all,

I am working with a USB-6221 sending square-wave on a light source. The signal is one pulse every second (1000 samples per pulse, so sample rate is 1kHz). Let's say the dutycycle of the squarewave is 50%.


On the other hand, i use a PXIe-4302 to acquire signal from a photodiode that is receiving the light from the source. I want to acquire the signal at same frequency (1kHz, 1000 samples every second). I want to do this because i process the waveform acquired and this processed signal is the useful signal i want to monitor over time (which is computing the standard deviation of the photodiode waveform on those 1000 samples).

 

My problem is that when i create the two tasks (1 for AnalogInput, 1 for AnalogOutput), they are not synchronized on the same clock (because not triggered and using their own OnBoardClock) and i have reasons to believe that this is causing some drift on my processed signal and some non repeatability on the experiment.

I would like the two task to run on the same 1kHz clock, so that reading photodiode signal and sending pulse on light source happen at the same time.

 

I searched online and there is many different solutions that don't work when i try to adapt them to my case. The thing is that i get lost and confused with timing, triggering, what clock i have on my devices and how should i link them together. as of now, the code i use looks like this:

 

etienne_niorthe_0-1708594272225.png

 

Any help would be greatly appreciated :),

Thank you ,

Etienne

 

0 Kudos
Message 1 of 6
(533 Views)

If you have a PXIe-4302 and a PXI X Series DAQ, it can be easily done using DSA, SC Express, and X Series Multidevice Tasks

 

Synchronizing USB-6221 and PXIe-4302 is very complex because:

1. They have different form factors (USB vs PXIe)

2. They are two different DAQs, M Series and DSA

 

You can refer to Synchronize a PXI DSA, M and S Series Card Using LabVIEW with DAQmx and the CLK10 + StartTrigger signals would need to be routed and wired externally via PFI ports.

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 6
(481 Views)

Hello ZYOng, thank for your reply.
Indeed what i thought about was pulling a wire from the USB-6221 to the PXIe-4302, so i could trigger the AnalogRead using the pulse signals received on the analog input.

But i don't see PFI lines input on my PXI device, only analog input.

Could i create another AnalogInput task just to read the pulse signal from USB and use this signal to trigger the reading of the photodiode ?

 

 

0 Kudos
Message 3 of 6
(457 Views)

There is a PFI0 on Pin A5 that you can use to receive an external trigger.

-------------------------------------------------------
Control Lead | Intelline Inc
Message 4 of 6
(440 Views)

This will be very challenging to accomplish with the hardware stated. With just using the trigger to effectively start the acquisition, you are still going to see drift over time. The longer the acquisition runs, the further and further out of sync your two devices are going to become. You really need to utilize some form of clock synchronization. If you have a timing card available to you, you'd be able to accomplish the synchronization you need.  If you do not have a timing card, you can try exporting the 10MHz clock of the USB-6221 to a PFI line. Connect this signal to your PXIe chassis 10MHz reference in connector (would need to know your chassis and would also be beneficial to know if you have an embedded controller you are using). Connecting this way, should provide clock synchronization to some degree and minimize any drift over time. The last thing, which sounds like you are already planning for, export the start trigger of your AO task through another PFI line on the USB device and connect to the PFI line of the 4302 (If you are using a TB-4302, the terminals are labeled PFI0 and DGND on the J18 terminal block). Once signals are all connected and exported (check the export signals vi's in the DAQmx API) appropriately, you just need to make sure you use the Configure Trigger.vi for the AO and AI task. You want the AO task to use the NONE instance and AI task to use the digital edge start trigger instance. You then will start the AI task first then start the AO task.

 

If you do have a timing card available to you, the operations are similar but you would use the NI SYNC API to perform a few additional steps. I would recommend exporting the SAMPLE CLOCK of the 4302 device to the backplane, out of the timing card and into the USB-6221. I would also recommend making the 4302 device be that start trigger source and routing that to the USB module and reversing some of the operations above. This would ensure the higher level of synchronization and ensure no drift over time.  

 

One last thing to mention, the DSA device has some inherent delay built into it due to the way the data is sampled. Read through the manuals Filter Group Delay section to understand what is going to happen and how you can account for this when analyzing the data. IF what you are concerned with is the width of your signal, then this should not really affect you. If you attempt to overlay these signals in time, you would see that the DSA device is responding later in time than you'd expect, this is the group delay. If you wanted to eliminate dealing with group delay, you could migrate to an X-Series or S-Series card. These two card types are also inherently easier to synchronize.

Message 5 of 6
(392 Views)

As already stated, the two units need a synchronisation in hardware

 

one way:

The 4302 has 32 channels, do you use them all? (Answer no, only one channel configured)

A simple synchronisation would be to splitt the pulse signal and feed it (maybe with some input scaling attenuator) to a free (second) channel of the 4302 and read all (both).  Increase the samplerate to 5kSPS , do a contious aquisition (producer-consumer). The signal analysis sligthly increase, but nothing a modern PC couldn't handle at (only) 160kSPS max. (10kSPS in a two channel case)

Why go up to 5kHz?  I don't know your timing constrains , but since your USB source is free running (not in sync with the PXI system) your pulses will drift with longer measurement duration and with the higher samplerate and a known pulse shape you can fit the pulse and can get even subsample timing accuracy to cut out a single pulse event.

 

Other way:

If only a simple pulse is needed and the repetition time only needs  a coarse timimg:  Configure the 4302 to read 1k (or 5k or ?) sample and use the reference trigger out on PFI0 to pulse your ligth source. (I don't know if the DAQmx allow to set arbitary pulse length in the range you need) , After you read one record , you can start the next one, which will need some time (xx ns or µs)

 

To set other pulse lengths by software, you can use one timer of the 6221 (if there is no spare timer in the PXI system). Feed the reference trigger via PFI0 to one of the 6221 timer inputs . should give you 12.5 ns resolution.. (or less, for a 500ms pulse you maybe need to use the 20MHz clock , so 'only' 50ns timing accuracy)

 

If you need help to configure the hardware ask here. 

 

I would go the first way.  If you are willing to post your vi and explain your idea of signal processing (by looking at the block diagram picture, I have the impression there migth be better ways 😉 )  AND add some data in the diagram (capture 3-4 seconds, stopp the vi, do EDIT:Make Current Values Default , Save the vi) help will be much easyer.

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 6 of 6
(360 Views)