LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronization of Measurement Instruments with Waveform Generator

Nathan

 

A) What do you mean by the phrase " wire one of these digital outputs to your cameras."? 

My cameras are connected to the DAQ board via the digital output port p0.0 . Is this what you mean? 

 

B) Should I still be using a counter temrinal to output a pulse (aka the code you provided earlier)?

 

C) In your second code, Cont Acq&Graph and digital output trigger.vi 38 KB,  you show the analog and digital ports starting at the same. But there was no DAQ Trig. VI. And you are not using a counter temrinal to outpout a pulse?

 

C2) Also in this code, it cannot find the "Get Terminal Name with Device Prefix.vi" (perhaps my version of labview is too old).

 

D) When I tried to use a digital read with the waveform, it gave me the following error in my code that used a counter.

 

" ERROR -200802

 

Write cannot be performed when....

 

Call DAQmx Start before Daqmx...or change the output buffer"

 

Assuming the output buffer needs to be changed, how does one do that and is it even necessary (aka should I still be using this code)

 

E) When I tried writing a 1 line, 1 point digital bool like in the second code, to my counter code, it gave me the following error:

 

"

ERROR -200609

 

Generation cannot be started, because the selected buffer size is too small

 

"

 

Assuming the output buffer needs to be changed, how does one do that and is it even necessary (aka should I still be using this code)

 

 

 

Thanks for your undying patience

 

 

Greg

0 Kudos
Message 21 of 45
(859 Views)

Hey gcass,

 

I'm sorry, I forgot you were using p0.0 to connect to the camera. Just set the digital output to port 0, line 0 (which is p0.0), that is what I meant by connect it to the camera. I've attached an updated 'Cont Acq&Graph and digital output trigger.vi' that just uses a constant instead of the "Get Terminal Name with Device Prefix.vi", so you should be able to run it. Also make sure you set the source for the 'DAQmx Start Trigger.vi' for the digital line to Dev/ai/StartTrigger (I made comments about this in the block diagram, just make sure you have the right Dev).

 

So basically, analog inputs are already synced up on the analog sample clock. You only need that extra counter if you were going to sync up analog and digital inputs or outputs. But since you just want to send a single pulse, this can be done with a trigger. So this code runs two analog inputs (although you can acquire more inputs if you want), and sends an output to your digital line at the same time the analog inputs start acquiring. You no longer need the counter since you just want to sync up analog inputs and a single digital output.

 

Answers:

 

A) as I said above, just set the digital output to port 0, line 0 which is p0.0

B) you don't need to use a counter if you're just syncing up analog inputs. The digital output can just be synced to the analog input's start trigger. If you were continuously acquiring digital signals, you may need to use a counter, but this way should work fine.

C) there is no trigger for the analog inputs, but you send the StartTrigger of the analog inputs to the digital output. Basically, analogs start normally, and the digital output uses the analog timing to determine when it starts.

C2) I've taken that VI out. That just gets the device reference for your ai/StartTrigger, but you can just use a constant.

D) You are using buffered output. If you setup the timing (using the DAQmx Timing.vi) you make it a buffered output, and this requires there be more than one sample. You don't need buffered outputs if you are just sending one signal.

E) similar issue as D.

 

Software Developer
National Instruments
0 Kudos
Message 22 of 45
(835 Views)

 


I hooked up the cameras / force sensor (but not the testing machine) and set the cameras ready for a trigger signal. Then I pressed run on my program and .... Success! It sent in  a trigger signal and the force sensor recorded data. 

Then I tried to run it again, with the cameras ready for a trigger signal.....and it the cameras didnt respond to the labview running. They kept waiting for a trigger. 

I made sure that the cameras were still working properly (aka waiting for a trigger and then starting once a trigger was sent in) with the previous code and they were. 

Then I turned everything off and tried it again. 

Again, I had once success and then every other time, it didnt work. 

I ran it with HIGHLIGHT execution and it gave me the following error (see attached picture):

"Attempted to read samples that are no longer available. The requested sample has been overwritten. 

INcreasing the buffer size, reading the data more frequently, or specifying a fixed number of samples might correct the problem

"

This doesnt sound like a trigger issue, but it doesnt sound good either.

Can you explain why the code might work one time and then not again? 
Can you offer any suggestions/solutions to the error? 

Thanks

 

gcass

Download All
0 Kudos
Message 23 of 45
(829 Views)

Nate

 

About my problem from directly above ^^

 

I was told that "

 

 it is easy to solve your problem. Remember in the old code I have
two for loop to create a step signal, on and off, a complete step cycle,
but here your digital output to the camera is always in a true signal.
That's why the first time you run the code,the digital output changed from
False to True (the camera receives a rising signal). and It stays true
after that. When you run the code again, because of the error, it returns
to the false state and when you try the third time, it sends a rising edge
again. To verify this, you can run your code once, and disconnect the
digital output from the camera and use a voltagemeter to measure the
voltage at that port. It should be five volts.

To solve this problem, you could write another VI, that just has the
digital output series and its function is just to turn that port back to a false state"

 

 

Does this make sense?

0 Kudos
Message 24 of 45
(816 Views)

Hello gcass,

 

Yes, this makes sense. Sorry I forgot to include a low signal on your line when I first made that VI. Basically, the VI is sending a high signal on the digital output line, but then never resets back to low. I've attached the updated VI that sends a high signal, holds it for 200ms and then brings it back to low.

 

Also, the errors you get when you do highlight execution are not related to this, they are related to highlight execution. When you run highlight execution, it slows the execution of the VI down significantly. The DAQmx VIs will usually give you an error during highlight execution because they are running too slow to read the buffer at the desired rate.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 25 of 45
(812 Views)

Nathan

 

I have discovered an issue with the synchronization within the Labview program.

 

Today, I ran some tests with my test machine that strains a material. I entered in all the necessary parameters and then ran the test.  The trigger system worked effectively and the cameras started collecting data once I pressed run.

 

Unfortunately, there was a delay between the force sensor and the cameras.

 

For example, at frame 1100, the cameras showed that the specimen had not been strained. Meanwhile, at force sample 1100, the force sensor was near its peak value. This means that the force sensor starts collecting data BEFORE the camera gets the signal. This means the force sensor and cameras are not synchronized.

 

Do you have any idea why this would be? Is it because we are triggering the cameras off of the force sensor? Is there a way to make this delay more reliable?

 

 

Would using a digital pulse solve this issue (like we discussed earlier)?

 

I also have a digital pulse generator in my lab that I could use so that the force sensor data and the camera each took a picture at the same time as a pulse was sent out, rather than simply starting off the same trigger.

 

Thanks

 

gcass

 

I

0 Kudos
Message 26 of 45
(797 Views)

Hello gcass,

 

To truly synchronize your analog input with the camera, you need to make sure that the camera is taking pictures at the same rate you are recording data. How are you specifying the rate at which the camera takes pictures? Can you change this rate to match the rate you are specifying for your analog input?

 

If you can control when your camera takes pictures with a digital pulse, then syncing the camera and analog input with this pulse would definitely be the best approach. You can either use the pulse generator you have or generate your own pulses. If you want to use the external pulse generator, then just wire the output of that pulse generator to one of your PFI lines and you can use an example for analog input with an external clock (open up example finder and then open "Hardware Input and Output»DAQmx»Analog Measurements»Voltage»Cont Acq&Graph Voltage-Ext Clk.vi"), and set the DAQmx Timing VI's clock source to that PFI line.

 

If you want to generate your own pulse, you can use a counter to do this (example finder: "Hardware Input and Output»DAQmx»Generate Digital Pulses»Gen Dig Pulse Train-Continuous.vi"), then send that output to the camera and to another PFI line. Just remember to set your DAQmx timing VI clock source to the PFI line that you are inputting the external pulse on.

 

-Nathan H 

Software Developer
National Instruments
0 Kudos
Message 27 of 45
(781 Views)

Nathan

 

Using the previous labview, i set the capture rate of the cameras (in the cameras software) and the capture rate of the force sensor (in the labview) to be the same. 

 

You said

 

" If you want to use the external pulse generator, then just wire the output of that pulse generator to one of your PFI lines and you can use an example for analog input with an external clock (open up example finder and then open "Hardware Input and Output»DAQmx»Analog ......If you want to generate your own pulse, you can use a counter to do this (example finder: "Hardware Input and Output»DAQmx»Generate Digital Pulses»Gen Dig Pulse Train-Continuous.vi"), then send that output to the camera and to another PFI line."

 

Isnt this what we tried to accomplish previously in this thread (see the attached VI that you graciously sent along). 

 

The last time we looked at this VI, I was having trouble because I changed the digital input to a digital output. Isn't this what I need (it uses a counter to generate a digital pulse) or should I follow your above comments? 

 

Thanks

 

gcass

 

0 Kudos
Message 28 of 45
(771 Views)

Nate

 

The company that makes the cameras, Photron, has a "Labview wrapper" with some sample VIs that may be useful. Do you think these are necessary? 

 

Also, I think that I never changed the start AI trigger from Dev1 to Dev 3 when I ran my code and problems occurred. No error message popped up saying that DEV1 did not exist, but this might be a possible source of error right?

Thanks

 

Greg

0 Kudos
Message 29 of 45
(758 Views)

Hey gcass,

 

First make sure that your AI start trigger, and AI channel (and Digital Channel) are coming to and from the same device. You can right click the constants or controls and go to "I/O Name Filtering" and select "Limit to Device" and pick the device you are using.

 

Feel free to download the wrappers and open them to see if there is a specific protocol that the company recommends for controlling the cameras. But if you already can control when they take the picture with a digital pulse, then that's really all you need.

 

I would first try to troubleshoot by making absolutely sure the sampling rates of everything is equal, and that you have the same device names. If that doesn't work, you can use "Sync_Analog&Dig Inputs with Counter.vi" and take out the code for inputting a digital signal. Then just send the output of the counter to your camera pulse input. (to find the right pin that your counter output is on, you can open up Measurement & Automation Explorer and right click your device and go to "Device Pinouts"). Again, make sure you have the right device name when configuring what counter you are using in the block diagram.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 30 of 45
(752 Views)