Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Help with delayed ttl timer/trigger


  • Please log in to reply
5 replies to this topic

#1 johannes

johannes
  • Members
  • 2 posts

Posted 29 November 2011 - 08:58 PM

Hi, I am new to labJack. I have pretty limited understanding of electronics but some experience with programming. I wonder if a labJack U3 can do the following trick for me: I have a camera which exposes for 100 ms every 110 ms and sends a TTL pulse that is high during exposure and low in between exposures. I would like to open a separate shutter for 30 ms using a delayed TTL pulse during the high state (during exposure) at a fixed delay after the leading edge of the high pulse. I want LabJack to listen to the camera pulse, and, once it detects the pulse, generate a short TTL pulse after some delay. I guess in short I want to simulate a delayed pulse generator if that makes sense. Is LabJacks timing accuracy sufficient for this task? Can someone direct me to the relevant documentation/ code fragments or example applications that would do something like this? I have installed AzeoTech DAQfactory and I also have MatLab available Thank you very much in advance, J

#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 30 November 2011 - 09:23 AM

Section 3.1 describes your basic limitation:

http://labjack.com/s...3/users-guide/3

It will take about 600us each time to check the state of the input, and then whenever you want to change the state of the output that will take about 600us. Actually, when you create the output pulse you will likely use a single combined high/wait/low command (using an add/add/add/go/get/get/get block of code).

So there is perhaps 600us jitter in detecting the input high. Then you use a software delay, which I would say is pretty reasonable to do to +/-1ms. Then there is perhaps 600us jitter in sending the high/wait/low command that creates your 40ms pulse.

I don't think matlab will have a problem with the software delay. You can program it like any other language, although if you are not a matlab wiz I would consider just using plain C or something simpler like that.

Not sure about the timing of this in DAQFactory. I will ask AzeoTech to look at this topic.

#3 johannes

johannes
  • Members
  • 2 posts

Posted 30 November 2011 - 11:39 AM

Actually, when you create the output pulse you will likely use a single combined high/wait/low command (using an add/add/add/go/get/get/get block of code).


Hi, thanks for the response. I can live with the jitter you described.

Your suggestion 'high/wait/low' to generate the output sounds like the right thing but I am lost with the syntax of these commands and how to combine them with edge detection in a LabJack script.
Is there any example code (pseudo or real) doing something like this that I can use as a start?

thanks again,
J

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 30 November 2011 - 03:11 PM

If you are using DAQFactory, you probably need to start a topic on AzeoTech's forum to get help with writing the sequences.

If you are using matlab or some other standard programming language, you first just have a loop that reads a digital input as fast as possible until you see the state you are looking for. I suggest you just call eDI in that loop:

http://labjack.com/s...ers-guide/4.3.9

This is one of the easy functions, so when you look at our UD driver examples for various languages look for an example related to easy-functions or efunctions.

To make the 30ms pulse, you will do an add/go/get block. You can see pseudocode for an add/go/get block here:

http://labjack.com/s...ers-guide/4.3.5

Yours would look like:

//Set FIO3 to output-high.
AddRequest (lngHandle, LJ_ioPUT_DIGITAL_BIT, 3, 1, 0, 0);

//Wait 30ms.
AddRequest (lngHandle, LJ_ioPUT_WAIT, 0, 30000, 0, 0);

//Set FIO3 to output-low.
AddRequest (lngHandle, LJ_ioPUT_DIGITAL_BIT, 3, 0, 0, 0);

GoOne
Get...
Get...
Get...

You can read about the wait iotype here:

http://labjack.com/s...rs-guide/4.3.14

#5 drax22

drax22
  • Members
  • 1 posts

Posted 27 September 2013 - 12:58 PM

In the pseudocode that you gave in your reply, you have three AddRequest() and the GoOne() and I understand that part.  But you say that there needs to be three Get... function calls.  Could you give the pseudocode for this?  

 

The reason I am asking is, to do the three Get..., if I call the GetResult() what would the parameter be for each of the Get...?  

 

 

 

//Set FIO3 to output-high.
AddRequest (lngHandle, LJ_ioPUT_DIGITAL_BIT, 3, 1, 0, 0);

//Wait 30ms.
AddRequest (lngHandle, LJ_ioPUT_WAIT, 0, 30000, 0, 0);

//Set FIO3 to output-low.
AddRequest (lngHandle, LJ_ioPUT_DIGITAL_BIT, 3, 0, 0, 0);

GoOne
Get...  (What is the pseudocode here?)
Get...  (What is the pseudocode here?)
Get...  (What is the pseudocode here?)

 

Thanks



#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 07 October 2013 - 05:01 PM

The GetResult() functions access results based on the IOType and Channel parameters.  Thus, you'd want something like:

GetResult (lngHandle, LJ_ioPUT_DIGITAL_BIT, 3, ptrValue1);
GetResult (lngHandle, LJ_ioPUT_WAIT, 0, ptrValue2);
GetResult (lngHandle, LJ_ioPUT_DIGITAL_BIT, 3, ptrValue3);

In this case the only real purpose of that would be to check the error codes if the GoOne call reports one, since none of those requests actually return anything (in the way an analog input read would).  They are all setting/controlling things on the LabJack.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users