Jump to content

Alessandro

Members
  • Posts

    11
  • Joined

  • Last visited

Alessandro's Achievements

Member

Member (2/4)

0

Reputation

  1. Good morning, I'm Alessandro. I'm trying to acquire from two analog input channels of the Analog Discovery 2, whose acquisition must be triggered by an external Arduino signal (0V->5V square wave) at port T1. One acquired analog input channel (called SIGNAL) is a multi-step analog signal at KHz rate (BLUE in the pictures) that I want to sample at each bit (samples are shown in BLACK). Then the Arduino trigger signal is split and fed it to the remaining analog input of the Analog Discovery, so that this trigger is present both at T1 port (to trigger the acquisition) and recorded at the remaining analog input of the Analog Discovery (called TRIGGER, shown in ORANGE in the pictures). Therefore it is possible to see when the acquisition of SIGNAL happens with respect to the TRIGGER rising edge. As you can see from the pictures, TRIGGER rising edge is synchronized with the SIGNAL, but the acquisition sometimes happens 2 samples in advance. Do you know why this could happen? I would like to start the acquisition everytime with the TRIGGER rising edge. Thank you. Here it is the Python code I used to acquire the signal: sts = c_byte() sampling_frequency = 10000 #500000 hzAcq = c_double(sampling_frequency) nSamples = 300 rgdSamples1 = (c_double * nSamples)() rgdSamples2 = (c_double * nSamples)() rgwDigital = (c_uint16 * nSamples)() cAvailable = c_int() cLost = c_int() cCorrupted = c_int() fLost = 0 fCorrupted = 0 sampling_time = 1 / sampling_frequency ############ set up acquisition ################ dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(0),c_bool(True)) # the acquired channel is the scope 1+,1- dwf.FDwfAnalogInAcquisitionModeSet(hdwf, c_int(3)) # record dwf.FDwfAnalogInFrequencySet(hdwf, hzAcq) sRecord = nSamples / hzAcq.value dwf.FDwfAnalogInRecordLengthSet(hdwf, c_double(sRecord)) # -1 infinite record length dwf.FDwfAnalogInTriggerPositionSet(hdwf, c_double(0.0 * sRecord)) # trigger at time zero ############ set up trigger ###################### dwf.FDwfAnalogInTriggerAutoTimeoutSet(hdwf, c_double(0)) # disable autotrigger dwf.FDwfAnalogInTriggerSourceSet(hdwf, trigsrcExternal1) # trigsrcDetectorAnalogIn dwf.FDwfAnalogInTriggerTypeSet(hdwf, c_int(0)) # trigtypeEdge dwf.FDwfAnalogInTriggerChannelSet(hdwf, c_int(1)) # channel 2 is used as TRIGGER (+2,-2) dwf.FDwfAnalogInTriggerLevelSet(hdwf, c_double(1.8)) # 0V # dwf.FDwfAnalogInTriggerHysteresisSet(hdwf, c_double(0.01)) # 0.01V dwf.FDwfAnalogInTriggerConditionSet(hdwf, c_int(0)) # trigcondRisingPositive ################# ACQUISITION ######################### sts = c_byte(0) rgdSamples1 = (c_double * nSamples)(0) rgdSamples2 = (c_double * nSamples)(0) rgwDigital = (c_uint16 * nSamples)(0) cAvailable = c_int(0) cLost = c_int(0) cCorrupted = c_int(0) fLost = 0 fCorrupted = 0 print("Starting oscilloscope") # dwf.FDwfAnalogInConfigure(hdwf, c_int(0), c_int(1)) dwf.FDwfAnalogInConfigure(hdwf, c_int(True), c_int(True)) iSample = 0 while True: dwf.FDwfAnalogInStatus(hdwf, c_int(1), 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 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.FDwfAnalogInStatusData2(hdwf, c_int(0), byref(rgdSamples1, sizeof(c_double) * iSample), c_int(iBuffer), c_int(cSamples)) # get channel 1 data dwf.FDwfAnalogInStatusData2(hdwf, c_int(1), byref(rgdSamples2, sizeof(c_double) * iSample), c_int(iBuffer), c_int(cSamples)) # get channel 2 data dwf.FDwfDigitalInStatusData(hdwf, rgwDigital, c_int(sizeof(c_uint16) * nSamples)) iBuffer += cSamples cAvailable.value -= cSamples iSample += cSamples # print(str(cAvailable.value), str(cSamples), str(iSample), str(iBuffer)) iSample %= nSamples # print(str(cAvailable.value),str(cSamples),str(iSample), str(iBuffer)) if sts.value == 2: # when sts assumes value equal to 2 it exits from the loop (end of acquisition) break if iSample != 0: rgdSamples1 = rgdSamples1[iSample:] + rgdSamples1[:iSample] rgdSamples2 = rgdSamples2[iSample:] + rgdSamples2[:iSample] if fLost: print("Samples were lost! Reduce frequency") if fCorrupted: print("Samples could be corrupted! Reduce frequency") rgdSamples1 = numpy.array(rgdSamples1, dtype=float) rgdSamples2 = numpy.array(rgdSamples2, dtype=float)
  2. Hello, I'm writing into the forum because I need to acquire 2 analog input signals (multilevel signals) and 1 digital input signal in order to sample the analog ones. I'm retrieving the 2 analog signals using the 2 analog scopes of the Analog Discovery 2, while I saw that I can retrieve the digital one using a DIO port. This is simple using the Waveforms software, but I would like to use a Python script (code as attachment). Basically I acquire the analog signals using: dwf.FDwfAnalogInStatusData2(hdwf, c_int(0), byref(rgdSamples1, sizeof(c_double) * iSample), c_int(iBuffer), c_int(cSamples)) # get channel 1 data dwf.FDwfAnalogInStatusData2(hdwf, c_int(1), byref(rgdSamples2, sizeof(c_double) * iSample), c_int(iBuffer), c_int(cSamples)) # get channel 2 data These analog signals are synchronous. The question is: How can I acquire the digital signal from the DIO port? Is it possible to have a digital signal that is synchronized (or shifted by an offset) with respect to the analog signals? Thank you! Alessandro
  3. Hi @attila, if yes, what is the python line that I should write to force a 2V into the analog input? Thank you Alessandro
  4. Good morning to everyone, I'm doing an experiment in which I sample the 2 analog input scopes of the Analog Discovery 2 at every iteration of a for cycle. At these analog inputs I analyzed the current coming from to 2 photodiodes. There is a order of magnitude between the 2 measured voltage (current of the photodiode*AD2 input resistance) meaning tens of mV for 1 photodiode and hundreds of mV for the other photodiode. The problem with this kind of measure is that the response of the 2 photodiodes to a power ramp is different. This could depend on the fact they are unbiased. Therefore I'd like to bias directly the 2 analog inputs. Is it possible o I need to insert a transimpedance amplifier between the photodiode and the analog input? Thank you in advance, Alessandro
  5. Ok, so you mean it's not important if we write: dwf.FDwfAnalogInStatus(hdwf, c_int(False), None) dwf.FDwfAnalogInStatusSample(hdwf, c_int(0), byref(voltage1)) dwf.FDwfAnalogInStatusSample(hdwf, c_int(1), byref(voltage2)) or: dwf.FDwfAnalogInStatus(hdwf, c_int(False), None) dwf.FDwfAnalogInStatusSample(hdwf, c_int(1), byref(voltage2)) dwf.FDwfAnalogInStatusSample(hdwf, c_int(0), byref(voltage1)) Should voltage2 and voltage1 be the same in the examples above or the order in which we write the code affects the measure?
  6. Good morning everybody, I've just used my Analog Discovery 2 for the acquisition of two different signals using the two available Analog Inputs. The Python syntax is: dwf.FDwfAnalogInStatusSample(hdwf, c_int(0), byref(voltage1)) dwf.FDwfAnalogInStatusSample(hdwf, c_int(1), byref(voltage2)) The question is: Are the two acquisitions perfectly synchronized? Is there a way to acquire simultaneously the two voltages without using an external trigger? I need their ratio and it has to be very precise. Thank you in advance.
  7. I'm using Analog Discovery 2. Examining the digital channels, I can see they're synchronous, but they show 500mV as maximum voltage. I don't know if there's a possibility to obtain perfect synchronous channels with greater voltage range...
  8. Hi, assume that I want to change my code with two synchronized digital outputs. Is there a way to set the digital output voltage level in AnalogDiscovery2? Thank you
  9. Hi, I have the same problem here. In particular I used the DigitalOut_Custom python code, but with the oscilloscope I realized I can't reach 1V output and I need more. Therefore before declaring the variable "pin=0", I put: # set voltage to 3.3 V (DD) dwf.FDwfAnalogIOChannelNodeSet(hdwf, 0, 0, c_double(3.3)) # enable positive supply dwf.FDwfAnalogIOEnableSet(hdwf, 1) # enable VIO" but nothing has changed. Any suggestions? Thank you.
  10. Good morning, I'm new in this forum. I'm writing because I'm working on a project related to the generation of two encoded signals. As you can see from the uploaded code, the encoded signal (encoded[]) is made of a fixed base (encoding[]) that is multiplied by each element in the array data[]. Therefore the encoded signal is a bit stream of 0 and 1 that I created using funcCustom. The main constraint of this projects is that the two signals must be SYNCHRONOUS. The PROBLEM is that in reality they're not as you can see from the oscilloscope image. Sometimes it happens that there is a small delay of 4µs and sometimes there isn't at all. Why does it happen? This is crucial for my application. In the code I used this kind of synchronization: dwf.FDwfAnalogOutMasterSet(hdwf, c_int(1), c_int(0)) dwf.FDwfAnalogOutConfigure(hdwf, c_int(-1), c_bool(True)) Thank you, Alessandro CDMA_customFunc.py
×
×
  • Create New...