Phil_D

Members
  • Content Count

    26
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Phil_D got a reaction from attila in Having trouble getting 16k samples from Analog In API function   
    This worked! Thanks @attila
  2. Like
    Phil_D reacted to attila in Having trouble getting 16k samples from Analog In API function   
    Hi @Phil_D
    # 2nd configuration for Analog Discovery with 16k analog-in buffer
    if(!FDwfDeviceConfigOpen(-1, 1, &hdwf)){...
     
  3. Like
    Phil_D reacted to attila in Digilent Analog Discovery 2: AnalogIn continous sampling   
    Hi @Pazzo
    In case the data processing or saving in your loop function takes too much time it could lead to buffer overflow (samples lost/corrupt).
    You could try opening the device with 2nd configuration to have more device buffer.
    # 2nd configuration for Analog Disocovery with 16k analog-in buffer
    #dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(1), byref(hdwf)) 
     
  4. Like
    Phil_D reacted to attila in Driving the scope ADC at full scale for best SNR   
    Hi @Phil_D
    You can use the RangeSet function to select the gain and the RangeGet function to get the calibrated value, full swing.
    All the Set/Get function in the API behave like this.
    Normally it is not recommended to go with full swing input signal since clipping can occur. Like when the scale top is 5.561V and the input signal reaches 5.562V
    dwf.FDwfAnalogInChannelEnableSet(hdwf, c_int(-1), c_bool(True)) dwf.FDwfAnalogInChannelRangeSet(hdwf, c_int(-1), c_double(5.0)) dwf.FDwfAnalogInConfigure(hdwf, c_int(1), c_int(1)) range1 = c_double() range2 = c_double() offset1 = c_double() offset2 = c_double() dwf.FDwfAnalogInChannelRangeGet(hdwf, c_int(0), byref(range1)) dwf.FDwfAnalogInChannelRangeGet(hdwf, c_int(1), byref(range2)) dwf.FDwfAnalogInChannelOffsetGet(hdwf, c_int(0), byref(offset1)) dwf.FDwfAnalogInChannelOffsetGet(hdwf, c_int(1), byref(offset2)) print("Scope 1 Range: "+str(range1.value)+"V Offset: "+str(offset1.value)+"V") print("Scope 2 Range: "+str(range2.value)+"V Offset: "+str(offset2.value)+"V") # on my AD2 the actual ranges are the following: # Scope 1 Range: 5.560701917732086V Offset: -2.4933249474501373e-06V # Scope 2 Range: 5.558373268176409V Offset: 0.00021560932083742462V  
  5. Like
    Phil_D reacted to attila in ADC gain or attenuation in hardware vs. gain or attenuation in Waveforms   
    Hi @Phil_D
    The gain switch is adjusted automatically based on the selected scope range.
    At 500mV/div (5Vpk2pk ~0.3mV resolution) or lower the high gain is used with  and above this the low gain (50Vpk2pk w ~3mV resolution).
    In case you specify trigger level out of the screen (5Vpk2pk) or offset higher/lower than +/- 2.5V the low gain will be used for the trigger source channel. This will be noted on the screen with red warning text.
    The attenuation is a different thing.
    This option lets you specify the external attenuation or amplification on the signals which enter the scope inputs and the data is scaled accordingly.
    Like, if you use a 10x scope probe, the scope input will actually get 1/10th of the original signal, but specifying 10x attenuation the signal is scaled to show values on the probe. In this case the 500mV/div (5Vpk2pk) low/high gain limit moves up to 5V/div (50Vpk2pk) and the low gain up to 50V/div
    If you have an external 100x amplifier on the scope input you can specify 0.01x attenuation. With this you will have 5mV/div (50mVpk2pk ~0.003mV resolution) for high gain.
  6. Like
    Phil_D reacted to attila in Waveforms Spectrum Analyzer and Zero Padding   
    Hi @Phil_D
    Sure, it makes more sense to apply the window only on the real data section.
    const NAVG = 10 const NPAD = 2 Spectrum.Trace5.Window.text = "Rectangular" // disable windowing Spectrum.run() var win = [] var sum = [] for(var acq = 1; acq <= NAVG && Spectrum.wait(); acq++){ var hz = Spectrum.Channel1.dataRate // WF v3.11.2 { // padding in Trace 5 var rg = Spectrum.Channel1.data // channel 1 time domain data var c = rg.length if(acq==1){ // create window var w = 0 for(var i = 0; i < c; i++) { var v = pow(sin(PI*i/(c-1)), 2.0) // Hann w += v win.push(v) } w /= c*NPAD for(var i = 0; i < c; i++) { // normalize win[i] /= w } } for(var i = 0; i < c; i++) rg[i] = win[i]*rg[i] // apply window for(var i = 0; i < c*(NPAD-1); i++) rg.push(0) // padding Spectrum.Trace5.setSamples(rg, hz) } { // averaging in Trace 6 var rg = Spectrum.Trace5.magnitude if(acq==1){ sum = rg; Spectrum.Trace6.Clone(Spectrum.Trace5) }else{ rg.forEach(function(v,i){ sum[i] += v;}) // sum sum.forEach(function(v,i){ rg[i] = v/acq;}) // average Spectrum.Trace6.setMagnitude(rg, 0, hz/2) } } } Spectrum.stop()
     
    Here you can see that CZT produces the same result as the padding:
    The noise floor difference is due to different captures.

     
    The FFT works on power of two + 1 BINs, with CZT you can specify arbitrary number of BINs, setting fine resolution:

     
  7. Like
    Phil_D reacted to attila in Waveforms Spectrum Analyzer and Zero Padding   
    Hi @Phil_D
    It can be done like this:
    const NAVG = 10 Spectrum.run() var sum = [] for(var acq = 1; acq <= NAVG && Spectrum.wait(); acq++){ var hz = Spectrum.Channel1.dataRate // WF v3.11.2 { // padding in Trace 5 var rg = Spectrum.Channel1.data // channel 1 time domain data var c = rg.length var t = rg[c-1] // last sample for(var i = 0; i < c; i++) rg.push(t) // 2x padding Spectrum.Trace5.setSamples(rg, hz) } { // averaging in Trace 6 var rg = Spectrum.Trace5.magnitude if(acq==1){ sum = rg; Spectrum.Trace6.Clone(Spectrum.Trace5) }else{ rg.forEach(function(v,i){ sum[i] += v;}) // sum sum.forEach(function(v,i){ rg[i] = v/acq;}) // average Spectrum.Trace6.setMagnitude(rg, 0, hz/2) } } } Spectrum.stop()  
  8. Like
    Phil_D reacted to attila in Wait for averaging in script   
    Hi @Phil_D
    Spectrum.run() for(var i = 0; i < 50 && Spectrum.wait(); i++); Spectrum.stop()  
  9. Like
    Phil_D reacted to attila in Waveforms Spectrum Analyzer and Zero Padding   
    Hi @Phil_D
    There is no zero padding option but it can be done with Script like this:
    var rg = Spectrum.Channel1.data // channel 1 time domain data var c = rg.length var t = rg[c-1] // last sample for(var i = 0; i < c; i++) rg.push(t) // 2x padding var rghz = Spectrum.Trace1.frequency var hz = 2.0*rghz[rghz.length-1] //var hz = 2.0*Spectrum.Frequency.Stop.value // scope sample rate Spectrum.Trace5.setSamples(rg, hz)
     
    Some other suggestions to improve the resolution:
    1. For lower frequencies, with 1MHz sampling you can use the Scope to perform a longer recording. This will highly improve the resolution in the FFT view.
    2. With AD you can select the second device configuration to have 16k Scope buffer.
    3. You can select a higher bandwidth window, like rectangular or cosine.
    4. In the latest beta version with CZT algorithm you can select higher number of bins, higher resolution.
    https://forum.digilentinc.com/topic/8908-waveforms-beta-download/
    Here:
    - T1 is CZT BlackmanHarris 10x BINs, 244Hz resolution
    - T2 is FFT BlackmanHarris 4k BINs 2.4kHz resolution
    - T3 is FFT Cosine 4k BINs 2.4kHz resolution
     

  10. Like
    Phil_D reacted to attila in API or software interface to Waveforms 2015   
    Hi @Phil_D @bvleo
    The issue is fixed in the latest beta version. You can call: 
    subprocess.Popen(['C:/Program Files (x86)/Digilent/WaveForms3/WaveForms.exe','default.dwf3work','-runscript'])
    When a WF app instance is running, the above call will notify it to load and run the script. The '-runscript' will supress the 'save current workspace' message.
     
  11. Like
    Phil_D reacted to attila in API or software interface to Waveforms 2015   
    Hi @Phil_D
    I just notice that the -runscript is only working when the instruments are in docking window mode.
    My bad, runscript is only looking for docked Script window. It will be fixed in the next software version.

  12. Like
    Phil_D reacted to bvleo in API or software interface to Waveforms 2015   
    Hey @Phil_D
    I too had a problem with getting WaveForms to run automatically, and my group didn't find a way to make it work through the suggested code. However, we did have success when we commanded Python to simulate an F5 key press, which is a shortcut in WF to run the script. We used the library "uinput". Here's a sample of the actual command we used. I'm not certain that it's all you need, as I was not the primary Python programmer for this project, but at least it'll give you an idea of what needs to be done for this workaround. The sleep timers are there to give the program time to start and load the workspace.
    waveform_Call = subprocess.Popen("exec " + waveforms, shell = True)
        waveform_Call
        time.sleep(10)
            device = uinput.Device([
                    uinput.KEY_FN,
            uinput.KEY_F5,
            ])
        time.sleep(1)
            device.emit_combo([
            uinput.KEY_FN,
            uinput.KEY_F5,
            ])
  13. Like
    Phil_D reacted to attila in API or software interface to Waveforms 2015   
    Hi @Phil_D
    Try calling to load the workspace and to run script one after the other.
    subprocess.Popen(['C:/Program Files/Digilent/WaveForms3/WaveForms.exe', 'phase_noise_237.dwf3work'])
    subprocess.Popen(['C:/Program Files/Digilent/WaveForms3/WaveForms.exe', '-runscript'])
  14. Like
    Phil_D reacted to attila in Is there source code available for DWFCMD.EXE?   
    Hi @Phil_D
    The dwfcmd app was created long time ago when the WaveForms v2 app supported only Windows. Good to know that it is still used.
    You can find the source of the dwfcmd app at:
    C:\Program Files (x86)\Digilent\WaveFormsSDK\samples\dwfcmd\ dwfcmd.cpp
    /usr/share/digilent/waveforms/samples/dwfcmd/ dwfcmd.cpp
  15. Like
    Phil_D reacted to attila in Analog Discovery 2 vs Raspberry Pi 3   
    Hi @Phil_D
    The received data set may contain inserted or altered by dummy zero bytes so the data can be shifted randomly...
    To detect such it would require adding a custom CRC wrapper above the communication, firmware and software architectural changes...
  16. Like
    Phil_D reacted to rprr in Analog Discovery 2 vs Raspberry Pi 3   
    Just to add, that I've tried it with the recently released Raspberry Pi  3B+ but no luck. I have updated to the latest kernels. Very frustrating  
    I wonder if there is a problem with the Digilent Adept runtime drivers for linux.
  17. Like
    Phil_D reacted to attila in Analog Discovery 2 vs Raspberry Pi 3   
    Hi @Phil_D @rprr
    The problem is that the USB IN packets/bytes are randomly lost/altered.
    I tried various kernel options, limiting the USB transfer rates but had no luck. The data corruption reduced from one in 1-60 seconds to one in 10-60 minutes, which it is still not good...
    It seems that the root of the problem is in the low level FTDI library, kernel or USB modules, or between them...
    The Analog Discovery is working fine with other SOCs but not with the RPi.
    I also notice issue with the USB keyboard I use with the RPi, time to time key presses are not received. 
    You can find many similar RPi issues on the net:
    https://www.raspberrypi.org/forums/viewtopic.php?f=28&amp;t=5249&amp;sid=8839659cb92b7475fa196b2fad775d9f&amp;start=250
    http://www.ftdicommunity.com/index.php?topic=40.0
  18. Like
    Phil_D reacted to attila in Analog Discovery 2 vs Raspberry Pi 3   
    Hi @Wojtek
    I have updated the PRi B2 a few months ago and tried different boot/kernel options mentioned on other forums... but nothing helped.
  19. Like
    Phil_D reacted to attila in Analog Discovery 2 vs Raspberry Pi 3   
    FTDI USBs like AD, AD2, DD are not working with RPI model B (1,2,3) data packets/bytes are randomly lost. 
    The EExplorer with different USB controller is working fine on these.
    All devices are working with other embeddeds: Zed, Zybo, BeagleBone…
    According reports AD is working with the original RPI model A and probably Zero because it has similar chipset/USB.
    The problem seems to be with FTDI or RPI B USB, library or hardware. You can find such comments regarding RPI problems with other devices too. Unfortunately we couldn't remediate this problem.
  20. Like
    Phil_D reacted to attila in Running FFTs with the API using the AD2   
    Hi @Phil_D
    I moved your post to the proper thread.
    The WaveForms SDK provides access to the low level function.
    The Spectrum Analyzer in WF application uses these function to capture data and performs FFT (or CZT). Then, a set of measurements and graphics are available. I think there would be too many options to fit in API.
    You could perform similar acquisition with a custom application or script, using Python, Octave, LabView, Matlab..., where data processing (FFT) and even more sophisticated measurements (dedicated for various tasks) are available.