3.2.1 - External Triggering [UE9 Datasheet]
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.