Search the Community

Showing results for tags 'analogdiscovery2'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • New Users Introduction
    • Announcements
  • Digilent Technical Forums
    • FPGA
    • Test and Measurement
    • Measurement Computing (MCC)
    • Add-on Boards
    • Digilent Microcontroller Boards
    • Non-Digilent Microcontrollers
    • LabVIEW
    • FRC
    • Other
  • General Discussion
    • Project Vault
    • Learn
    • Suggestions & Feedback
    • Buy, Sell, Trade
    • Sales Questions
    • Off Topic
    • Educators
    • Technical Based Off-Topic Discussions
    • Archived

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 9 results

  1. Hello, I am using below code to generate a Negative pulse at regular interval on DIO 0 pin of AD2 --------------------------------------------------------- print("Generating 1s pulse") while True: dwf.FDwfDigitalOutEnableSet(hdwf, c_int(0), c_int(1)) dwf.FDwfDigitalOutRunSet(hdwf, c_double(0.05)) # 50ms run dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(1)) # once dwf.FDwfDigitalOutIdleSet(hdwf, c_int(0), c_int(1)) # 1=DwfDigitalOutIdleLow, low when not running dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(0), c_int(1), c_int(0)) # initialize high on start dwf.FDwfDigitalOutCounterSet(hdwf, c_int(0), c_int(0), c_int(0)) # low/high count zero, no toggle during run dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) time.sleep(0.1) dwf.FDwfDigitalOutReset(hdwf) time.sleep(5) dwf.FDwfDigitalOutReset(hdwf) dwf.FDwfDeviceCloseAll() -------------------------------------------------------- And after this code segment I have another "pulse acquisition" code from Different pins of Digilent. ==> But, Since i ran code above continously in while loop(we need to generate the pulse continously), the acquisition code is not getting executed. Need some idea here, if we can ran the pulse generation with some other way or configure digilent. Any help is appreciated. @attila ############# Tried Below code to configure digilent for pulse generation but No Luck so far: ------------ # continue running after device close dwf.FDwfParamSet(c_int(4), c_int(0)) # DwfParamOnClose 0 = run, 1 = stop, 2 = shutdown print("Opening first device") hdwf = c_int() dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) # the device will be configured only when calling FDwf###Configure dwf.FDwfDeviceAutoConfigureSet(hdwf, c_int(0)) # digital output dwf.FDwfDigitalOutTriggerSourceSet(hdwf, c_int(3)) # trigsrcDetectorDigitalIn dwf.FDwfDigitalOutRepeatSet(hdwf, c_int(0)) # infinite repeat dwf.FDwfDigitalOutRepeatTriggerSet(hdwf, c_int(1)) # wait for trigger in each cycle dwf.FDwfDigitalOutRunSet(hdwf, c_double(1)) # 1ms run # DIO 1 pulse dwf.FDwfDigitalOutEnableSet(hdwf, c_int(1), c_int(1)) dwf.FDwfDigitalOutIdleSet(hdwf, c_int(1), c_int(1)) # 1=DwfDigitalOutIdleLow, low when not running dwf.FDwfDigitalOutCounterInitSet(hdwf, c_int(1), c_int(1), c_int(0)) # initialize with high when running dwf.FDwfDigitalOutCounterSet(hdwf, c_int(1), c_int(0), c_int(0)) # low/high count zero, no toggle during run # configure and start dwf.FDwfDigitalOutConfigure(hdwf, c_int(1)) ------------ Thanks, Rohit
  2. Hi, I am using protocol analyzer to monitor a SPI bus.. I have a STM32MCU used as SPI master, configured to run full duplex communication. There is no slave connected and I am just trying to understand the protocol itself. It is configured the following way: CPHA = 0, CPOL = 0 I have plugged the 1st Probe(Orange) to the CLK and 2nd Probe(Blue) to the MOSI pins and I record the waveform, Parallelly I have made the following connections to the digital inputs to record them on the Protocol analyzer DI 1(Green Wire) -> CLK DI 2(Purple Wire) -> MOSI The purpose of this connection is to monitor the CLK and DATA out from the SPI using Scope and Protocol analyzer. The logic I have written in the STM32MCU is to send a value "0x1" out via SPI pin whenever a push button is pressed. Below is the image of the data out from SPI that is captured in scope, the data out from the MCU is correct, every time I press the push button(SW delay is provided to prevent debouncing) However I observe a different pattern while Spying the bus using protocol analyzer. I see the data being shifted every time I press the button(Image Below). You can see that the "11" values are being shifted every time I press the push button. The data transmitted is wrong (It sends "11" instead of 1) My question is, if the data is shifted in the protocol analyzer window why bit shifting does not show on the scope?
  3. I need to capture a pulse (High to low), which stays for appx 600us, then goes back high. I need to capture for a given interval of time, the no. of pulses triggered. time interval maybe : 1ms, 1 s, 5s etc. Been using the DigitalIn_PulseTrigger.py & DigitalIn_trigger.py, but couldn't understand if it is behaving as expected: -------------- while True: dwf.FDwfDigitalInStatus(hdwf, c_int(1), byref(sts)) print("Status:", str(sts.value)) if sts.value == 2 : # done break ------------ Not sure about the value to be compared here, as for 1 sec or for 5 sec, i am seeing the break in appx same time here. => Also tried with AnalogIn_sample.py but i think it is not able to detect the drop in voltage for such short duration. Any help will be appreciated. Thanks, Rohit
  4. Hi, I am using Raspberry Pi 4 and Analog discovery 2 to building a sampling system. The trigger signal is generated by the raspberry pi and routed to the second analog input channel. The trigger signal has a voltage of 4 V and the trigger mode is set as Positive edge. From the lab oscilloscope, the trigger signal is observed while it is not read out by the analogIn channel of the Analog discovery 2 oscilloscope (it shows that the system stopped at Reading analog in status) . I am wondering whether there is anything wrong with my codes (shown as attached codes, especially in the trigger setting part), hope to have your advice. Best regards, Zeyu from time import sleep import RPi.GPIO as GPIO import signal from ctypes import * from dwfconstants import * import math import time import matplotlib.pyplot as plt import sys import numpy from csv import writer import pandas as pd 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(1e8) nSamples = int(1e4) 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 for j in range(1, 3, 1): print("Opening first device") dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) rgSamples1 = (c_int16*nSamples)() 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((90.0+j)*hzAcq.value/nSamples)) dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(0), AnalogOutNodeCarrier, c_double(5)) 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 def lopper(): for i in range(1,300): GPIO.output(7,0) sleep(0.001) GPIO.output(8,1) sleep(0.001) GPIO.output(8,0) GPIO.output(7,1) sleep(0.001) GPIO.output(7,0) GPIO.setmode(GPIO.BCM) GPIO.setup(7,GPIO.OUT) GPIO.setup(8,GPIO.OUT) lopper() dwf.FDwfAnalogInTriggerAutoTimeoutSet(hdwf, c_double(0)) #disable auto trigger dwf.FDwfAnalogInTriggerSourceSet(hdwf, trigsrcDetectorAnalogIn) #one of the analog in channels dwf.FDwfAnalogInTriggerTypeSet(hdwf, trigtypeEdge) dwf.FDwfAnalogInTriggerChannelSet(hdwf, 1) # first channel dwf.FDwfAnalogInTriggerLevelSet(hdwf, c_double(3.5)) # 0.5V dwf.FDwfAnalogInTriggerConditionSet(hdwf, trigcondRisingPositive) # dwf.FDwfAnalogInTriggerHoldOffSet(hdwf, c_double(0.01)) GPIO.cleanup() print("Starting dwf.FDwfAnalogInConfigure(hdwf, c_bool(False), c_bool(True)) dwf.FDwfAnalogOutConfigure(hdwf, c_int(0), c_bool(True)) dwf.FDwfAnalogOutReset(hdwf, c_int(0)) iSample = 0 while True: dwf.FDwfAnalogInStatus(hdwf, c_int(0), byref(sts)) dwf.FDwfAnalogInStatusRecord(hdwf, byref(cAvailable), byref(cLost), byref(cCorrupted)) iSample += cLost.value iSample %= nSamples if cLost.value : fLost = 1 if cCorrupted.value : fCorrupted = 1 iBuffer = 0 #wait at least 2 sec while cAvailable.value>0: cSamples = cAvailable.value # we are using circular sample buffer, make sure to not overflow if iSample+cAvailable.value > nSamples: cSamples = nSamples-iSample dwf.FDwfAnalogInStatusData16(hdwf, c_int(0), byref(rgSamples1, sizeof(c_int16)*iSample), c_int(iBuffer), c_int(cSamples)) # get channel 1 dat iBuffer += cSamples cAvailable.value -= cSamples iSample += cSamples iSample %= nSamples if sts.value == DwfStateDone.value : # done break dwf.FDwfDeviceCloseAll() if iSample != 0 : rgSamples1 = rgSamples1[iSample:]+rgSamples1[:iSample] print("Recording done "+str(iSample)) if fLost: print("Samples were lost! Reduce frequency") if fCorrupted: print("Samples could be corrupted! Reduce frequency") List = [] for v in rgSamples1: List.append(v) with open("record5.csv", "a") as f_object: writer_object = writer(f_object) writer_object.writerow(List) f_object.close() plt.plot(numpy.fromiter(rgSamples1, dtype = numpy.int16)) plt.show() file=open("record6.csv","w") df=pd.read_csv("record5.csv",header=None, low_memory=False) data=df.values data=list(map(list,zip(*data))) data=pd.DataFrame(data) data.to_csv(file,header=0,index=0) text = open("record6.csv", "r") text = ' '.join([i for i in text]) text = text.replace(",", " ") file = open('read.txt', 'w') file.write(text) file.close()
  5. Hello, Because of my carelessness, I broke Scope 1 by 100V overvoltage.(Scope 2 is alive.) Can I fix it by replacing the ADG612, which is the "Scope Input Divider and Gain Selection IC"? Thanks, rakunann444
  6. Hi! I hope this ends up in the right section! I had a weird thing happen to my Analog Discovery 2 just now. I was monitoring some uart communication with both scopes when my 2 scope started acting strange. It doesn't "hold" the voltage, initially it samples the right voltage but then it decreases exponentially, it kind of looks like a capacitor discharging or something like that (see pictures). If I instead connect 2+ to ground and use 2- to probe the signal it works fine although it's inverted... I cant imagine what would have whacked it since I'm just looking at some low voltage signals but it definitely seems broken to me... If anyone has an idea of what might have happened or how to fix it that would be greatly appreciated, I've been really happy with the product so far and I really want that scope back in working order!! The first pic is the broken scope, and the second is the same measuring the same square wave scope but "reversed" like i mentioned. Thanks!
  7. I'm a coding newbie trying to to use Javascript to produce a pulse of arbitrary length and capture the whole pulse (and a little bit before and after) in one csv file. To do this, I need to make Scope1's recording buffer size longer, and set Scope 1 to be triggered by Wavegen1, but get the following errors with both the Wavegen and Scope Windows open: Scope1.BufferSize.value = 1; RESULT: TypeError: Result of expression 'Scope1.BufferSize' [undefined] is not an object. Scope1.Source.text = "Wavegen 1"; //OR Scope1.Source.text = "Wavegen1"; RESULT OF BOTH: TypeError: Result of expression 'Scope1.Source' [undefined] is not an object. I'm guessing these functions are deprecated, since while they do appear in the help menu, they don't appear in the Ctrl+Space autofill menu. Does anyone know how to change the the individual buffer size for recording in javascipt, and set the source or Scope1, or is this something I have to go into the C++ SDK to do? Reading other forums code, at least the BufferSize variable is claimed to work fine, in code like here: Even with just copying Andras's code, I've run into the same compiler errors; I've reinstalled waveforms on at least two computers with separate Analog Discovery 2 devices and hit the same wall. Is there some declaration I must make beforehand before certain Scope1 members can be accessed?
  8. I am using the python API for Waveforms to interface an Analog Discovery 2 and are trying monitor a voltage. The problem is that the measurements on channel 1 are capped to about 2.7 Volt wile channel 2 can measure up to 12.5 (the voltage I am supposed to measure) just fine. When I open Waveforms and use the scope there everything seems to work just fine. I am using the example code from AnalogIn_Record.py whit some small cleanup/modifications. Does anyone have an idea what I might be doing wrong? """ 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 as np import signal dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf") class AnalogDiscovery2(): def __init__(self): self.hdwf = c_int() dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) def record_analog_in(self, pin, duartion): return def __del__(self): dwf.FDwfDeviceCloseAll() def rec(fs, duration_seconds=1, infinite=False): #declare ctype variables hdwf = c_int() sts = c_byte() hzAcq = c_double(fs) nSamples = duration_seconds * fs rgdSamples_1 = (c_double*nSamples)() rgdSamples_2 = (c_double*nSamples)() cAvailable = c_int() cLost = c_int() cCorrupted = c_int() fLost = 0 fCorrupted = 0 #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() #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) if infinite: dwf.FDwfAnalogInRecordLengthSet(hdwf, -1)#) # -1 infinite record length else: dwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(nSamples/hzAcq.value)) #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 time_start = time.time() 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_1, sizeof(c_double)*cSamples), cAvailable) # get channel 1 data dwf.FDwfAnalogInStatusData(hdwf, c_int(1), byref(rgdSamples_2, sizeof(c_double)*cSamples), cAvailable) # get channel 2 data cSamples += cAvailable.value time_used = time.time() - time_start 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") data_1 = np.fromiter(rgdSamples_1, dtype = np.float) data_2 = np.fromiter(rgdSamples_2, dtype = np.float) t = np.linspace(0, time_used, len(data_1)) np.save("data_1", data_1) np.save("data_2", data_2) np.save("time", t) if __name__ == "__main__": rec(100, 2)
  9. Hi, I'm trying to acquire at 1MSample/s using WaveForms SDK (DWF Version: 3.10.9) I think that I should use acqmodeRecord mode with infinitum length so I use: FDwfAnalogInRecordLengthSet(hdwf, 0.0); But then in the while loop I'm a little puzzled due to the call if(!FDwfAnalogInStatus(hdwf, true, &sts)).... Shouldn't be done only once to reach Running state? According to section "5 Analog In (Oscilloscope)" in SDK documentation the AD2 should remain in Running state... So I change the example to do only once but I have always the same samples...any clue? Should I use other acquisition mode like ScanScreen? like reported in Thank you for your help pz