Jump to content
  • 0

Reprogramming on SDK


eric_A

Question

Currently using the SDK with Python on Windows, I took time to compare the Waveform software and the SDK. Everything possible on the first is possible on the second one.

Almost everything.

 

I couldn't find a way to start the device (Analog Discovery) with another configuration.

I tried to disable the Scope and the AWG, then to ask the maximum buffer size, but I always get 4096.

 

Is it hidden in the dwf.h, dwf.lib or dwf.dll ?

Any advice is welcome.

Thanks.

 

From the help :

Configurations: Select the configuration you want to use for the selected device. The configurations have different device buffer-memory distributions for the instruments and other capabilities, like number of pins or channels.

 

From the Wiki :

Default Pattern Generator buffer size is 1kSamples/channel. The WaveForms Device Manager (WaveForms Main Window/Device/Manager) provides alternate FPGA configuration files, with different resources allocation. With no memory allocated to the Scope and AWG, the Pattern Generator buffer size can be chosen to be 16kSamples/channel.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

In a newer, not yet released version the FDwfDeviceConfigOpen lets you choose the device configuration.

You can find the installer for this in private message.

 

In case you need the SDK for other platforms too, please send an email to waveforms at digilentinc dot com

Link to comment
Share on other sites

In a newer, not yet released version the FDwfDeviceConfigOpen lets you choose the device configuration.

You can find the installer for this in private message.

 

In case you need the SDK for other platforms too, please send an email to waveforms at digilentinc dot com

 

Great, I installed SDK 2.8.9 and the new function works.

The 4th configuration is the one I wanted, with 16k buffers for digital instruments.

dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf) )

 

 

I can successfully send 16384 bits in the pattern, but when I tried the Analyser ...

 

runfile('C:/Users/CTO/Documents/Adisco/SDK/ADC/DigitalIn_Test.py', wdir=r'C:/Users/CTO/Documents/Adisco/SDK/ADC')
16384
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:Anacondalibsite-packagesspyderlibwidgetsexternalshellsitecustomize.py", line 580, in runfile
    execfile(filename, namespace)
  File "C:/Users/CTO/Documents/Adisco/SDK/ADC/DigitalIn_Test.py", line 92, in <module>
    dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
WindowsError: exception: integer divide by zero

 

I'm running Win8 x64 i7. I've seen most "WindowsError" that divides by zero are related to AVbin for audio compression, but it doesn't make any sense to me ...

 

Is this SDK in Beta version as well ?

Thank you

Link to comment
Share on other sites

Looking at the SDK source code of FDwfDigitalInStatus, the only possible division I see when the buffer size is zero. Make sure to set this to a non zero value by FDwfDigitalInBufferSizeSet.

Let me know if this solves the problem.

 

Yes, this software version including the SDK is not yet publicly released, so it is beta.

Link to comment
Share on other sites

As soon as I use dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf) ), instead of dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)), even a buffer size below 4096 make it send the same error.

My current setup is :

 

### Setup DigitalIn

cSamples = 4000 

rgwSamples = (c_uint16*cSamples)()

dwf.FDwfDigitalInDividerSet(hdwf_B, c_int(1)) 

dwf.FDwfDigitalInSampleFormatSet(hdwf_B, c_int(16)) 

dwf.FDwfDigitalInBufferSizeSet(hdwf_B,c_int(cSamples))

dwf.FDwfDigitalInTriggerSourceSet(hdwf_B,trigsrcExternal1) 

dwf.FDwfDigitalInTriggerPositionSet(hdwf_B,c_uint(cSamples)) 

 

If I could unleash the 16k buffer, it would save my measurements. Thanks for your help.

Regards,

Eric

Link to comment
Share on other sites

The only way I could get division by zero error is when having scan screen more and buffer size zero, but this is an incorrect configuration:

from ctypes import *
import sys
import time

if sys.platform.startswith("win"):
    dwf = cdll.dwf
elif sys.platform.startswith("darwin"):
    dwf = cdll.LoadLibrary("libdwf.dylib")
else:
    dwf = cdll.LoadLibrary("libdwf.so")

hdwf = c_int()
sts = c_byte()
cSamples = 0
rgwSamples = (c_uint16*cSamples)()

dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf))

dwf.FDwfDigitalInAcquisitionModeSet(hdwf, c_int(2)) #scan screen
dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))

dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))
time.sleep(1)
dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
With normal configuration, acquisition of 16k digital samples it is working:
from ctypes import *
import sys
import time

if sys.platform.startswith("win"):
    dwf = cdll.dwf
elif sys.platform.startswith("darwin"):
    dwf = cdll.LoadLibrary("libdwf.dylib")
else:
    dwf = cdll.LoadLibrary("libdwf.so")

hdwf = c_int()
sts = c_byte()
cSamples = 16*1024
rgwSamples = (c_uint16*cSamples)()

# open 3rd configuration with 16k digital buffer
dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf))

# start a binary counter to test the acquisition
for i in range(0, 16):
    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(i), c_int(1))
    dwf.FDwfDigitalOutDividerSet(hdwf, c_int(i), c_int(1<<i))
    dwf.FDwfDigitalOutCounterSet(hdwf, c_int(i), 1, 1)
dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))

# configure logic analyzer
dwf.FDwfDigitalInDividerSet(hdwf, c_int(1)) 
dwf.FDwfDigitalInSampleFormatSet(hdwf, c_int(16)) 
dwf.FDwfDigitalInBufferSizeSet(hdwf, c_int(cSamples))
dwf.FDwfDigitalInTriggerPositionSet(hdwf, c_uint(cSamples)) 
dwf.FDwfDigitalInConfigure(hdwf, c_bool(0), c_bool(1))

# wait to finish
while True:
    dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts))
    if sts.value == 2 : # done
        break

# get data
dwf.FDwfDigitalInStatusData(hdwf, rgwSamples, 2*cSamples)

dwf.FDwfDeviceCloseAll()

# save data
f = open("acq.csv", "w")
for v in rgwSamples:
    f.write("%sn" % v)
f.close()

Let me know it this helps.

 

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...