LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronization of Measurement Instruments with Waveform Generator

Hello gcass,

 

It looks like in your Channel Parameters settings of the 'Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi' you have your physical channel set to Dev1/ai0. Shouldn't this be Dev3/ai0? Do have another device besides the USBX-6341? It looks like this error is appearing because it can't find Dev1.

 

If you are not sure about what devices you have installed, you can open up Measurement and Automation Explorer (located in all programs>National Instruments), and then expand your Devices and Interfaces to see what devices you have. From here you can also go to 'Test Panels' and test the inputs and outputs to make sure they work before doing any LabVIEW programming.

 

-Nathan H

 

 

Software Developer
National Instruments
Message 11 of 45
(927 Views)

Nate

 

Thanks for the previous tip. That was a silly mistake that I made.

 

I made the necessary changes to the VI and I came out with the following results:

 

When both VI's are open:

 

I "run" the digital pulse generator VI and it works without error. The Acquire Voltage VI does not automatically start up, even though the clock/trigger settings are set to the correct ports.Should this happen or no? SEE PICTURE #1 BELOW.

 

If i "run" the digital pulse generator VI and then click run on the Acquire voltage VI, it DOES start collecting data right away.SEE PICTURE #2 BELOW.

 

So I need to incorporate these two codes into the same file. What would be the easiest way to do this? Is there a way that I can "call" the digital pulse generator VI or should I just copy/paste digital pulse VI into the acquire voltage VI?

 

Technically, if my tested lasted 10 seconds (for example), I could probably just run the pulse generator continuously and then when I wanted to trigger the actual test/data acquisition, I could press run on the acquire voltage VI? Correct?

 

 

Thanks for all your help on this project.

 

I will be posting some photos below detailing

 

gcass

0 Kudos
Message 12 of 45
(906 Views)

 

 

You can see data was collected because of the baseline voltage.

 

 

0 Kudos
Message 13 of 45
(905 Views)

digital pue on, acquire voltage on.jpgdigital pulse on, acquire voltage off.jpg

0 Kudos
Message 14 of 45
(898 Views)

Hello gcass,

 

The Acquire Voltage VI should not start automatically. I was having you open them up individually first, in order to see the functionality, with the implication that you would combine them into one VI later. I have combined the sync with counter, analog input, and digital input into one VI for you. I don't know what version of LabVIEW you have, but I have attached a 2009 copy (which you will be able to open in 2010 and 2011 if you have these versions). If you are using a version older than LabVIEW 2009, let me know and I will save it for the previous version you need and repost it. I hope this helps!

 

-Nathan H 

Software Developer
National Instruments
0 Kudos
Message 15 of 45
(893 Views)

Nate

 

Thanks for the code. It worked perfectly. I have one remaining issue though.Let me explain further:

 

I have two computers in this experiment: 1 with the photo capturing software (computer A) and 1 with the labview software (computer B)

 

In my original code, my cameras were hooked up to a digital output port. The cameras were waiting for a trigger signal in computer A. 

 

In computer B, I ran the labview program and the  trigger signal was sent to the cameras telling them to start. That was it. Once the trigger signal was sent, the cameras started taking pictures. Then the rest of the commands were executed in labview (telling the force sensor and testing machine to start).

 

In this new labview that you attached, it is looking for a digital input port.

 

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.

 

When I change the port from an inport to an outport, I get the following error message: 

 

" ERROR  -200462   

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

 

The only thing I changed from the code was the inport to an outport. Thus, I am pretty sure that the outport is an issue.

 

Is there a way that I can get around this error? Can I change the input to something else?

 

I have attached three pictures below:

1. A picture of the error code when I have a digital output port.

2. A  picture of my old code that had a digital output.

 

Thanks

 

Error with Digital OUTUT.JPG

 

 

 

 

 

Digital Output in Original code.JPG

 

 

I have two computers in this experiment: 1 with the photo taking software and 1 with the
0 Kudos
Message 16 of 45
(878 Views)

Hello gcass,

 

Are the cameras simply waiting for a rising digital edge? If so, you could simply send the output of Counter1 (pin 91 or PFI 13) to the input of your camera controller.

 

If you want to generate a separate digital signal, you could simply add the code you had in your previous VI to this new VI, except also add a DAQmx Start Trigger.vi before you run the task that has the destination terminal as it's source (PFI 9).

 

You could also open up "Gen Dig Pulse-Dig Start.vi" from the example finder and select an unused counter (like counter 2 or 3), and use PFI9 as your trigger. The you would simply wire the output of this counter (ie - pin 93 or PFI 14 for counter 2), to the input of your cameras. Basically just make sure that whatever digital pulse you use to send to your cameras is triggered off of PFI9 (the same thing your analog input is triggered off of so they both start at the same time.

 

You received that error because you can't simply change the task from digital input to digital output, you also need to change the read function to write function, and make sure you are writing to your buffer before you start the task. But instead of altering the digital input task that I gave you, just delete that out and add in the code for one of the methods I listed previously. I hope all goes well setting this up!

 

-Nathan H 

Software Developer
National Instruments
0 Kudos
Message 17 of 45
(869 Views)

Nathan

 

Yes

 

The cameras are simply waiting for a rising digitial edge (I believe). In the previous code, we simulated a square via a while loop (see above picture).

 

How does one wire the output of Counter 1 to the input of the camera controller? I tried to wire the output of counter 1 to the Digital output.vi (white box) via the task in line but it gave me an error about the channels being incompatible. Am I wiring this to the wrong area?

 

I also tried tried to use my old code by putting the while loop with the digital bool after the DAQ Start Task.VI,  and still connecting everything, but it gave me the same as before.

" ERROR  -200462   

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

 

Thus a few last questions (hopefully):

A) The digital channel should be a digital output correct?             It should not be a digital input?

B) Is it ok to send a trigger signal and sample clock into the DAQ Start task for the Digital output or do I need to do a read task before I use the DAQ Start Task for the digital output? I saw in digital synchronization sample that they did a read of a waveform before they pressed start. Does that make any sense?

 

C) I think that the option where I "send the output of Counter1 (pin 91 or PFI 13) to the input of your camera controller" is the best option because I want data recorded at the same rate and at the same time.

 

Also, how would i alter this code so that it was not on "user stop" but rather, only ran for a predetermined time, such as 3 seconds.

 

 

Thanks again

 

gcass

0 Kudos
Message 18 of 45
(861 Views)

Nathan

 

I was told from someone formerly in my lab that " There should be two counterports in the current DAQ board. Find out what is another one and write the exactly the same code as your clock series (counter)." I did not understand what she meant. Could the errors I am having be caused by having the same source as trigger / clock?  My above post details more my current issue.

 

Thanks

 

Greg

0 Kudos
Message 19 of 45
(859 Views)

Hello gcass,

 

So if I understand it correctly, you have analog inputs you want to sync up with the start of a single digital output (just the rising edge). All of your analog inputs can just sync up on the analog sample clock, and then you can either send the analog start trigger directly out on a pin (as shown in the first example I've attached) or make a single digital output that starts with your analog sample clock (as shown in the second attached example). Either way, you need to wire one of these digital outputs to your cameras.

 

To answer your questions:

 

A) if you are wanting to output a digital signal to start the cameras, then yes, it should be a digital output.

B) You need to set up things like triggering and sample clock settings before you start the task; however, when you are outputting signals, especially if you are using a buffered output, then you need to write the buffer before you start the task. Basically, do what they did in the example you mentioned where they wrote a waveform before they started the task.

C) To alter these codes so that they only run for three seconds (which I've done in the second example) you make it so your loop stops after it reaches an iteration number that is equal to [(sampling rate)*(seconds to run)]/(samples per channel). So sampling rate times the amount of time you want to run gives you the total number of samples you will take. Then you divide that by how many samples you are taking for each iteration of the while loop. This gives you the number of iterations that your loop needs to run.

 

-Nathan H 

Software Developer
National Instruments
0 Kudos
Message 20 of 45
(852 Views)