/* This example illustrates the use of simple trigger functions with * the NIVXI library. This program starts by sourcing one of the TTL * trigger lines using the function SrcTrig(...). Next a call to * EnableTrigSense(...) is made to sensitize the CPU to triggers occuring * on a certain TTL line. Next we halt execution of the program until * we receive a trigger on the line we just enabled using the function * WaitForTrigger(...). * * See the documentation in the NI-VXI Software Reference Manual for * complete information on these functions in the chapter entitled * 'VXI Trigger Functions'. For detailed technical information on * VXI triggers, consult the National Instruments Technical Note #40 * 'Triggering with NI-VXI' available on line or through your sales * representative. */ #include "nivxi.h" #include #include #define ON 0 #define OFF 1 #define SYNC 4 main() { INT16 ret; UINT16 line = 4; UINT16 source_line = 5; UINT16 prot; printf("\nYou can run this example with VICtext. If it is not already running,"); printf("\nyou can quit this program, launch VICtext, then run this program again."); printf("\nRun the trig.log script file in VICtext by typing"); printf("\n'$ \"\\trig.log'\" at the prompt. This instructs VICtext to assert"); printf("\ntrigger line 4."); ret = InitVXIlibrary(); /* Initialize VXI library */ prot = ON; printf("Sourcing TTL Line %d\n", source_line); ret = SrcTrig (-1, source_line, prot, 10000L); /* Source a line on TTL backplane */ prot = SYNC; ret = EnableTrigSense(-1, line, prot); /* Sensitize the CPU to recognize * VXI triggers */ printf("Waiting for trigger on line %d\n", line); ret = WaitForTrig(-1, line, 30000L); /* Wait up to 30 seconds for a * trigger on the TTL line * specified in 'line'.*/ if (ret == 0) { printf("Got the Trigger!\n"); } /* When we get the trigger from the instrument (VICtext), stop driving * the 'source_line' TTL trigger */ prot = OFF; ret = SrcTrig (-1, source_line, prot, 10000L); printf("\nPress any key to exit..."); while (!kbhit()); ret = CloseVXIlibrary(); return 0; }