LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronization of Measurement Instruments with Waveform Generator

To all,

 

I am relatively new to LABVIEW and thus would really appreciate your assistance/patience. 

 

I am trying to synchronize several different instruments (Force Sensor/High Speed Cameras) to start and record data at the same time. I want to accomplish this goal by using the waveform generator to send a square wave at the sampling rate (ex. 15,000 HZ) to each device and record data (voltage/take a picture) for each wave. I also need to "start" the machine that runs the test.

 

I currently am using a single square wave pulse to start the cameras and intialize the force sensor/machine. A square wave pulse gets sent into the camera, the camera starts, the DAQ clears the task and then force sensor/machine are intialized. This creates a delay between the camera, force sensor and machine and thus makes analyzing the data difficulty. This is the part of the code that I would like to change so that I am continuously sending in the square wave pulse.

 

I have attached two overlapping screenshots that shows my current labview program.

 

Any help that you could provide would be greatly appreciated.

 

 

Thanks

 

gcass

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

rightside.jpg

0 Kudos
Message 1 of 45
(4,330 Views)

Hello gcass,

 

Can you tell me what DAQ device you are using so I can get a better idea of your setup? I assume you are using separate DAQ cards to read the force sensor and cameras. Instead of generating a squarewave and then outputting that signal, it may be more efficient to use the internal clocks and counters on the DAQ devices that you are using. 

 

Refer to this article for a summary of the various ways to sync up devices:

http://zone.ni.com/devzone/cda/tut/p/id/4322 (there are examples available for download at the end of this article)

 

Basically, you want to use the DAQmx Trigger.vi to make sure the different instruments start at the same time, and then use the DAQmx Timing.vi to make sure the instruments use the same clock in order to be synchronized. 

 

-Nathan H. 

Software Developer
National Instruments
0 Kudos
Message 2 of 45
(4,307 Views)

I am using a  DAQ USBX-6341 board.

I have the force sensor hooked up into the analog in channel/port 1.

I have the digitial pulse generator hooked up into the analog in channel/port 4.

I have the cameras hooked up into the digital p0.0 channel/port.

I have the testing machine connected via COM5.

 

Currently, I am not using a digital pulse generator. I am sending in a trigger to the camera to start taking photos. This trigger takes 2 miliseconds and then the labview program tells the forcesensor and testing machine to start. This creates a delay between the camera, force sensor and testing machine. THis makes it difficult to analyze data.

 

I want the testing machine, cameras, and force sensor to start taking pictures at the same time. I was told that the best way to do this would be to send in a square wave at my desired sampling rate (ex. 15,000) into the DAQ. This would synchronize everything so that it started capturing data at the same time once a trigger was sent in.

 

Is this the easiest way to accomplish that goal? I will read the link provided (Thanks!!!), but I would like some more general input. I just want a reliable method.

 

Thanks

 

gcass

 

0 Kudos
Message 3 of 45
(4,302 Views)

Hello gcass,

 

To achieve true synchronization, the analog inputs and digital inputs need to be on the same timebase. The way you are doing it now should achieve this (in principle) if you are setting your timing for all DAQmx tasks to be based off of the square wave. The main thing you need to remember is to use the DAQmx Timing.vi to select what you are basing the sampling on. Another way to do this is to just share an internal clock. You can use the AI/sampleclock as the timebase for both the analog and digital input.

 

To open an example showing how this can be done go to help>find examples. When the example finder opens, select the "Hardware Input and Output" folder, then select the "DAQmx" folder, then "Synchronization", then "Multi-Function", and finally open up the VI called "Multi-Function-Synch AI-Read Dig Chan.vi". This will sync up the digital analog input channels (Note: To select multiple channels for either analog or digital, go into the block diagram and change the DAQmx read.vi to read NChan instead of 1Chan).

 

If you would like to continue using your current method, you can try telling the machine and the force sensor to also be based on this same trigger that starts the camera, and then make sure that all the synchronized processes are using the same square wave as the timing source. Also, if it is a constant delay of 2 milliseconds, you could try starting the force sensor and test machine 2 milliseconds earlier.

 

I hope this helps.

 

-Nathan H 

 

 

Software Developer
National Instruments
0 Kudos
Message 4 of 45
(4,286 Views)
0 Kudos
Message 5 of 45
(4,267 Views)

Above is my newly designed code.

 

I am using the example Multi-Function-Synch AI-AO-Ext Dig Trigger.vi  as a starting point. 

 

I have a digital output (cameras), analog input (force sensor) and a VISA serial (test machine).

 

My main goal was to start them all on the same trigger signal.

 

I am still having issues regarding a trigger signal.

 

I was  told that I could accomplish this via using a counter output to generate a digital trigger on command.

 

I built a 1 ms, 1 pulse output via a counter output. I tried to use this a trigger source in my code but the data types were incompatable.

 

I think that my code (see attachment/pictures above) are synchronized, but I cant figure out my "trigger source." Can i the digital trigger made from the counter output as my trigger? 

 

I also have a digital pulse generator (see posts above) that I could use. If i were going to use that, how would I? Since I only want to send one pulse to trigger everything to begin at the same time, wouldn't it be excessive to use this pulse generator? I also have an oscilloscope that I could use.

 

Any help on this matter would be great. Thanks so much for your help already.

 

 

0 Kudos
Message 6 of 45
(4,252 Views)

Hello gcass,

 

Using a counter pulse to sync up your inputs is great approach. To do this, first open up "Gen Dig Pulse Train-Continuous.vi" from the Example Finder. Select counter 1 for your counter (ctr1). Before running this VI, connect the output of this counter (pin 91, or PFI 13 for the USB-6341) to the clock source of counter 0 (pin 83 or PFI 9). This is actually the Gate of counter zero which can be used as an external clock. So you should have the counter output of counter 1 wired to the gate of counter 0 (you can use any counters, I just arbitrarily chose 0 and 1).

 

Next, open up 'Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi'. (Eventually you will combine all these functions into one VI, but for demonstration purposes, just open up the VIs separately first before trying to put all the functions in one VI). You'll notice this VI has a trigger in it as well. All the trigger does is tell the reading to start on either the rising or the falling edge of the external clock (It doesn't stop the program from going to the next step). So now you should have two VI's open: one generating a continuous pulse, and the other reading analog inputs. On the front panel of the 'Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi' select the clock source to be PFI9 (Also, select the trigger source to be PFI9). Make sure the sample rate is the same rate that you have set on the "Gen Dig Pulse Train-Continuous.vi". Now run both VIs at the same time. You should be reading analog inputs using the pulse train as your time base. Notice that if you stop the generate pulse train, your other VI stops reading. 

 

A good method to setup an overall synced up process would be to use this external clock as your timebase for all your inputs (see "Cont Read Dig Chan-Ext Clk.vi" in example finder for how to set this method up for digital signals). So start your testing by having the three VIs open ("Gen Dig Pulse Train-Continuous.vi",  'Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi', and "Cont Read Dig Chan-Ext Clk.vi") and run the read digital and analog VIs first. Then run your generate digital pulse train VI and both the analog and digital reads should be synced up on that one external timebase.

 

Finally you can combine these VIs into one super-synced VI that first starts the digital and analog read tasks, then generates the pulse train to start them at the same time and ensure they are continually synced. You may have to change the timeouts to something bigger if you end up starting either the analog or digital reads a long time before you start the pulse train.

 

I hope this helps.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 7 of 45
(4,237 Views)
That is alot to digest. I will try it out and see if it works. Lots of thanks
0 Kudos
Message 8 of 45
(4,235 Views)

Timing-Triggering Parameters.JPGGen Dig Pulse  Continuous Wiring Issue.JPG

0 Kudos
Message 9 of 45
(4,217 Views)

Hi

 

Above are two pictures of my attempt to execute your solution.

 

I opened "Gen Dig Pulse Train-Continuous.vi". 

 

I made my counter ctr1.

I  then tried to "connect the output of this counter (pin 91, or PFI 13 for the USB-6341) to the clock source of counter 0 (pin 83 or PFI 9)".

I attempted to do this by following the example here:

 

http://digital.ni.com/public.nsf/allkb/8A85E97855EDADC98625730C00065F58?OpenDocument

 

After trying this, I ran the VI and it ran without problems.

 

Then I opened up "Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi" and made both my clock source and my trigger source PFI9.  

 

When I pressed run, the error -200220  occurs. Reason: Device Identifier is Invalid.

 

I think that my error is in how I connected the counter output terminals. Can you look at the above pictures and give me some advice?

Thanks

0 Kudos
Message 10 of 45
(4,215 Views)