LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronization of Measurement Instruments with Waveform Generator

Nathan

 

I made sure all of the names were correct on the devices for the old code but that did still not synchronize everything.

 

I did what you said about taking " "Sync_Analog&Dig Inputs with Counter.vi" and take out the code for inputting a digital signal. " Then I sent the output of the counter to my camera pulse input but my cameras did not even recieve the trigger signal.

 

If you look back at page 2 of our discussion, I mentioned that the cameras are a digital output, not a digital input.

I do not want to collect data (such as a wave) from the inport. I just want to tell the computer to start collecting data in its respective software and then take a picture everytime it sees a wave.

 

Previously,  when I changed the port from an inport to an outport, I got the following error message: 

 

" ERROR  -200462   

Generation cannot be starte because output buffer is empty. ......"

 

We talked about different solutions but never implemented them because we changed the code to just a rising digital edge.

 

Now I want to try using the counter terminals to generate pulses, so we are back to the same problem as before.

I have a digital output and an analog input. The counter terminal is sent to both of them but the code is not working. Can you please look at my attached code and see where my logic has broken down?

 

Thanks for your patience and persistence.

 

Gcass

0 Kudos
Message 31 of 45
(1,030 Views)

Hello gcass,

 

So it looks like we got the "Cont Acq&Graph and digital output trigger.vi" example working correctly for us. As you remember, this example starts collecting data and sends a digital start pulse to your camera at the same time. However, you had an issue with the acquisition and camera falling out of sync using this VI. I've attached an updated VI that also outputs a counter pulse on pin 89 (PFI 12). This pulse is a 5 Volt TTL Signal. If your camera cannot accept this type of signal, we may need to look at other options for controlling your camera. 

 

So the attached example starts the output trigger for the camera and the analog acquisition at the same time while also syncing up the analog input with a counter pulse. This same counter pulse gets sent out on pin 89 (PFI 12). So here is a summary of what this does:

 

Analog Input:

Takes a sample every time the counter pulse edge rises

 

Counter output:

Outputs a pulse at a user defined frequency (the sampling rate) to pin 89. There should be a 5 volt signal coming out of pin 89. The analog input is also using the internal signal of this counter as it's timebase.

 

Digital output

Sends a single digital output pulse at the exact time when the analog input starts acquiring data.

 

As I said previously, you get ERROR  -200462 when you try to output a signal without writing to the buffer first (only valid in buffered generation. You can also generate by not messing with the Timing VI and send out single samples, in which case you don't have to write before you start).

 

So basically you should try and see if your camera can take pictures every time it receives a 5 volt signal. If so, then send the output of pin 89 to the input on the camera. If your camera can't accept digital signals to tell it when to take a picture, then you may have to contact the company that makes the camera to see if they have a solution to syncing the camera up with various events. 

 

If your camera does accept digital pulses, wire the pin 89 to the camera, and wire the output of the p0.0 to the trigger that starts your camera. Your analog signal will only take samples when the counter pulse is fired. So if your camera is also based on this same counter pulse, then they will be synced. 

 

 

Software Developer
National Instruments
0 Kudos
Message 32 of 45
(1,025 Views)

Nate

 

Thank you so much for yourpatience and help in this endeavor. 

 

My camera does accept digital pulses so what I need to do is 

 

a) wire pin 89 to the camera   ( I just wire the task out of the CO Pulse Frequency to the task in of the Digital Output port)

b) wire the output of the p0.0 to the trigger that starts the camera.  (I beileve this was already done. There is a digital bool in betweent he P0.0 and the trigger but that is used for buffer writing and is necessary).

I have attached a screenshot to show the one connection that I made (task out of counter to task in of camera).

 

I will test this code soon and get back to you. 

 

Thanks

 

gcass

0 Kudos
Message 33 of 45
(1,016 Views)
0 Kudos
Message 34 of 45
(1,016 Views)

Hey gcass,

 

I'm confused why are you doing this: ( I just wire the task out of the CO Pulse Frequency to the task in of the Digital Output port)? This will give you Error -200559 since tasks can only contain one type of channel. Is there something specific you are trying to achieve by doing this? Are you trying to send the counter output on the same digital line as your trigger? If so, you can either change the trigger to be wired to pin 89 (PFI12) or use the Export Signal VI and send the counter signal to p0.0 and delete the digital output code.

 

What exactly are the inputs on your camera? This VI is assuming your camera has a "start trigger" input that accepts a digital pulse to tell the camera to start/initialize (this is hard wired to p0.0), and a "take picture" input that will take a picture whenever a pulse is sent to it (hard wired to pin 89 (PFI12) if you use counter 0).

 

However, if you only have one digital input to your camera which you can set to control when you take the pictures, then just wire the counter output to that (wire pin 89 to the camera), and then get rid of the code that generates a single digital pulse on p0.0. The counter pulse will pulse at the same time the analog input starts sampling anyway, so this could work for your trigger as well. If you don't want to use pin 89, and are set on using p0.0, you can use the Export Signal VI to send the counter output to p0.0. 

 

-Nathan H

 

 

Software Developer
National Instruments
0 Kudos
Message 35 of 45
(1,003 Views)
Nathan This VI is assuming your camera has a "start trigger" input that accepts a digital pulse to tell the camera to start/initialize (this is hard wired to p0.0), and a "take picture" input that will take a picture whenever a pulse is sent to it (hard wired to pin 89 (PFI12) if you use counter 0). So my camera has both Synch In BNC cable and a TTL Trig in BNC cable attachments. I want to trigger AND synchronize the camera using the labview. Currently, I am only connecting the camera to the DAQ via the trig TTL cable. You said that I should "send the output of pin 89 to the input on the camera." I thought this was accomplished by wiring the task out of the CO Pulse Frequency to the task in of the Digital Output. I misunderstood. You are right when you say:" This VI is assuming your camera has a "start trigger" input that accepts a digital pulse to tell the camera to start/initialize (this is hard wired to p0.0), and a "take picture" input that will take a picture whenever a pulse is sent to it (hard wired to pin 89 (PFI12) if you use counter 0)." So what you mean is: PHYSICALLY (not in the VI) CONNECT the Synch IN cables to pin 89, which has nothing to do with altering the code. This makes much more sense. I will check it. Thanks Greg
0 Kudos
Message 36 of 45
(998 Views)

Hey Greg,

 

Yes: PHYSICALLY (not in the VI) CONNECT the Synch IN cables to pin 89. This is if you are using counter0 as your pulse generating counter. If you decide to use another counter (like ctr1 or ctr2) then you will have to find what pin is the counter output terminal for your respective counter (here's a link to the manual where you can find pinouts: http://digital.ni.com/manuals.nsf/websearch/4768D5BAFD0771CF8625773B0055185A). I hope this helps. Let me know how everything works out.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 37 of 45
(992 Views)

 

Nathan

 

So I used your codes and I think that it successfully synchronizes everything. There is only 1 issue. I changed the code so that instead of a digital waveform, I would collect the acutal voltage values of the force sensor.

 

When I set it to 10,000 Hz for pulse generation, 15,000 force sensor points are taken.This is very strange.

 

I have attached my code. Please take a look at it and see if you can tell why 1.5 the force points are taken.

 

Thanks

 

Greg

0 Kudos
Message 38 of 45
(978 Views)

Nathan

 

So I have attached my code. I could not operate the cameras unless the digital pulse was already generating, so what I did to trouble shoot was basically open Gen Dig Pulse Train Continuously, put it on CTR0 (the desired port) and had it constnatly running.

 

Then I had the pulse generator in my code set to CTR1, which had nothing connected to it. Would this have something to do with it?

 

Thanks

 

Greg

Download All
0 Kudos
Message 39 of 45
(977 Views)

Hey gcass,

 

What are you choosing for your "run time" control? I played around with running the code, and when I ran it for 1 second at 10,000 Hz and 1000 samples to read, I got 11,000 samples in my file. This just means that loop ran one too many times and collected an extra set of samples. So if you had your samples to read set to 5000 (with a 10,000 Hz sampling rate), and had your runtime set to 1 second, you will get 15,000 samples. To fix this, I added an increment on the loop iteration check (since the loop iteration starts at zero). Now I no longer get this issue (see the attached code and comments within the block diagram).

 

For the camera, I'm confused how you can only operate them if a pulse is already generating, how do you start them in the first place? The part of this code that generates pulses is the pretty much the same as the Gen Dig Pulse Train Cont VI, so I'm not sure why you have to use this extra VI. Also, remember that your analog input is using the counter's internal output as it's timebase. So make sure that whatever counter you use to generate pulses for your camera is the same counter output you choose for your timebase (if "dev3/ctr1" is generating pulses, use "dev3/Ctr1InternalOutput" as your timebase). See the comments in the code for more detail.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 40 of 45
(962 Views)