Jump to content
  • 0

DigiDisco-Logic: undefined delay between trigger and capturing


HoWei

Question

I do use the DigitalDiscovery logic analyzer to capture data from an ADC. I trigger the capturing via a rising edge at DIN15.

The timing diagram looks always the same like this:

Blue is the trigger for the logic analyzer /  Yellow indicates the ADC clock / Red is the sampled data

image.thumb.png.c8eea45fcd4e40c2acecef8fb632259e.png

The ADC transmits the data serially (via 2 wires) to the DigiDisco-Logic inputs. After the transmission I decode the data, starting from sample one and plot the ADC sampled data.

What I expect is a plot like this - starting with 01010101011111....

image.png.4a070131a6a85d3ac7a3944cdcf26551.png

What I get is different for each capture as shown below.:

- It seems like the trigger or start of capturing has a certain variation or delay.

- It is capturing data BEFORE! the trigger signal occurs

- I am sampling with 400MHz the DigiDisco DIN channels, this means there are more than 100 samples taken BEFORE! the trigger is coming.

Is this delay/variation expected ?

image.png.ef588046bac23bfc2807be2574287dc2.png

image.png.908ac439dd4e5ada6a8497b7c3be6870.png

image.png.4974d018c3c934756928e6c28826ddaf.png

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

Hi @attila,

I have setup a small test comparing Waveforms vs. my python script.  The setup is very simple:

- DIO39 connected to DIN15 (This is the trigger for the record-capture)

- DIO32 connected to DIN11 (this is the testsignal to capture)

The DIO39 (blue) shall trigger the record-mode capturing and the DIO32 (yellow) provides some samples. The signal look like this:

image.png.aaab96a675d6b5f38f14b86c53975d7b.png

In Waveforms GUI it is working as expected IF I set the trigger mode to "normal".

If the trigger mode is set to "auto", I will always receive 0s - why is that ?

image.thumb.png.ac18904fee7da43e48661137ffc80e92.png

In my python script I always receive 0s - what is the command to set the "normal" mode for triggering via SDK in python ?

Thanks !

 

Link to comment
Share on other sites

I tried to set dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, c_double(0.0)), which (according to the SDK docu) sets the normal trigger - but no effect !

How is the digital threshold set for the DIN pins ?

On DIN0..9 I do have CMOS Level inputs 0..3V, but DIN15 and DIN11 are from the 1.8V DigiDisco outputs.

Could it be that the threshold is too low to detect the high levels for DIN11 ?

But why does the DIN15 trigger then ?

 

Edit: It cannot be the amplitude or threshold because I can capture a clock signal with 0.9V amplitude !

Thus leaves the problem that I cannot trigger in "normal" mode in python !

Could you please provide a short example for "normal" trigger in record-mode?

Link to comment
Share on other sites

Attached please find the script, where I try to capture in record mode with "normal" trigger - I do not capture the expected signal.

But the oscilloscope shows that the testsignal on DIN11 is available immediately after the trigger-signal on DIN15 comes.

from ctypes import *
from dwfconstants import *
import math
import sys
import time
import matplotlib.pyplot as plt
import numpy as np
import digilent as dig

	
##################
#MAIN
##################

#init first Digilent device found 
#and set output voltage to 1.8V
dwf, hdwf = dig.initDevice(1.8)
time.sleep(0.1)

dwf.FDwfDigitalIOReset(hdwf)

#get internal clock frequency
hzDO = c_double() 
dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzDO))
print("Internal frequency is " + str(hzDO.value/1e6)+" MHz")


cap_trig = 15 # DIO15 Pin39
#################################################################################################
# Configure capture trigger output - will toggle only once before first valid sample is available
#################################################################################################
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(cap_trig), c_int(1))						#set to output
dwf.FDwfDigitalOutTypeSet(hdwf, c_int(cap_trig), DwfDigitalOutTypeCustom)			#Custom type for single edge
dwf.FDwfDigitalOutOutputSet(hdwf, c_int(cap_trig), DwfDigitalOutOutputPushPull)		#drive output load

dwf.FDwfDigitalOutIdleSet(hdwf, c_int(cap_trig), DwfDigitalOutIdleLow)
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(cap_trig), c_int(int(hzDO.value/20e6)))	# 20MHz 

dat_cap_trig = c_int(1)																# send only one rising edge
dwf.FDwfDigitalOutDataSet(hdwf, c_int(cap_trig), byref(dat_cap_trig), c_int(1))		

data = 8 #DIO8 Pin32
#################################################################################################
# Configure data output - will send 01010110
#################################################################################################
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(data), c_int(1))						#set to output
dwf.FDwfDigitalOutTypeSet(hdwf, c_int(data), DwfDigitalOutTypeCustom)			#Custom type for single edge
dwf.FDwfDigitalOutOutputSet(hdwf, c_int(data), DwfDigitalOutOutputPushPull)		#drive output load

dwf.FDwfDigitalOutIdleSet(hdwf, c_int(data), DwfDigitalOutIdleLow)
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(data), c_int(int(hzDO.value/20e6)))	# 20MHz 

data_send = (1*c_int)(0x65)											
dwf.FDwfDigitalOutDataSet(hdwf, c_int(data), byref(data_send), c_int(8))		


########################################
#set DIO output runlength and repetition
########################################
dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(1)) # only once



######################################################################################################################################################################################
# Configure DIN data capture
######################################################################################################################################################################################


# set number of sample to acquired by DigiDisco
nSamples = int(1000)
print("nSamples =",nSamples)


# set number of sample to acquire
#nSamples = 1200000
rgwSamples = (c_uint16*nSamples)()
cAvailable = c_int()
cLost = c_int()
cCorrupted = c_int()
cSamples = 0
fLost = 0
fCorrupted = 0

hzDI = c_double()
dwf.FDwfDigitalInInternalClockInfo(hdwf, byref(hzDI))
print("DigitalIn base freq: "+str(hzDI.value))


dwf.FDwfDigitalInAcquisitionModeSet(hdwf, acqmodeRecord)	# record mode
dwf.FDwfDigitalInDividerSet(hdwf, c_int(int(hzDI.value/400e6)))	 #400MHz

# 16bit per sample format from DIN0..DIN15
dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16))

#define trigger pin DIN
trigDIN = 15

#set trigger source 
dwf.FDwfDigitalInTriggerSourceSet(hdwf, c_int(3)) #3=trigsrcDetectorDigitalIn see SDK docu
# number of samples 
dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_int(nSamples))
dwf.FDwfDigitalInTriggerPrefillSet(hdwf, 0)		#no prefill
dwf.FDwfDigitalInTriggerSet(hdwf, c_int(0), c_int(0), c_int(1<<trigDIN), c_int(0))  #rising-edge on pin trigDIN
#dwf.FDwfDigitalInTriggerLengthSet(hdwf,0,0,0)


#trying to set trigger mode "normal"
autotimeout = c_double()
dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, c_double(0.0))
dwf.FDwfDigitalInTriggerAutoTimeoutGet(hdwf, byref(autotimeout))
print("Autotimeout:",autotimeout)

psecmin = c_double()
psecmax = c_double()
pnsteps = c_double()
dwf.FDwfDigitalInTriggerAutoTimeoutInfo(hdwf, byref(psecmin), byref(psecmax),byref(pnsteps))
print("AutoTriggerInfo:", psecmax, psecmin, pnsteps)


#####################################################################################################################################################
# Activate DIN capture and DIO output
#####################################################################################################################################################

# begin acquisition
dwf.FDwfDigitalInConfigure(hdwf, c_bool(1), c_bool(1))
print("Starting record...waiting for trigger on DIN", trigDIN)

time.sleep(3)   #wait some time before triggering


# activate the DIO outputs
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))								#start the DIO device  (non-blocked outputs only)
print("Starting data transmission ...")

#check successfull acquisition
sts = c_byte()
while cSamples < nSamples:
    dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
    if cSamples == 0 and (sts == DwfStateConfig or sts == DwfStatePrefill or sts == DwfStateArmed) :
        # acquisition not yet started.
        continue
    dwf.FDwfDigitalInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted))
    cSamples += cLost.value
    if cLost.value :
        fLost = 1
    if cCorrupted.value :
        fCorrupted = 1

    if cAvailable.value==0 :
        continue

    if cSamples+cAvailable.value > nSamples :
        cAvailable = c_int(nSamples-cSamples)
    
    # get samples
    dwf.FDwfDigitalInStatusData(hdwf, byref(rgwSamples, 2*cSamples), c_int(2*cAvailable.value))
    cSamples += cAvailable.value

	
time.sleep(3) # as long as the device are not closed the voltage output is available
dwf.FDwfDeviceCloseAll()


print("   done")
if fLost:
    print("Samples were lost! Reduce sample rate")
if cCorrupted:
    print("Samples could be corrupted! Reduce sample rate")

f = open("record.csv", "w")
for v in rgwSamples:
    f.write("%s\n" % v)
f.close()


#filter samples by signal
fclk = np.zeros(nSamples)
dclk = np.zeros(nSamples)
datA0 = np.zeros(nSamples)
datA1 = np.zeros(nSamples)
datB0 = np.zeros(nSamples)
datB1 = np.zeros(nSamples)
datC0 = np.zeros(nSamples)
datC1 = np.zeros(nSamples)
datD0 = np.zeros(nSamples)
datD1 = np.zeros(nSamples)
testData = np.zeros(nSamples)
trigIN = np.zeros(nSamples)


#filter each signal with logic AND from rgwsamples
#and then shift to right end
for i in range(nSamples):
	fclk[i]=int(rgwSamples[i] & 0x01)			#fclk=DIN0
	dclk[i]=int((rgwSamples[i] & 0x02) >>1 )	#dclk=DIN1
	datA0[i]=int((rgwSamples[i] & 0x04) >>2	)	#datA0=DIN2
	datA1[i]=int((rgwSamples[i] & 0x08) >>3	)	#datA1=DIN3
	datB0[i]=int((rgwSamples[i] & 0x10) >>4	)	#datB0=DIN4
	datB1[i]=int((rgwSamples[i] & 0x20) >>5	)	#datB0=DIN5
	datC0[i]=int((rgwSamples[i] & 0x40) >>6 )	#datC0=DIN6
	datC1[i]=int((rgwSamples[i] & 0x80) >>7 )	#datC0=DIN7
	datD0[i]=int((rgwSamples[i] & 0x100) >>8 )	#datD0=DIN8
	datD1[i]=int((rgwSamples[i] & 0x200) >>9 )	#datD0=DIN9
	testData[i]=int((rgwSamples[i] & 0x800) >>11 )	#trigIN=DIN11
	#trigIN[i]=int((rgwSamples[i] & 0x8000) >>15 )	#trigIN=DIN15

	

#plt.plot(fclk,'b')
plt.plot(testData,'r')
plt.show()	









 

Link to comment
Share on other sites

I tried setting "dwf.FDwfDigitalInTriggerSourceSet(hdwf, trigsrcDigitalOut)" as trigger source as recommended in :

image.png.2cdb1a4969c639f0f8f0e0d6e00dbb51.png

 

But no success - still receiving all 0s.  I cannot even identify the trigger time point.

Whenever a continous signal is applied I capture the signal. But a signal starting at the same time as the trigger is not captured  ???

 

Link to comment
Share on other sites

Hi @attilla,

I found that I do have to set the input buffer size "dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(nSamples))" to capture the signal.

What happens if I do not set this buffer size ?

If this buffer size is not set -  why does it capture a constant clock signal but not a signal coming at the trigger time ?

Can you please explain the difference ?

 

Another question is why it work in WaveformGUI "record" mode, but in the script I need to use "single" mode (which is not available in WaveformGUI ) ?

Whats the difference ?

 

Link to comment
Share on other sites

Hi @HoWei

The repeated mode in GUI is the same as single in SDK.

The buffer size is used in single/repeated, scan screen/shift capture modes.
For single/repeated use 
FDwfDigitalInBufferSizeSet and FDwfDigitalInTriggerPositionSet.

In the device ddram the samples are stored in 64bit words. With 16bit sampling the trigger can be in 4 positions in this word.
The single/repeated mode aligns returned samples to have stable trigger position.

The record mode may use streaming of data, started before trigger event so the trigger position can vary based on sample size, 64bit_words/sample_size.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...