Jump to content

arnavguptagenerac

Members
  • Posts

    4
  • Joined

  • Last visited

arnavguptagenerac's Achievements

Newbie

Newbie (1/4)

0

Reputation

  1. Hello, I had some scripts for an analog discovery 2 that I was working with in windows that worked all fine. I tried recreating same thing in WSL but I had an extremely hard time trying to get this installed. A lot of the links and how to's are insanely outdated and the newest version of stuff I could find was from 2015. I am new to WSL and this kind of work and could really use some help getting waveforms installed on WSL and gettitng the SDK scripts to work. Even the download page for this is broken. From what I could tell I neeeded to have ADEPT but this page seems to be completely down. I really need some help with this if anyone has done this before. This is what the adept download page looks like.
  2. @attila I understand that I can set the sampling rate and output frequency of the analog channels. I was more wondering if there was anyone to get the frequency value that shows up in the actual waveform application scope. Like the ones you can access under measurements for C1 and C2. I want to try and recieve the frequency value of both channels of the actual waveform I am measuring.
  3. Hello, I am trying to get some waveforms from a device to make sure that is outputting what I want. The voltage of the waveform is already confirmed to be done but I do not know how to determine the frequency of the waveform from the SDK. I am using the following code. Any tips? """ DWF Python Example Author: Digilent, Inc. Revision: 2018-07-19 Requires: Python 2.7, 3 """ from ctypes import * from dwfconstants import * import math import time import matplotlib.pyplot as plt import sys import numpy 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") #declare ctype variables hdwf = c_int() sts = c_byte() hzAcq = c_double(100000) nSamples = 200000 rgdSamples = (c_double*nSamples)() cAvailable = c_int() cLost = c_int() cCorrupted = c_int() fLost = 0 fCorrupted = 0 #print(DWF version version = create_string_buffer(16) dwf.FDwfGetVersion(version) print("DWF Version: "+str(version.value)) #open device print("Opening first device") dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) if hdwf.value == hdwfNone.value: szerr = create_string_buffer(512) dwf.FDwfGetLastErrorMsg(szerr) print(str(szerr.value)) print("failed to open device") quit() print("Generating sine wave...") dwf.FDwfAnalogOutNodeEnableSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_bool(True)) dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(0), AnalogOutNodeCarrier, funcSine) dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(1)) dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(2)) dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_bool(True)) #set up acquisition dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0), c_bool(True)) dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(0), c_double(5)) dwf.FDwfAnalogInAcquisitionModeSet(hdwf, acqmodeRecord) dwf.FDwfAnalogInFrequencySet(hdwf, hzAcq) dwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(nSamples/hzAcq.value)) # -1 infinite record length #wait at least 2 seconds for the offset to stabilize time.sleep(2) print("Starting oscilloscope") dwf.FDwfAnalogInConfigure(hdwf, c_int(0), c_int(1)) cSamples = 0 while cSamples < nSamples: dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts)) if cSamples == 0 and (sts == DwfStateConfig or sts == DwfStatePrefill or sts == DwfStateArmed) : # Acquisition not yet started. continue dwf.FDwfAnalogInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted)) cSamples += cLost.value if cLost.value : fLost = 1 if cCorrupted.value : fCorrupted = 1 if cAvailable.value==0 : continue if cSamples+cAvailable.value > nSamples : cAvailable = c_int(nSamples-cSamples) dwf.FDwfAnalogInStatusData(hdwf, c_int(0), byref(rgdSamples, sizeof(c_double)*cSamples), cAvailable) # get channel 1 data #dwf.FDwfAnalogInStatusData(hdwf, c_int(1), byref(rgdSamples, sizeof(c_double)*cSamples), cAvailable) # get channel 2 data cSamples += cAvailable.value dwf.FDwfAnalogOutReset(hdwf, c_int(0)) dwf.FDwfDeviceCloseAll() print("Recording done") if fLost: print("Samples were lost! Reduce frequency") if fCorrupted: print("Samples could be corrupted! Reduce frequency") f = open("record.csv", "w") for v in rgdSamples: f.write("%s\n" % v) f.close() plt.plot(numpy.fromiter(rgdSamples, dtype = numpy.float)) plt.show()
  4. Hello, I was just wondering if anyone could help me figure out how to get a better image of a 60 Hz waveform using the SDK on analog discovery 2. I am using the default single acquisition code for this. The problem that I am getting is that because there is a max buffer size of 8192 I cannot get an image of the full waveform and verify whether or not it is the waveform I want to see. I can only see a part of this waveform and the part I see is random based on whenever the analog discovery 2 is reading its channel 1. Is there any way around this so I can see the full waveform. this is what I am seeing and this is what I want to see. Also does anyone know how I can get the channel measurement values that are shown on the right in the image above from the SDK. Thank you!
×
×
  • Create New...