Jump to content
  • 0

Waveforms sdk for Labview obtaining data issue


Chris

Question

Hi,

I am using Labview to create a pattern generator and logic analyzer on the Analog Discovery Kit using the waveforms sdk dll. At the minute the pattern generator is functioning and I am using it to send data to a second discovery kit to test the logic analyzer. I am having issues acquiring the acquisition data when using the FDwfDigitalInStatusData node, when transmitting 0xFF, I read back 0x6 or 0x9 depending on the trigger position setting. I am only interested in the data after the trigger, I have scourged the internet trying to find a solution with no luck, I have a feeling I am miss using the FDwfDigitalInTriggerPositionSet node, any feedback on what the correct trigger position and reason for incorrect data would be great :)

Data is arriving at 1MHz, the frequency of the analyzer is setup at 2MHz to prevent aliasing

Using a 32bit sample format and triggering on a rising edge

Single Acquisition Mode with the buffer set anywhere between 100-300

Unsure on placement of trigger position to receive data

Thanks Guys,

Chris

Link to comment
Share on other sites

19 answers to this question

Recommended Posts

The DigitalInTriggerPositition specifies the number of samples to acquire after trigger (cSamplesAfterTrigger).
In case you are interested only in samples after trigger, set it equal to the DigitalInBufferSize. Which on Analog Discovery is by default 4096.

Link to comment
Share on other sites

I've now managed to access all of the data samples captured.
To access all the captured samples:
An array of the same size as the number of samples has to be passed into the 'rgData' input parameter of DigitalInStatusData. In this case I have initialised an array of zeros, which is the same size as the number of samples. 
Also, a numeric of the same value as the number of samples must be passed into 'countOfDataBytes'.

image.thumb.png.301abfbbb26885043f74345af04d48e5.png

image.png.f9399167bfaeab0676960b7177ad3a6d.png

Link to comment
Share on other sites

Hi @attila many thanks for your response.

I have changed the data type to array, but unfortunately I'm still unable to access more than one sample. The size of the array passed out of the DigitalInStatusData function, corresponds to the size of the array fed to the input parameter 'rgData', rather than the number of samples acquired (as indicated by SampleValid). The 1st sample in the array is valid (the same as before, when the data type was a Numeric and not an array). All other samples in the array are just a copy of whatever is fed into the input parameter 'rgData'. 

The 'Function Return' reports 1, suggesting the function is not reporting an error. 

With an array of 0, 0, 0 passed in...

image.thumb.png.0868e4bd973da0d3113b929ed4d11e2b.png

...an array with valid data in the first element of the array is passed out, followed by 0, 0:

image.png.1e3d100fc858a39db17ec1c3e4e33932.png

With an array of 0, 3, 0, 8 passed in...

image.thumb.png.9fbc797d10efafabbe6c3309ff939f3a.png

...an array with valid data in the first element of the array is passed out, followed by 3, 0, 8:

image.png.8176a54e66eb4020fe224c6e64523a30.png

Link to comment
Share on other sites

Resurrecting an old thread, but I am struggling to access captured data from the Digilent Digital Discovery Device. 
I have setup up the DigitalIn functions to capture data following a trigger event. The trigger is successfully activated as the DigitalInStatus function reports a triggered event, and the LED2 led illuminates when the appropriate condition is met (rising edge on DIN0). The DigitalInStatusSampleValid reports the same number of valid samples as was requested, so it seems as though the data is being captured ok. 
However, where my problem lies is in actually obtaining the data using DigitalInStatusData. I seem to be able to access one sample at a time. When altering the samplesAfterTrigger input to the DigitalInTriggerPositionSet function, I can see a different value in rgData Out, corresponding to the captured pattern on the DigitalIn port (DIN0-7). So the sample displayed in rgData, effectively moves along the pattern as the number of samplesAfterTrigger is changed. What I would like to do is access all the captured samples and build up an array. How can the other samples be accessed / indexed?

Code attached. 

Digital In Logic Analyser.zip

Link to comment
Share on other sites

15 hours ago, attila said:

Hi @graham

If you are using VIs the dwf.dll is already installed, since VIs are based on this.
The DLL can be imported from C:/Windows/System32/dwf.dll

Thank you attila,

In labview, I can access only the basic VIs, but in the screenshots from Evengi there are other VI icons which are coloured blue, and named something like: "F DWF Dgital Out Run Set" etc.

To import them properly, should I use the wizard in labview? In this case it requests a header file, but I don't know where to find this

Thanks,

Graham

Link to comment
Share on other sites

Hello,

I am trying to solve my problem based on info in this thread - I apologies if I am hijacking it

I want to be able to set the synchronisation settings (repeat numbers, wait time, etc) for the Discovery 2 waveform generator through labview. I have installed the DWF VIs, but they only allow me to change basic settings. Do I need to install the dwf.dll to get the sub-VIs that can be seen in Evengi's screenshots?

I followed the instructables link but it seems to refer to LabForms - is this what I need to install?

Thanks!

Graham

Link to comment
Share on other sites

I forgot to mention that after importing the DLL into LabVIEW some function argument types need to be adjusted.
The DLL import does not have information about pointer argument if it is representing pointer to a value or pointer to an array, char pointer or C type string...

Link to comment
Share on other sites

Thanks for the fast answer and your help, now everything is working correctly. The FDwfDigitalOutEnableSet has to be called at least in cofiguration of eack channel, otherwise a peak will generated and the external scope will trigger on its edge. The FDwfDigitalOutWaitSet has to be called before FDwfDigitalOutEnableSet.

Another issue after generating VIs from dwf.dll is that the parameter "rgBits" in FDwfDigitalOutDataSet has to be modified to a pointer, otherwise its not possible to use a custom data number as a bit mask.

Best regards

Evgeni

Link to comment
Share on other sites

After Digital Out settings make sure to call dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) to start the generator.

To delay a bit the actual signal generation, while the Digital In (MSO/Logic Analyzer) is started, use FDwfDigitalOutWaitSet option with a few (10-100) milliseconds.

Link to comment
Share on other sites

Hi attila,

thank you very much for the fast answering! I have installed all possible LabVIEW drivers and projects from the links you send me and I have also imported the dwf.dll manually already.

Then I have modified the "Digilent_WaveForms_Stimulus Response (MSO and FGEN)" to a Logic Analyzer and it works verry well.

I have also tried to implement in LabVIEW a pattern generator with your python code above, but any of the signal lines does not work yet. Firstly I tried to generate a digital clock signal with 1MHz and display it on a external scope  (Agilent DSO-X-3024A), but nothing happens.

I have attached the VI and some screens of the VI's block diagram and hope you or anyone else can help me. The VI consists of a mix of LabVIEW generated VIs from dwf.dll and VIs from NI's Edition drivers (https://decibel.ni.com/content/docs/DOC-44838).

My final destination in pattern generation is shown in the Image below "What_I_want_to_generate" via LabVIEW:What_I_want_to_generate.thumb.png.63e691 (Note: The frequency is 2 MHz, but in the VI is 1 MHz).
 

Block_diagram_Pattern_Gen_part1_SCLK.png

 

Block_diagram_Pattern_Gen_part2_MOSI_and_CE.png

Block_diagram_Pattern_Gen_part3_CE_and_CloseSession.png

Thanks in advance for your help.

Evgeni

Digilent_WaveForms_Pattern_Generator.vi

Link to comment
Share on other sites

Hello,

You can install the "Digilent WaveForms VIs" hardware support package which provides simple VIs to use the Analog Discovery 1&2 and EExplorer. This package is based on Virtual Bench VIs and does not provide all the features that WaveForms SDK has.
https://decibel.ni.com/content/docs/DOC-44838
http://vipm.jki.net/#!/package/digilent_waveforms_vis

You can also access all features of WaveForms SDK importing the dwf library, like the following project is done:
http://www.instructables.com/id/Analog-Discovery-USB-Oscilloscope-LabVIEW/

The WaveForms installs the Application (GUI), Runtime (dwf library) and SDK (manual, examples).
An SPI transmission using the DigitalOut (Pattern Generator) in Python looks like this:

from ctypes import *
import math
import time
import sys

if sys.platform.startswith("win"):
    dwf = cdll.dwf
elif sys.platform.startswith("darwin"):
    dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
else:
    dwf = cdll.LoadLibrary("libdwf.so")


#print DWF version
version = create_string_buffer(16)
dwf.FDwfGetVersion(version)
print "DWF Version: "+version.value

#open device
hdwf = c_int()
print "Opening first device"
dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))

if hdwf.value == 0:
    print "failed to open device"
    quit()

hzSys = c_double()
dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))

# SPI parameters
CPOL = 0 # or 1
CPHA = 0 # or 1
hzFreq = 1e6
cBits = 16
rgdData = (2*c_byte)(*[0x12,0x34])

# serialization time length
dwf.FDwfDigitalOutRunSet(hdwf, c_double((cBits+0.5)/hzFreq))

# DIO 2 Select 
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(2), c_int(1))
# output high while DigitalOut not running
dwf.FDwfDigitalOutIdleSet(hdwf, c_int(2), c_int(2)) # 2=DwfDigitalOutIdleHigh
# output constant low while running
dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(2), c_int(0), c_int(0))
dwf.FDwfDigitalOutCounterSet(hdwf, c_int(2), c_int(0), c_int(0))

# DIO 1 Clock
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(1), c_int(1))
# set prescaler twice of SPI frequency
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(1), c_int(int(hzSys.value/hzFreq/2)))
# 1 tick low, 1 tick high
dwf.FDwfDigitalOutCounterSet(hdwf, c_int(1), c_int(1), c_int(1))
# start with low or high based on clock polarity
dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(1), c_int(CPOL), c_int(1))
dwf.FDwfDigitalOutIdleSet(hdwf, c_int(1), c_int(1+CPOL)) # 1=DwfDigitalOutIdleLow 2=DwfDigitalOutIdleHigh

# DIO 0 Data
dwf.FDwfDigitalOutEnableSet(hdwf, c_int(0), 1)
dwf.FDwfDigitalOutTypeSet(hdwf, c_int(0), c_int(1)) # 1=DwfDigitalOutTypeCustom
# for high active clock, hold the first bit for 1.5 periods 
dwf.FDwfDigitalOutDividerInitSet(hdwf, c_int(0), c_int(int((1+0.5*CPHA)*hzSys.value/hzFreq))) 
# SPI frequency, bit frequency
dwf.FDwfDigitalOutDividerSet(hdwf, c_int(0), c_int(int(hzSys.value/hzFreq)))
# data sent out LSB first
dwf.FDwfDigitalOutDataSet(hdwf, c_int(0), byref(rgdData), c_int(cBits))


dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
print "Generating SPI signal"
time.sleep(1)

dwf.FDwfDigitalOutReset(hdwf);

dwf.FDwfDeviceCloseAll()

 

Link to comment
Share on other sites

Hi there,

isn't there any finished VI solution in LabVIEW, how to use the Pattern Generator and the Logic Analyzer. I have to simulate a SPI interface (3 lines with Pattern and 4 line Logic Analyzer). I tried the static DIO from NI Community,

https://decibel.ni.com/content/docs/DOC-44838

but I need a continously mode with 2MHz frequency like Chris in the post above, not the static one... Would be verry happy to get some VI for continously generating pattern and logic analizing.

Thanks for helping in advance.

Evgeni

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...