Jump to content
  • 0

Why can't I get AD2 to trigger using the SDK?


zimbot

Question

I'm sure the answer must be that I totally misunderstood something or failed to set some setting, but I've spent days on this and can't figure it out.

I'm using the WaveFormsSDK via C-sharp from a server (what will be a calibration service) to be controlled by a client, currently trying to get surge pulses to trigger an acquisition on AnalogIn (first channel).  I can make it work just fine in WaveForms, so I know that the signal path is okay, the settings reasonable, etc.  I've tried to set up all the configuration settings that I can find that seem relevant, and I have taken a day and half to write enough code to pull that configuration information back out and report it, just so I can debug this.  But I can't find what is wrong/missing.  Can you?

I will attach a text file that includes some edited logged information showing [almost] each call to the API (all return true, so all show "ok"), plus additional application-level information.  But the core of it is that these are the settings I have for the AnalogIn instrument, and yet it will not trigger. 

			"AnalogInAcquisitionMode": "Single1",
			"AnalogInFrequency": "33333333.333333332 Hz",
			"AnalogInNoiseSize": "0 samples",
			"AnalogInBufferSize": "16384 samples",
			"AnalogInSamplingSource": "None",
			"AnalogInSamplingSlope": "Rise",
			"AnalogInSamplingDelay": "0 sec",
			"AnalogInChannelCount": "2",
			"AnalogInChannel0Enabled": "True",
			"AnalogInChannel0Filter": "Average",
			"AnalogInChannel0Range": "5.5676941275276715 V",
			"AnalogInChannel0Offset": "0.0001293024264681572 V",
			"AnalogInChannel0Attenuation": "1 (externally applied attenuation -- samples are divided by this factor)",
			"AnalogInTriggerSource": "AnalogIn (NORMAL)",
			"AnalogInTriggerAutoTimeout": "0 sec",
			"AnalogInTriggerPosition": "0.00046080000000000003 sec",
			"AnlogInTriggerHoldOff": "0 sec (between start and the possibility of triggering)",
			"AnalogInTriggerType": "Edge",
			"AnalogInTriggerChannel": "0",
			"AnalogInTriggerFilter": "Average",
			"AnalogInTriggerCondition": "Fall",
			"AnalogInTriggerLevel": "-1.74999656965822 V (at scope) * 1000 == -1749.99656965822 V (at DUT)",
			"AnalogInTriggerHysteresis": "0 V",
			"AnalogInTriggerLengthCondition": "More",
			"AnalogInTriggerLength": "1E-08 sec",
			"AnalogInStatus": "Ready",
			"AnalogInStatusSamplesLeft": "0",
			"AnalogInStatusSamplesValid": "0",
			"AnalogInStatusIndexWrite": "0" 

The pulses are negative, so I look for falling edge below an amount well under 1/2 of the strongest level (they reach about -4V since this is coming from a high voltage probe with 1000:1 attenuation and probing an impulse of about 4000V).  Given the application, I have tried using both Single and Single1 as the acquisition mode.  I've varied several other things to no avail.  I started out with the default device configuration which uses 8192 sample buffer size, but then switched to another configuration when I noticed it had twice as many samples in that buffer.  If I give an auto-trigger time-out of 0 (no time-out), then the status just stays "Armed" forever.  If I give it a reasonable time-out, then it always just times out and gives me an acquired waveform that is always somewhere between my pulses (and thus useless).  I believe the weird values for Range and Offset must be due to the devices from-factory calibration (they were set to 5 and 0).

 

Any clues?

untriggerable.txt

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

Hi @zimbot

1. The trigger source should be set to trigsrcDetectorAnalogIn = 2
FDwfAnalogInTriggerSourceSet(hdwf, 2)

2. In order to have 16k sample buffer for Scope make sure to open the device with the 2nd configuration, 1 with 0 based indexing.
FDwfDeviceConfigOpen(-1, 1, &hdwf)

3. With 33MHz and 16k samples you will have 491.52us captures. The trigger position is relative to the middle of the capture.
In order to have the trigger position at left set FDwfAnalogInTriggerPositionSet to 245.76us.
With higher value the trigger will be 'outside of the capture on the left side'

image.thumb.png.eb055e51c3d8353552df3bc7e59a09e9.png

image.thumb.png.7d030b16dd1fc18157192ecf65fc244e.png

Link to comment
Share on other sites

Thanks.

I am doing all those steps.  As shown in the log I provided (when logging API calls, I only record arguments of interest, not the device handle)...

      opening enumerated device 0: 'Analog Discovery 2' SN='SN:210321AD97C9' (best config = 1 with AnalogInBufferSize of 16384)
      FDwfDeviceConfigOpen(0,1) ok

... confirmation:

            "SupportedBufferSizeRange": "[16,16834] samples",

By the way, I had started out working with the default configuration (0) with 8192 sample buffer size.  The behavior is the same either way in that I cannot get it to trigger.

Then to set up the AnalogIn device, the various API calls include these:

      FDwfAnalogInTriggerSourceSet(analogIn) ok
      FDwfAnalogInTriggerPositionSet(0.00023039989184070464) ok

that makes ~230 usec, which is just a bit less than the amount you suggested for far-left alignment (491.52usec), because I need to allow a bit of margin to the left of the trigger to show the rising pulse prior to reaching trigger level.  However, the step size is quantized a bit, so you can see a slightly different value resulted (below), but 460 < 491 and should still put the pulse within the viewable (captured) window.  Confirmation:

            "AnalogInTriggerSource": "AnalogIn (NORMAL)",
            "AnalogInTriggerPosition": "0.00046080000000000003 sec"

(NORMAL vs AUTO in that first logged line comes from looking at the AnalogInTriggerAutoTimeout value).

Had the setting for the position been wrong, I might capture a signal only after it had decayed, which would be unfortunate.  But that isn't what is happening.  instead, the device never triggers (at all) for me with these settings.  It stays in state Armed until the time-out occurs, despite dozens of opportunities to trigger when the voltage should be reaching -4V at the initial impulse.

 

I can get it to trigger with the WaveForms program using similar settings, but not using these API calls from my own program.  So I know it's possible.  The question remains:  what else is required that I might be missing?

Link to comment
Share on other sites

By the way,  I had hoped I could use my code's query-and-log capability to find out what the settings are when WaveForms is working (that is, while triggering works).  But it appears that the dwf library or device driver will not allow more than one process to access the device at the same time.  Somehow, between WaveForms shutting down (and closing the device), and my program opening and querying it, all of the settings get reset to defaults.  So I have not had any success at finding out what WaveForms does differently from my program.

Link to comment
Share on other sites

Hi @zimbot

It seems to me you are using analog-in as trigger source, which indicates the analog-in instrument state, so the instrument waits for itself...
Use the 'DetectorAnalogIn' as trigger source, value 2

7 hours ago, attila said:

1. The trigger source should be set to trigsrcDetectorAnalogIn = 2
FDwfAnalogInTriggerSourceSet(hdwf, 2)

 

Link to comment
Share on other sites

Aha, I knew it had to be some sort of stupidity on my part!  I never even noticed the distinction.

I'll try that as soon as I finish recovering my disk from a failed attempt at moving and resizing my partition.  ?

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...