Triggered Logging/Streaming using LabJack U12


Recommended Posts

Hi everyone,

following setup: I have 4 photodiodes and a light-barrier.

I want to log the signals coming from the photodiodes only when the light-barrier is open.

Ideally it should work that way: light-barrier opens -> data from diodes logged with i.e. 0.1 kHz; light-barrier closed -> logging stopped until barrier opens again.

I would be also happy, if a certain amount of samples is logged after the light-barrier opens.

Due to the desired data rate of 0.1 khz (or more) I think streaming is the right function.

I played around with the function pretriggered streaming, but somehow it doesn't work as I want it to.

I want to log signals from single-ended channels 0-3. The light barrier gives out a differential signal dependent on the supply voltage (5-24 V DC).

Maybe someone could give me some instructions how to setup the single channels to realize triggered streaming.

Thanks in advance! :-)


Link to comment
Share on other sites

Sounds like you would stream 4 analog inputs, and connect the light barrier signal to IO0 as the IO lines are also returned in stream mode. Azeotech will have to comment on whether the IO0 data can be used to control the soft stream triggering in DF.

I don't understand what you mean when you say the photodiode signals are differential, but you are going to measure them single-ended?

Run some simple test programs to make sure the light barrier signal is causing IO0 to read high and low as expected, and to make sure you are getting the expected voltages on the analog input channels.

Link to comment
Share on other sites

You can easily use the digital signal to trigger the streaming, as long as you are aware of the latency. First question is: U12 or U3/UE9? I'm assuming U12 since you mention pretrig mode. This is actually probably the best choice for the U12 as there is no latency, plus you can't read the digital slow while streaming the analogs. If the latency (delay) is ok between the digital signal and logging, then use the soft trigger:

I'll assume you have a sequence to start and stop the stream and a logging set already running. In your digital input channel's Event (lets say its called DigIn) put:

// trigger start
if ((digin[0] == 1) && (digin[1] == 0))
// trigger delayed end
if ((digin[100] == 0) && (digin[101] == 1))

The first if looks at the most recent digital signal and if the most recent is high, and the next most recent reading is low (transition to high), it starts the stream. The second if does the same thing in reverse, except that it goes back 100 readings. This delays the stop by 100 readings * interval of reading the digital signal.

Link to comment
Share on other sites

The signals from the photodiodes are single-ended, the signal from the light barrier is differential.

I'm using a LabJack U12 and DAQFactory Express.

The voltage coming from the light-barrier is causing IO0 to switch between low and high.

The delay between trigger and logging could be critical, so I expect that it's going to be a triggered logging of a certain amount of samples, right?

I tried using the PretrigAnalog.ctl file from the AzeoTech Knowledge Base.

I added a modified version of that file. It should log channels AI0-AI3 (single-ended from photodiodes), when channel AI10 (differential from light-barrier) exceeds 5V. In this case 300 samples are to be logged with a sampling rate of 100 Hz. Is it possible to repeat that procedure so that these 300 samples are logged every time channel AI10 exceeds 5 V (the light-barrier is being closed during the logging).

Additional: I'm using DAQFactory Express for 2 days now, so my skills are quite limited. ;-)


Link to comment
Share on other sites

From your description, you are talking about 5 analog input channels (AI0-AI3 and AI10), but the U12 can only stream 4 analog inputs max.

First thing you need to do is connect the light barrier signal to one of the IO lines, as IO0-IO3 are also collected as part of the stream. The simplest option is if the negative of the light barrier signal can be connected to U12 ground, thus making the signal look single ended for the IO line. If that is not possible, you will have to use something to convert it from differential to single-ended. You could use the EI-1040 instrumentation amp (overkill), or use a chip like the MAX3082E. You already mentioned that the light barrier signal causes IO0 to transition between low and high, so seems like you already have this part figured out, and not sure where AI10 came into the mix.

Now, what you want to do is stream the 4 analog input channels and the 4 IO lines at the max rate of 300 scans/second. From what Azeotech is saying, you can look at the IO0 data to decide which analog input data to keep. Since you are scanning at 300 scans/second, the max latency should be about 3.3 ms for you.

Link to comment
Share on other sites

LabJack is right, unless the trigger is one of the four analog inputs, you are going to need to put the trigger on a digital signal. You can then use the pretrig command to do what you want with minimal latency (3.3ms since you are sampling at 300hz) using the digital input as the trigger.

Since you are streaming, you cannot use a non-streamed channel to trigger using the Event method I originally described. Yes, you can use it to start the stream, but once the stream starts, you aren't going to be able to read that input without stopping the stream, so you can't use the input to stop the stream. And then there is the large latency.

The other option is to stream all 4 analogs and the digital and then write some script to look for the transitions yourself. Of course this is what the pretrig function does for you, so you might as well use that.

Link to comment
Share on other sites

I forgot that I can stream only 4 channels at a time, so forget about the AI10 thing; I will trigger the logging using IO0-channel.

Maybe I could get some more detailed instructions how to set up the channels and the logging set?

That would be very helpful...


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.