I am developing python script to send custom data on pattern generator and receive it on logic analyzer and then do data integrity check (as of now dumping the data to csv file and later need to modify to compare the data).
when run the Python script (see below) , I see all '0' in csv file.
Appreciate if anybody provide me insight on how to achieve this task.
Question
Venkat
Hi,
I am new user of DD.
I am developing python script to send custom data on pattern generator and receive it on logic analyzer and then do data integrity check (as of now dumping the data to csv file and later need to modify to compare the data).
when run the Python script (see below) , I see all '0' in csv file.
Appreciate if anybody provide me insight on how to achieve this task.
Below is pattern generator related code:
channel = 0
dwf.FDwfDigitalOutEnableSet(hdwf, channel, c_int(1))
dwf.FDwfDigitalOutTypeSet(hdwf, channel, DwfDigitalOutTypeCustom)
cBits = 16
rgdData = (2*c_byte)(*[0x12,0x34])
dwf.FDwfDigitalOutDataSet(hdwf, channel, byref(rgdData), c_int(cBits))
dwf.FDwfDigitalOutRunSet(hdwf, c_double(2*8/1e8)) # 160ns = 2*8 bits /100MHz = 16 bits * 10ns
dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(1)) # once
print('PG Setup Done: Channel ',channel)
And below is Logic Analyzer related code:
dwf.FDwfDigitalInTriggerSourceSet(hdwf, trigsrcDigitalIn)
dwf.FDwfDigitalInTriggerSet(hdwf, 0,0,0xFFFF,0xFFFF);
dwf.FDwfDigitalInTriggerAutoTimeoutSet(hdwf, c_double(10.0));
#sample rate = system frequency / divider, 800MHz/8 = 100MHz sample rate
dwf.FDwfDigitalInDividerSet(hdwf, c_int(8))
# 16bit per sample format
dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16))
# set number of sample to acquire
cSamples = 16
#rgwSamples = (c_uint16*cSamples)()
rgwSamples = (c_uint8*cSamples)()
dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))
Both LA and PG are configured:
# begin acquisition # Enable LA
dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
# Enable PG
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
Below is Acquisition code:
while True:
dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
print ('STS VAL: ', str(sts.value))
if sts.value == stsDone.value :
break
time.sleep(1)
print ('Acquisition finished')
And below is read data code:
# get samples, byte size
#dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, 2*cSamples)
dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, 1*cSamples)
dwf.FDwfDeviceCloseAll()
For the time being writing to csv file:
f = open("record.csv", "w")
for v in rgwSamples:
f.write("%s\n" % v)
f.close()
Regards,
Venkat
digilent_examp.py
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.