Jump to content
  • 0

Understanding dwf.FDwfDigitalInSampleFormatSet()


HoWei

Question

Hi,

I need help in understanding the difference of the following commands, as it does not what I expect in example "DigitalIn_Sync.py":

     dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(8))   --> I expect to apture data only from DIN0..7

     dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16)) --> I expect to capture data only from DIN0..15

     dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(32)) --> I expect to capture data only from DIN0..23,DIO24..31

But only the second command (is default in the example), does work as expected.

I am triggering in DIN23. I tried to limit the capture inputs to DIN0..7.

Can you please help me in understanding the above command ?

 

 

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Hi @HoWei

In FDwfDigitalInStatusData the 3rd argument is byte count, for 8bit sampling use 1*samples, for 18bit 2*samples, for 32bit 4*samples.
Are you adjusting this according the sample size?

On Digital Discovery, in case the events (rising/falling edges) are limited, not continuous like rare SPI clocks use maximum sample size, otherwise last samples might remain in cache.

print("Configuring SPI spy...")
# record mode
dwf.FDwfDigitalInAcquisitionModeSet(hdwf, acqmodeRecord)
# for sync mode set divider to -1 
dwf.FDwfDigitalInDividerSet(hdwf, c_int(-1))
# 32bit per sample format
dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(32))
# noise samples
dwf.FDwfDigitalInSampleModeSet(hdwf, c_int(1)) 
# continuous sampling 
dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_int(-1))
# in sync mode the trigger is used for sampling condition
# trigger detector mask:          low &     hight   &   ( rising 	  | falling  	    )
dwf.FDwfDigitalInTriggerSet(hdwf, c_int(0), c_int(0), c_int(1<<idxClk), c_int(1<<idxClk))
# for Digital Discovery bit order: DIO24:39; with 32 bit sampling [DIO24:39 + DIN0:15]
dwf.FDwfDigitalInInputOrderSet(hdwf, c_int(1))
dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
....

	dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
	dwf.FDwfDigitalInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted))
	dwf.FDwfDigitalInStatusData(hdwf, rgdwSamples, c_int(cAvailable.value*4)) # 32bit data

 

Link to comment
Share on other sites

Hi,

sorry but I think your answer does not help me to understand it better - yes the arguments of the commands are clear. 

But what does it really mean if I set the sample format to "8" (for example) ?

Does it limit the captured input lines to DIN0..7 ?   Or does it mean something different ?

 

If I want to capture only DIN0..7, do I have to set:

      dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(8))

      dwf.FDwfDigitalInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted))

      dwf.FDwfDigitalInStatusData(hdwf, rgdwSamples, c_int(cAvailable.value*1))

I am still confused ..

 

Link to comment
Share on other sites

Please find attached the code I am using - I am capturing 30 samples.

 

This is working, when using the settings:

line 70: dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16))

line 113: dwf.FDwfDigitalInStatusData(hdwf, byref(rgwSamples, 2*cSamples), c_int(2*cAvailable.value))

The recorded output is :   1,0,3,2,1,0,3,2,1,0,3,2,.....  (as expected because I am toggling DIN0 and DIN1, triggered by DIN23)

 

But when changing these lines to:

line 70: dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(8))

line 113: dwf.FDwfDigitalInStatusData(hdwf, byref(rgwSamples, 1*cSamples), c_int(1*cAvailable.value))

The recorded output is 1,515,1,515  ... for the first 15 samples, then it 0,0,0,0 for the last 15 samples.  But I expect the same output as above.

 

 

 

 

DigitalIn_Sync.py

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...