LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

digital output LED microsecond timer

Solved!
Go to solution

Hey all,

 

I am trying to make an array of 10 LEDs in a row to form an analog timer to use for characterizing shutter lag on a DSLR camera. We are going to first ballpark the shutter lag on the camera using a different method and then would like to resolve the shutter lag to within <1ms. I am trying to use labview alongside a NI usb 6251 using an SC-2345 for access to the digital outputs. Im using a timed structure and a timed loop to ensure the timing between each LED turning on corresponds to an actual time. However, I am not getting the results I thought I would. The timing does not seem to be what I thought it would be and I can not get the timed loop to work with all the channels at the desired frequency which would idealy be as high as possible. Could someone take a look at my code and provide me with some insight where I may be getting issues? I apologize if I am overlooking important information that may be needed to help solve this. 

 

~Aaron

0 Kudos
Message 1 of 10
(3,957 Views)

Aaron,

 

You seem to be trying to do it the hard way.

 

Use the hardware timed output of the 6251 to send the data to the LEDs. That device has DIO rates to 1 MHz so you should be able to generate signals with microsecond resolution.  Switch to using an integer data type. Then one value can write to all ten lines in one operation.  Create an array of values in ascending powers of two to turn on the LEDs sequentially.  Set the DO clock rate. Write the array to the DO buffer. Start task. Repeat as needed. Done.  No timed loops and no timed sequences required. One Digital Write before the test starts, so your timing does not depend on the OS passing data to the hardware.

 

The resolution of the Tick Count is 1 millisecond.  So uou cannot measure any loop timing faster than that, whether the loop iterates faster or not.  The data saved in array shows an average speed of around 1 ms with some variation. (Change the Display Format to show >10 significant digits.)

 

Lynn

0 Kudos
Message 2 of 10
(3,954 Views)

Lynn,

 

Thanks for the help. So it was not hard to get them to turn on, now how can I get them turn on sequentially and then turn off sequentially? Here is what I have so far. Its basically just the finite digital output example. 

0 Kudos
Message 3 of 10
(3,935 Views)

Here are two ways to modify the Output Array to get on followed by off sequencing.  Just insert this (or the portion you want) between Output Array and the DAQmx Write.vi.  The For loop is just for display and is not needed in the version driving hardware LEDs.

 

Lynn

0 Kudos
Message 4 of 10
(3,921 Views)

Lynn,

 

I appreciate your responses. I implemented your solution however, I am still not getting results. Am I missing something in my execution of your code?

0 Kudos
Message 5 of 10
(3,911 Views)
Solution
Accepted by topic author asassoon

I do not have DAQmx so I cannot be sure.  I think the 6251 has a maximum DO rate of 1 MHz so trying to set the rate to 20 MHz should generate an error.  For testing purposes set the rate to 1 few Hertz or less.  Then you should be able to see the LEDs as the turn on and off.

 

You also may need to set the number of samples to the size of the array.  That refers to the size of the array fed to the DAQmx Write, not the array on the front panel.  With the number of samples set to 1 I would expect that it only writes the first element of the array which happens to be zero.  That does not produce a very interesting output: It jsut leaves all the LEDs off!

 

Lynn

Message 6 of 10
(3,905 Views)

Lynn,

 

I think I got it working. Thank you so much for your help.

0 Kudos
Message 7 of 10
(3,902 Views)

If Lynn gave you help, then you should mark his message that helped you the most as the solution to your question rather than your own thank you message.  First you will have to go to the options menu to the upper right of your message to unmark it as the solution.

0 Kudos
Message 8 of 10
(3,889 Views)

I am very new in labview.

 

I am using labview to control the IGBT switches. I want the pulses at 10 KHz from connecting box (SCB-68). However the pulses are below 10 Hz (measure through DSO). In labview the pulse rate is 10KHz. I am using PCI 6251 kit.

 

 

Attachment for your information. Please help me out the for the possible conceptual error / modification.

0 Kudos
Message 9 of 10
(3,738 Views)

You really should've have started a new message thread.  Since the thread you responded to is marked as solved, you might not have as many people looking into it to help you.

 

The problem is your DAQ assistant is set for 1 sample, on demand.  That means it is software timed.  It is only going to put out samples as fast as the loop will run.  And since you are using Express VI's, that have some extra code behind them that can cause them to be slower than native LabVIEW code.  There is no way your VI can keep up with a 10 kHz loop rate.

 

You need to output data using an N samples waveform.  Look in LabVIEW help for DAQmx examples on how to do this.

0 Kudos
Message 10 of 10
(3,725 Views)