Jason

Members
  • Content Count

    7
  • Joined

  • Last visited

Everything posted by Jason

  1. Hi there I've been using the Analog Discovery with a python code that I wrote that uses the waveforms SDK and it works just fine on windows. I've tried migrating to mac but I'm now having trouble with running my code. So far I followed the link above and installed Waveforms2015 and the Dilient Driver but when I run my code I get the error below ending with 'OSError: dlopen(libdwf.dylib, 6): image not found' Can you advise? I think it because the install.sh (from the SDK folder) may not be installing correctly. In the terminal, when I run install.sh, all the lines say no such directory. Error information: runfile('/Users/Jason/Dropbox/JasonAnalogDiscovery/NMRspectrometer_redefiningAcquirePulseWaitandTrigPos.py', wdir='/Users/Jason/Dropbox/JasonAnalogDiscovery') dar Traceback (most recent call last): File "<ipython-input-165-c8d6aa72487a>", line 1, in <module> runfile('/Users/Jason/Dropbox/JasonAnalogDiscovery/NMRspectrometer_redefiningAcquirePulseWaitandTrigPos.py', wdir='/Users/Jason/Dropbox/JasonAnalogDiscovery') File "//anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile execfile(filename, namespace) File "//anaconda/lib/python2.7/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 78, in execfile builtins.execfile(filename, *where) File "/Users/Jason/Dropbox/JasonAnalogDiscovery/NMRspectrometer_redefiningAcquirePulseWaitandTrigPos.py", line 17, in <module> dwf = cdll.LoadLibrary("libdwf.dylib") File "//anaconda/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "//anaconda/lib/python2.7/ctypes/__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) OSError: dlopen(libdwf.dylib, 6): image not found
  2. Is there any reason why my number of samples would be limited with this code? The max samples I can set is 8192 (over 0.1 sec acquisition). After that the list in rgpy fills with zeros. I need a sample rate of 2 x 64KHz = 128KHz. The current issue limits me to 81KHz. from ctypes import * import time import sys import matplotlib.pyplot as plt if sys.platform.startswith("win"): dwf = cdll.dwf elif sys.platform.startswith("darwin"): dwf = cdll.LoadLibrary("libdwf.dylib") else: dwf = cdll.LoadLibrary("libdwf.so") print "Opening first available device" hdwf = c_int() dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) if hdwf.value == 0: print "failed to open device" quit() pulse = 0.5 wait = .01 acquire = .1 samples = 8192 rate = 1.0*samples/acquire print "pulse: "+str(pulse)+"sec" print "wait: "+str(wait)+"sec" print "acquire: "+str(acquire)+"sec" print "samples/rate: "+str(samples)+"/"+str(rate)+"Hz" # DigitalOut # controls the AnalogOut/In, these wait for trigger # run once pulsing the DIO0,1,2 signals dwf.FDwfDigitalOutRunSet(hdwf, c_double(pulse+wait+acquire)) dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(1)) # repeat once for i in range(0,3): dwf.FDwfDigitalOutEnableSet(hdwf, c_int(i), c_int(1)) # enable digital output 0 dwf.FDwfDigitalOutIdleSet(hdwf, c_int(i), c_int(1)) # DwfDigitalOutIdleLow dwf.FDwfDigitalOutDividerSet(hdwf, c_int(i), c_int(100000)) # 100Mhz / 1e6 = 1kHz counter rate, 1ms period #DIO0: pulse ______ _______ #DIO1: ______ wait _______ #DIO2: ______ ______ acquire dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(0), c_int(1), c_int(int(round(pulse*1000)))) # DIO0: initial value high, pulse length dwf.FDwfDigitalOutCounterSet(hdwf, c_int(0), c_int(10*1000), c_int(10*1000)) # low/high counts are longer than run dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(1), c_int(0), c_int(int(round(pulse*1000)))) # DIO1: initial value low, pulse length dwf.FDwfDigitalOutCounterSet(hdwf, c_int(1), c_int(10*1000), c_int(int(round(wait*1000)))) # low/high counts dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(2), c_int(0), c_int(int(round((pulse+wait)*1000)))) # DIO2: initial value low, pulse+wait length dwf.FDwfDigitalOutCounterSet(hdwf, c_int(2), c_int(10*1000), c_int(int(round(acquire*1000)))) # low/high counts # AnalogOut 0 # run once pulse length time after digital out starts dwf.FDwfAnalogOutEnableSet(hdwf, c_int(0), c_int(1)) dwf.FDwfAnalogOutFunctionSet(hdwf, c_int(0), c_int(1)) # sine dwf.FDwfAnalogOutFrequencySet(hdwf, c_int(0), c_double(64000)) # 10Hz dwf.FDwfAnalogOutAmplitudeSet(hdwf, c_int(0), c_double(0.02)) dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(0), c_int(6)) # trigsrcDigitalOut dwf.FDwfAnalogOutRunSet(hdwf, c_int(0), c_double(pulse)) dwf.FDwfAnalogOutRepeatSet(hdwf, c_int(0), c_int(1)) # repeat once dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_int(1)) # AnalogOut 1 # run pulse+wait+acquire time after digital out starts dwf.FDwfAnalogOutEnableSet(hdwf, c_int(1), c_int(1)) dwf.FDwfAnalogOutFunctionSet(hdwf, c_int(1), c_int(3)) # sine dwf.FDwfAnalogOutFrequencySet(hdwf, c_int(1), c_double(58500)) # 0.5Hz dwf.FDwfAnalogOutAmplitudeSet(hdwf, c_int(1), c_double(2)) dwf.FDwfAnalogOutTriggerSourceSet(hdwf, c_int(1), c_int(6)) # trigsrcDigitalOut dwf.FDwfAnalogOutRunSet(hdwf, c_int(1), c_double(pulse+wait+acquire)) dwf.FDwfAnalogOutRepeatSet(hdwf, c_int(1), c_int(1)) dwf.FDwfAnalogOutConfigure(hdwf, c_int(1), c_int(1)) # The AnalogIn trigger position is relative to the middle of the sample buffer. # The trigger event is the AnalogOut signal generation start, Run phase start. dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(-1), c_double(5)) #4 volt range dwf.FDwfAnalogInBufferSizeSet(hdwf, c_int(samples)) dwf.FDwfAnalogInFrequencySet(hdwf, c_double(rate)) dwf.FDwfAnalogInTriggerSourceSet(hdwf, c_int(6)) #trigsrcDigitalOut dwf.FDwfAnalogInTriggerPositionSet(hdwf, c_double(pulse+wait+(acquire/2))) #dwf.FDwfAnalogInTriggerPositionSet(hdwf, c_double(pulse/2)) #TRIGGERPOS dwf.FDwfAnalogInConfigure(hdwf, c_int(1), c_int(1)) print "Wait after first device opening the analog in offset to stabilize" time.sleep(1) rgData = (c_double*samples)() sts = c_int() dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) while True: dwf.FDwfAnalogInStatus(hdwf, c_int(1), byref(sts)) # done if sts.value == 2 : break dwf.FDwfAnalogInStatusData(hdwf, c_int(0), rgData, c_int(samples)) rgpy=[0.0]*len(rgData) for i in range(0,len(rgpy)): rgpy=rgData plt.plot(rgpy) plt.show() dwf.FDwfDeviceCloseAll()
  3. Thank you this is great! Am I limited with this method to how short a duration I can run? for example, if I set 'pulse' to 0.02 (say), I receive an error message: dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(0), c_int(1), c_int(pulse)) # DIO0: initial value high, pulse length TypeError: int expected instead of float Is there a way to address this so that pulse, wait and acquire can be as short as 1 ms?
  4. Hi Attila Thanks for your help with this. I've been playing around with the code you sent and I've learnt a lot from it but I haven't yet been able to bend it quite to my will. Below is a timing diagram for what I'm trying to achieve. I don't want the pattern to repeat. Simply execute the pattern below once. i.e. 'Pulse' 'Wait' 'Acquire' followed by a plot and all outputs going low. Can you help me with this? Thanks again! Pulse (2seconds)Wait (1second)Aquire (2seconds) Instrument# DigitalOut(or DigitalIO)0+++++++++++++++ DigitalOut(or DigitalIO)1 ++++++++++++++ DigitalOut(or DigitalIO) 2 ++++++++++++++ AnalogOut0+++++++++++++++ AnalogIn0 ++++++++++++++ Bonus:AnalogOut1++++++++Runs the whole time+++++++++++++++++++++
  5. Thanks attila. Can the digital IOs be triggered in the same way as the scope? For instance, in the example code you gave above, can a pin be triggered to come on at the same time as the scope? Trawling through the SDK manual the digital IOs appear not to have any trigger functions whereas the DigitalIn and the DigitalOut (pattern generator) do, is this right? I'm sorry I didnt quite follow how the HEX above translated into turning DIO 0 on... presumably it translates to something like 0000000000000001 across the 16 pins?
  6. wow, thanks for the quick response . That certainly answers my question and the code works great. I have another question if I may? The digital IO pins.. is it possible to control them individually? E.g. just to turn one pin on at the start of the program and leave it running? Would it be at 5V?
  7. Hi All Is it possible to control the relative timings of pulses and aquisitions using the SDK? I've not seen anything explicit in the SDK yet but I may be missing something fairly obvious (I'm new!). I'd like to get precise pauses between actions on time scales as short as 1 ms. For example: [200 ms sin pulse] [pause of (possibly as short as) 1 ms] [open scope channel] I considered using python's time.sleep() funciton but it looks like ~15 ms is the quickest pause it can consistently do so I'd like to do it in-hardware rather than in-software. Thanks for your thoughts! Jason