« Close

Datasheets and User Guides

App Notes

Software & Driver

 

3.2.1 - External Triggering

The internal scan clock normally initiates each scan in stream mode. Optionally, an external pulse (falling edge) on the Counter1 FIO line can initiate each scan. In the low level StreamConfig function, this is enabled by setting bit 6 of byte 9. In the LabJackUD Windows driver this is controlled with the put_config special channel LJ_chSTREAM_EXTERNAL_TRIGGER.

One application of external triggering is for synchronized streaming from multiple devices. In such a case, set bit 7 of byte 9 on the main unit to enable scan pulse output. In the LabJackUD Windows driver this is controlled with the put_config special channel LJ_chSTREAM_CLOCK_OUTPUT. The main unit will then use the internal scan clock to initiate each scan, and output a pulse per scan on the Counter1 FIO line. The output is normally high, goes low at the beginning of each scan, and stays low for about 6 microseconds. All other synchronized units are then configured for an external scan trigger.

Something that could be useful is the ability to define a scan with multiple samples from the same channel. So for instance, a scan could be defined as channels 0/1/0/1/0/1 or 0/0/1/1 or whatever. This can provide a small burst of samples for each external trigger. The scan list can have up to 128 channels. When using the LabJackUD driver, duplicate channels in a scan only works if reading all channels simultaneously, as channel-by-channel stream reads are specified by channel number.

One thing to consider when using external triggering is the buffering that takes place within the UE9 and PC. If the external signal is fairly continuous, such as in synchronized streaming, this is not a problem, but if the external trigger is more of a one-time pulse the buffering must be considered to get the data when desired. For instance, each UE9 stream data packet contains 16 samples, so if there is only 1 sample per scan the UE9 will not send any data until it has accumulated 16 scans. Some applications might resolve this by defining each scan as 16 samples, even if it is just 16 samples of the same channel (see previous paragraph). Another buffering issue will come into play if the LabJackUD driver is used with USB communication, as the driver reads 4 packets at a time (64 samples).

Streaming always uses Counter1 internally, and thus Counter1 is not available for counting while streaming. Additionally, if clock output or external triggering is enabled, the normal Counter1 FIO line will be claimed, which is the next FIO available after all other enabled timers/counters. If no other timers/counters are enabled, FIO0 will be used for stream clock output or input.

When using external stream clock output or input, the timer/counter configuration should not be changed after starting the stream, as that could cause a glitch or could even cause the Counter1 FIO pin number to change.

Enabling clock output causes the FIO line to be set to output when the configuration command is executed, but the clock output will not actually begin until the stream is started. Enabling clock input causes the FIO line to be set to input when the configuration command is executed, but interrupts will not occur until the stream is started.

Note that external triggering causes 1 scan per trigger pulse. It is not used where a single pulse starts a continuous stream or a burst of multiple scans, as that type of trigger is better handled in software. In software, an arbitrarily complex set of trigger conditions can be watched for in continuous stream data, and when the trigger occurs the software can “keep” a specified number of scans, “keep” all scans while the trigger is true, or whatever other behavior is desired. In addition, the software can maintain a history buffer and “keep” a specified number of scans before the trigger (pre-trigger scans). Since stream data can consist of analog, digital, and timer/counter inputs, the trigger conditions can use any or all of those.

8 comments

Hi,

we're trying to get an UE9 to work on Linux with external triggering. The documentation is a little overwhelming, could you give us a hint how to start? We had hoped to use the easy functions, but couldn't find any code examples, even for the low level access.

Thanks in advance!

Michael

What language are you using?  Did you find a basic (internally triggered) stream example to start from?

We're using C. We got untriggered analog input to work based on ue9EFunctions.c.

Now that you're asking, I guess we should have looked at ue9Stream.c?

Yes, ue9EFunctions is using command/response mode, which is software triggered.  You want to start with a normal stream example, then try to change it to use external triggering rather than the normal internal clock triggering.  That just means some changes in what you pass for StreamConfig.  You want to set bit 6 of byte 9.

Note that the external trigger comes in on Counter1.  Counter1 will appear on FIO0, if no other timers or counters are enabled.

OK, we'll try that. Thanks a lot for your quick feedback!

Hi,
I started with the stream example in the exodriver/examples/UE9/ue9Stream.c directory.

My goal will be reading in as much as possible analog inputs, with a resolution of 16 bit, triggered by an external source connected to FI0O.  The trigger rate will be around 10 Hz and I only need one value per trigger of each channel. As I understood the USB communication the host is reading packages of 192 Byte I was thinking of sample each channel more than one time to receive the data after each sample...

***post edited***

You post had too much detail for a comment in the user's guide, so edited it and just left your intro.  Please continue this on our forum or send an email to [email protected].  I did save all the content from your post as a support draft in our system, if you need it.

A few comments:

    - From Table 3.2-1, the maximum stream sample rate at Res=16 is 250 samples/s.  So for example, if you are streaming 5 channels, the maximum scan rate would be 50 scans/second.

    - I would do initial testing using the internal scan clock set to 10Hz.  Then when you program seems to work right with all the settings you want try switching to an external clock.

    - If you can't the time between large chunks of data coming in, then you do need to think about the 64 samples per chunk issue mentioned in Section 2.1.  For example, if you want to scan 4 channels at 10 Hz and get each scan as fast as possible, I would scan at 160 Hz so you will get a chunk with 16 scans at 10 Hz.  Note that this is a sample rate of 640 Hz so Res=15 is the highest resolution index you can use.

To comment further on your edited post, I fixed the seg. fault issue in the ue9Stream example.  You can set NUM_CHANNELS (I changed the name from NumChannels) to a value between 1-16 without issue.   It is available on the github.

As for "Error : read failed (StreamData).", power cycle your UE9 and try the updated example.  See if that helps it run again.