• 0

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

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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()

 

Share this post


Link to post
Share on other sites
  • 0

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

Edited by EvtodaGi

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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

Edited by EvtodaGi

Share this post


Link to post
Share on other sites
  • 0

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...

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0
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

Share this post


Link to post
Share on other sites
  • 0

Hi @graham

You can find the latest SDK manual, examples, header file in the install path:
C:\Program Files (x86)\Digilent\WaveFormsSDK\
Or click the SDK button in the Waveforms application's Welcome page to open this path.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now