/**************************************************************************** * CollectBlockEts * this function demonstrates how to collect a block of * data using equivalent time sampling (ETS). ****************************************************************************/ void CollectBlockEts() { int ets_sampletime; short triggerVoltage = mv_to_adc(100, (short)_channelSettings[(int)Imports.Channel.ChannelA].range); // ChannelInfo stores ADC counts Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] { new Imports.TriggerChannelProperties(triggerVoltage, triggerVoltage, 10, Imports.Channel.ChannelA, Imports.ThresholdMode.Level) }; Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] { new Imports.TriggerConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare) }; Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None }; Console.WriteLine("Collect ETS block..."); Console.WriteLine("Collects when value rises past {0}mV", adc_to_mv(sourceDetails[0].ThresholdMajor, (int)_channelSettings[(int)Imports.Channel.ChannelA].range)); Console.WriteLine("Press a key to start..."); WaitForKey(); SetDefaults(); /* Trigger enabled * Rising edge * Threshold = 1500mV * 10% pre-trigger (negative is pre-, positive is post-) */ short status = SetTrigger(sourceDetails, 1, conditions, 1, directions, null, 0, 0, 0); Console.WriteLine("Set Trigger : {0}", status); /* Enable ETS in fast mode, the computer will store 100 cycles but interleave only 10 */ status = Imports.SetEts(_handle, Imports.EtsMode.Fast, 20, 4, out ets_sampletime); Console.WriteLine("Set ETS : {0}", status); Console.WriteLine("ETS Sample Time is: {0}", ets_sampletime); BlockDataHandler("Ten readings after trigger", BUFFER_SIZE / 10 - 5); // 10% of data is pre-trigger }
/**************************************************************************** * CollectBlockTriggered * this function demonstrates how to collect a single block of data from the * unit, when a trigger event occurs. ****************************************************************************/ void CollectBlockTriggered() { short triggerVoltage = mv_to_adc(100, (short)_channelSettings[(int)Imports.Channel.ChannelA].range); // ChannelInfo stores ADC counts Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] { new Imports.TriggerChannelProperties(triggerVoltage, triggerVoltage, 256 * 10, Imports.Channel.ChannelA, Imports.ThresholdMode.Level) }; Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] { new Imports.TriggerConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare) }; Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None }; Console.WriteLine("Collect block triggered..."); Console.WriteLine("Collects when value rises past {0}mV", adc_to_mv(sourceDetails[0].ThresholdMajor, (int)_channelSettings[(int)Imports.Channel.ChannelA].range)); Console.WriteLine("Press a key to start..."); WaitForKey(); SetDefaults(); /* Trigger enabled * Rising edge * Threshold = 100mV */ SetTrigger(sourceDetails, 1, conditions, 1, directions, null, 0, 0, 0); BlockDataHandler("Ten readings after trigger", 0); }
/**************************************************************************** * CollectStreamingTriggered * this function demonstrates how to collect a stream of data * from the unit (start collecting on trigger) ***************************************************************************/ void CollectStreamingTriggered() { short triggerVoltage = mv_to_adc(100, (short)_channelSettings[(int)Imports.Channel.ChannelA].range); // ChannelInfo stores ADC counts Imports.TriggerChannelProperties[] sourceDetails = new Imports.TriggerChannelProperties[] { new Imports.TriggerChannelProperties(triggerVoltage, triggerVoltage, 256 * 10, Imports.Channel.ChannelA, Imports.ThresholdMode.Level) }; Imports.TriggerConditions[] conditions = new Imports.TriggerConditions[] { new Imports.TriggerConditions(Imports.TriggerState.True, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare, Imports.TriggerState.DontCare) }; Imports.ThresholdDirection[] directions = new Imports.ThresholdDirection[] { Imports.ThresholdDirection.Rising, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None, Imports.ThresholdDirection.None }; Console.WriteLine("Collect streaming triggered..."); Console.WriteLine("Data is written to disk file (test.out)"); Console.WriteLine("Press a key to start"); WaitForKey(); SetDefaults(); /* Trigger enabled * Rising edge * Threshold = 100mV */ SetTrigger(sourceDetails, 1, conditions, 1, directions, null, 0, 0, 0); StreamDataHandler(100000); }