Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the USB 6501 to trigger the execution of some code

Solved!
Go to solution

Hi there,

 

I would like to use the USB 6501 to trigger the execution of some code. I am struggling to figure out a way to do this because all of the examples I can find use a daq to trigger acquisition on the same device - I don't want to use the 6501 to do anything except see the trigger and then I want to execute code which doesn't use any daqmx vi's.

 

To be more clear, here is what I would like to do:

  • I have a 1.5us wide, 5.25 V high TTL pulse coming from an instrument. The pulse arrives at a regular interval, with the interval varying between 10ms and 100 ms. (My 'data rate', so to speak, is not large at all. Also, I can control that interval so I can make it longer if I need to).
  • I want to detect that pulse with the USB 6501
  • I want to use some of NI's digital i/o vi's to 'see' the pulse and then use that pulse as a trigger to execute a block of code 
  • The block of code which will be executed controls a different instrument, it does not use any daqmx vi's, and is not a NI daq device.

I am confused about a few things:

  1. Does the USB 6501 have the capacity to see a 1.5us wide pulse? I can't find any specs for minimum pulse width except with the counter input. In other words, does the USB 6501 have a high enough clock speed to see a 1.5 us pulse?
  2. How will I implement the timing? The block of code I want to execute will take much less than 10ms to complete, but I am confused about using the timing functions to ensure the block of code executes within the interval between pulses
  3. How will I implement this generally? All of the examples I can find are about using pulses to trigger acquisition on a DAQ. I can't find any examples for just triggering some block of code.

Thanks so much!

Sabrina.

0 Kudos
Message 1 of 8
(4,308 Views)

Hey,

 

You can use the USB 6501 to trigger your code and the Counter is fast enough to catch to 1.5 us resolution you need.  

 

As for how that is done,  can you give me some background on what your experience with LabVIEW is?

 

I want to find some examples online by searching through our forums, you can as well if you don't want to wait for me.  I just want to see how much information you are going to need or if maybe some training is needed.

 

As far as I can tell, you are trying to read in a digital signal, have the USB 6501 reading in the signal and when a certain signal is coming in, triggering a section of code.

 

The examples of triggering should work if you put your own code in the while loop.  To be sure, I would have to see the code example you are looking at.

 

Can you,

 

1.  Tell me if I am understanding you correctly and show me the examples you have been looking at for this?

 

2.  Try some code with instead of the aquisition VI's in the loop, try the code that you want.

 

3.  How are you going to assure the code is running within 10 ms?

 

-Ben

Regards,

Ben Johnson
ʕง•ᴥ•ʔง
0 Kudos
Message 2 of 8
(4,269 Views)

Hi Ben,

 

Thanks for your response.

 

To respond to one my questions, I found that the minimum pulse width for the digital i/o channels on the USB 6501 (excluding the counter) is 300ns, so it certainly does have the ability to see a 1.5us pulse.

 

To respond to your questions:

  1. I think you are understanding correctly. So far I have looked at NI's tutorials on Data Acquisition and triggering (http://www.ni.com/academic/students/learn-daq/triggering/) but those are all focused on using a NI DAQ as the object being triggered - I want to trigger some block of code to execute (the code controls a different, not NI instrument). I have also found this example, which is very close to what I need but is a bit unnecessary to use the counter (though in principle I could) (https://decibel.ni.com/content/docs/DOC-7372), and finally I have found an example for using a start trigger to generate a pulse (https://decibel.ni.com/content/docs/DOC-12129) - but again this uses DAQmx for the pulse - what I can't find is how to use a digital pulse from an input port then use that to generate a trigger which triggers the execution of a block of code, where the block of code doesn't use any of the DAQmx functions.

  2. This won't work as it breaks the flow of the program as far as I can tell

  3. I am not sure - I was going to look into finding a funciton which times the execution of a block of code (this is common in other languages, but I'm not sure if possible in LabView)

I am new-ish to LabView, but I am experienced in many other languages (C/C++, Matlab, Python, XML, VHDL). I'm not a coder or a code jockey, but I've had to figure out various languages through out my career, so I'm at least comfortable with wading through a bunch of information and learning as fast as I can until I get whatever I need done.

 

Thanks again!

 

Cheers,

Sabrina

0 Kudos
Message 3 of 8
(4,259 Views)

What do you mean breaks the flow of the program?

 

I was just thinking of using the trigger setup but stopping the task as soon as the trigger goes off and then have the code following the stop/clear task VI's.  That way the code still waits on the trigger but there is no acquisition that happens once it is triggered.  

 

You may also accomplish this with an edge count task.  I am not sure.

 

Can you try creating a digital trigger task and then stopping the task right after the trigger VI and then have a loop/code diagram of the desired code?

 

-Ben

Regards,

Ben Johnson
ʕง•ᴥ•ʔง
0 Kudos
Message 4 of 8
(4,247 Views)

I'll give that a go and let you know. A critical instrument just broke so I won't be getting back to this for at least a week.

 

Thanks for all your help!

0 Kudos
Message 5 of 8
(4,207 Views)

Hi, I'm back to the LabView now.

 

What I'm struggling with is that I am using LV to control a deparate software suite - so there is already a program flow associated with that. I can't just 'add in' DAQmx VI's - the program flow is controlled by the automation 'wires' for the other software suite. So adding in Daqmx triggering and tasks breaks the flow of the program. The screenshot attached shows what I mean by that.

 

I need to be able to use the pulse to start the execution of some code which is controlled by an automation flow which is completely separate from the DAQmx flow.

 

Any ideas?

 

 

0 Kudos
Message 6 of 8
(4,116 Views)
Solution
Accepted by topic author TSr314

What if you put your DAQmx Start Task VI into a flat sequence structure, and ran the “automation wires” through the sequence structure as well? The DAQmx task would be configured to wait for a trigger, so the DAQmx Start Task VI wouldn’t run until the trigger had been received. Since the “automation wires” run through the sequence structure, the flow would simply be halted until the trigger started the DAQmx task. You could then place the code you want to run after the trigger is received immediately following the sequence structure. This is where you could also stop the DAQmx task, as Ben had mentioned.

Ross S.
Applications Engineering
National Instruments
0 Kudos
Message 7 of 8
(4,095 Views)

Thanks Ross!

 

That's what I did, and it worked. Very much appreciated!


Cheers,

Tanya

0 Kudos
Message 8 of 8
(4,091 Views)