Logging on a specific treshold


Recommended Posts


I have two different questions for a project.

#1 (most important) Im working on a project where we want to log on a certain time. When a channel value is greater than X i want to log, with a time delay of 90mS, the value on another channel. This logging should only happen when a digout is enabled(1).

#2 Also i want to have a timer, showing minuttes and hours that a sequence is active, with reset of timer when disabled... any ideas?

Breg Geirrune


Link to comment
Share on other sites

#1) do you only want to log after the time the channel becomes greater than X?  I.e. when it crosses the threshold?  First of all, there are time latencies that can't be avoided if you do this in software.  This comes from both the delays in communications with hardware, and with how often you query the input.  For example, if your Timing is set to 0.1, then even ignoring comm delays, DAQFactory may not know if the channel crossed the threshold for 99.99 ms.

There are a couple ways around this, as you can't query the input faster than maybe every 10 or 20 ms.  Even if you stream, you can't do the logic in-situ because in stream mode, the data comes in in blocks.  The first way is to stream, but stream both channels, then analyze the data in blocks as they come in.  This is a bit more complicated to achieve, and is usually best done in a separate sequence.  The problem with this is that you still are subject to the latencies of streaming, but you can stream really fast and get that well below a millisecond.  

If, however, you really need it super tight, you will have to use hardware triggering.  Use a schmidt trigger to set a digital signal for when the threshold is crossed, and feed that trigger into a trigger input on your DAQ device.  The LabJack supports this sort of thing, but I don't know what hardware you are using.

#2) this is much easier.  Create a global variable called, say, "startTime", declared in an auto-start sequence.  Then at the top of the sequence you want to top, do:

startTime = systime()

Then, wherever you want to display the elapsed time, use something like:

iif(mySequence.running, systime() - startTime, 0)


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.