Jump to content

attila

Technical Forum Moderator
  • Posts

    6,668
  • Joined

  • Last visited

Posts posted by attila

  1. Szia @Andras

    The software is not available natively for Windows ARM64, only for Windows 32/64bit, Linux 32/64 bit intel/arm (x86, amd64, armhf, arm64) and MacOS 32/64.
    It is also working with MacOS M1/ARM seamlessly with emulation. 

    As I read, Windows ARM also provides intel emulation:
    https://blogs.windows.com/windows-insider/2020/12/10/introducing-x64-emulation-in-preview-for-windows-10-on-arm-pcs-to-the-windows-insider-program/

    The error is complaining about "Visual C++ Redistributable for Visual Studio 2015".
    This is included in the WF installer but WinARM may need a different variant. Please try installing it manually:
    https://www.microsoft.com/en-us/download/details.aspx?id=48145
    https://answers.microsoft.com/en-us/windows/forum/all/unable-to-install-programs-due-to-vcruntime140dll/3a9cba87-6dfd-4591-94d6-08c347e2db39

  2. Hi @maling

    I run the following code with 10 device for more than 10minutes several times without any problem.
    multi.py similar to your GetSpectra()

    image.png.521b9d3610aba9e6d9e3b6c8a615222a.png

     

    I only got error when disconnecting the USB cable:

    image.png.2c50a6b7fac4ae75008dfbefd6b969aa.png


    At which function it fails for you?
    For the error message use print(szerr.value) or cast the C string.

    from ctypes import *
    import sys
    import time
    from dwfconstants import *
    
    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")
    
    szerr = create_string_buffer(512)
    
    def FDwf(fun, args):
        if fun(*args) == 0:
            dwf.FDwfGetLastErrorMsg(szerr)
            print(szerr.value)
            raise
    
    #dwf.FDwfParamSet(DwfParamOnClose, c_int(1)) # 0 = run, 1 = stop, 2 = shutdown
    
    cDevice = c_int()
    dwf.FDwfEnum(c_int(0), byref(cDevice))
    print("Devices: "+str(cDevice.value))
    
    hdwfs = []
    for k in range(cDevice.value):
        hdwf = c_int()
        FDwf(dwf.FDwfDeviceOpen, [c_int(k), byref(hdwf)])
        hdwfs.append(hdwf)
    
    for k in range(len(hdwfs)):
        FDwf(dwf.FDwfAnalogImpedanceReset, [hdwfs[k]])
        FDwf(dwf.FDwfAnalogImpedanceModeSet, [hdwfs[k], c_int(8)]) # 0 = W1-C1-DUT-C2-R-GND, 1 = W1-C1-R-C2-DUT-GND, 8 = AD IA adapter
        FDwf(dwf.FDwfAnalogImpedanceReferenceSet, [hdwfs[k], c_double(1e3)]) # reference resistor value in Ohms
        FDwf(dwf.FDwfAnalogImpedanceFrequencySet, [hdwfs[k], c_double(1e3)]) # frequency in Hertz
        FDwf(dwf.FDwfAnalogImpedanceAmplitudeSet, [hdwfs[k], c_double(1)]) # 1V amplitude = 2V peak2peak signal
        FDwf(dwf.FDwfAnalogImpedanceConfigure, [hdwfs[k], c_int(1)]) # start
    
    tstart = time.time()
    sts = c_byte()
    for j in range(100): # repeat
        for i in range(100): # steps
            for k in range(len(hdwfs)): # device
                print("repeat: "+str(j)+"  step: "+str(i)+"  dev: "+str(k))
                FDwf(dwf.FDwfAnalogImpedanceFrequencySet, [hdwfs[k], c_double(1e3+99e3*i/99)]) # frequency in Hertz # Once you set a value, it will start its measurement routine automatically
            time.sleep(0.01)
            for k in range(len(hdwfs)):
                FDwf(dwf.FDwfAnalogImpedanceStatus, [hdwfs[k], None]) # ignore last capture since we changed the frequency
    
            # Read the result from each of the devices, once they complete.
            for k in range(len(hdwfs)):
                hdwf = hdwfs[k]
                while True:
                    FDwf(dwf.FDwfAnalogImpedanceStatus, [hdwf, byref(sts)])
                    if sts.value == 2:
                        break
                # Compute the resistance and reactance from the harvested values
                resistance = c_double()
                reactance = c_double()
                FDwf(dwf.FDwfAnalogImpedanceStatusMeasure, [hdwf, DwfAnalogImpedanceResistance, byref(resistance)])
                FDwf(dwf.FDwfAnalogImpedanceStatusMeasure, [hdwf, DwfAnalogImpedanceReactance, byref(reactance)])
    
    print("Done with "+str(len(hdwfs))+" devices in "+str(time.time()-tstart)+"s")
    dwf.FDwfDeviceCloseAll()

     

  3. Hi @CoreZ86

    The oscilloscope in a device is one instrument. The scope channels are controlled together, one trigger, same rate... but you can use them for different purpose. The FDwfAnalogInStatus->FDwfAnalogInStatusSample returns the current ADC readings regardless of the capture state.
    The wavegen channels are independent instruments.

    See the following posts:

     

     

  4. Hi @TheoMaria

    As it is in the second example:
     If you are using the DAQ do not call FDwfDeviceOpen since the device can be opened only once at a time.
     The DAQ will open the device the hdwf will get value 1 and use this in the FDwf functions.

    I've modified your example: Waveform_Generation2.m

    ...
    %% Power Supply
    % Load library, "hfile" is a variable that points to the location of the library
    
    % dummy read to open device
    data = read(dq, seconds(1));
    
    if ~libisloaded('dwf')
        loadlibrary('dwf', 'C:/Program Files (x86)/Digilent/WaveFormsSDK/inc/dwf.h');
    end
    
    if calllib('dwf','FDwfAnalogIOStatus', 1) == 0 % see if device is connected
        disp('No opened device')
        return
    else
        disp('Enable PS')
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 0, 0, 1.0); % V+ enable
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 0, 1, 5.0); % V+ 5V
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 1, 0, 1.0); % V- enable
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 1, 1, -5.0); % V- -5V
        calllib('dwf','FDwfAnalogIOEnableSet', 1, 1); % master enable
        pause(1) % wait to settle
    end
    
    unloadlibrary('dwf')
    
    %% Generate a Periodic Waveform and Record Input
    ...

     

  5. Hi @TheoMaria

    Probably you are using an old version of WF runtime 3.7.2 which is currently required by the DAQ AD support package.

    If you are using the support package this will open the device then the other functions can be called, like this

    function DWFtest2();
    
    % make sure daq opens device
    daqlist("digilent")
    dq = daq("digilent")
    ch_in = addinput(dq, "AD1", "1", "Voltage");
    [singleReading, startTime] = read(dq)
    
    % 32 bit system
    %hfile = 'C:/Program Files/Digilent/WaveFormsSDK/inc/dwf.h';
    %64 bit system
    hfile = 'C:/Program Files (x86)/Digilent/WaveFormsSDK/inc/dwf.h';
    
    if ~libisloaded('dwf')
        loadlibrary('dwf', hfile);
    end
    
    if calllib('dwf','FDwfAnalogIOStatus', 1) == 0 % see if device is connected
        disp('No opened device')
    else
        disp('Enable PS')
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 0, 0, 1.0); % V+ enable
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 0, 1, 5.0); % V+ 5V
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 1, 0, 1.0); % V- enable
        calllib('dwf','FDwfAnalogIOChannelNodeSet', 1, 1, 1, -5.0); % V- -5V
        calllib('dwf','FDwfAnalogIOEnableSet', 1, 1); % master enable
    end
    
    unloadlibrary('dwf')
    
    end

     

  6. Hi @TheoMaria

    See the following:DWFtest.zip
    The server does not allow me to add m code or m file, here you have a picture:

    image.thumb.png.3536f22f0c8ab2aae025f8ef24884cb6.png

        calllib('dwf','FDwfParamSet', 4, 0); % DwfParamOnClose continue on Run
        calllib('dwf','FDwfDeviceAutoConfigureSet', phdwf.Value, 0); 
        calllib('dwf','FDwfAnalogIOChannelNodeSet', phdwf.Value, 0, 0, 1.0); % V+ enable
        calllib('dwf','FDwfAnalogIOChannelNodeSet', phdwf.Value, 0, 1, 5.0); % V+ 5V
        calllib('dwf','FDwfAnalogIOChannelNodeSet', phdwf.Value, 1, 0, 1.0); % V- enable
        calllib('dwf','FDwfAnalogIOChannelNodeSet', phdwf.Value, 1, 1, -5.0); % V- -5V
        calllib('dwf','FDwfAnalogIOEnableSet', phdwf.Value, 1); % master enable
        calllib('dwf','FDwfAnalogIOConfigure', phdwf.Value); % configure device

     

  7. Duten tag @Fonso!

    Yes, the Ethernet phy provides isolation as well a WiFi dongle.
    For USB external isolator can be used. The cheaper ones, based on ADUM4160 are USB FS and will reduce the transfer rate. This will be mostly noticeable when streaming data, when using Scope/Logic record and Wavegen play modes.

    Isolation is recommended for safety when using multiple socket powered instrument and to reduce ground loops that could cause ringing, oscillation... in measurements.
    A self/battery powered tool is isolated so it is safe to use.

  8. Hi @Zeyu

    I've set to trigger and capture the same channel 2 to verify the trigger correctness.
    You can get the data from the channel 1 as well:
    dwf.FDwfAnalogInStatusData16(hdwf, c_int(0), byref(rgSamples1, sizeof(c_int16)*iSample), c_int(iBuffer), c_int(cSamples)) # get channel 1 data
    dwf.FDwfAnalogInStatusData16(hdwf, c_int(1), byref(rgSamples2, sizeof(c_int16)*iSample), c_int(iBuffer), c_int(cSamples)) # get channel 2 data

     

  9. Hi @LiamP

    Similar as it is done in the Device_Synchronization.py example, first configure each input and output channels (or the needed ones) in each device, and arm them, wait each to finish and get the data.

    for iDevice in range(cDevice.value): # open and configure
      dwf.FDwfDeviceOpen(c_int(iDevice), byref(hdwf))
      ...
      rghdwf.append(hdwf.value)
      
      dwf.FDwfAnalogIn... # configure range, offset... for channels, frequency, trigger position...
      dwf.FDwfAnalogInTriggerSourceSet(rghdwf[iDevice], trigsrcExternal1) 
      dwf.FDwfAnalogInConfigure(rghdwf[iDevice], c_bool(False), c_bool(True)) # arm inputs
      
      dwf.FDwfAnalogOutCount(hdwf, byref(cChannel))
      for iChannel in range(cChannel.value):
        dwf.FDwfAnalogOut... # configure signal, amplitude, offset... run length...
        dwf.FDwfAnalogOutTriggerSourceSet(rghdwf[iDevice], c_int(iChannel), trigsrcExternal1)
        dwf.FDwfAnalogOutConfigure(rghdwf[iDevice], c_int(iChannel), c_bool(True)) # arm outputs
    
    while True: # wait for each device capture
      fDone = True
      for iDevice in range(len(rghdwf)):
        dwf.FDwfAnalogInStatus(rghdwf[iDevice], c_int(0), byref(sts))
        if sts.value != dwfstateDone
          fDone = False
          break
      if fDone:
        break
      
    for iDevice in range(len(rghdwf)): # fetch and get data
        dwf.FDwfAnalogInStatus(rghdwf[iDevice], c_int(1), None)
        dwf.FDwfAnalogInChannelCount(rghdwf[iDevice], byref(cChannel))
        for iChannel in range(cChannel.value):
            dwf.FDwfAnalogInStatusData(rghdwf[iDevice], c_int(iChannel), ...
    
    dwf.FDwfDeviceCloseAll()

     

×
×
  • Create New...