Esempio n. 1
0
def Device_Enumeration():

    #print DWF version
    version = dwf.GetVersion()
    print "DWF Version: " + version

    #enumerate and print device information
    cdevices = dwf.Enum(0)
    print "Number of Devices: " + str(cdevices)

    for i in range(0, cdevices):
        devicename = dwf.EnumDeviceName(i)
        serialnum = dwf.EnumSN(i)
        print "------------------------------"
        print "Device %d :" % (i)
        print "\t" + devicename
        print "\t" + serialnum
        IsInUse = dwf.EnumDeviceIsOpened(i)

        if not IsInUse:
            hdwf = dwf.DeviceOpen(i)
            channel = dwf.AnalogInChannelCount(hdwf)
            hzfreq = dwf.AnalogInFrequencyInfo(hdwf)
            print "\tAnalog input channels: " + str(channel)
            print "\tMax freq: " + str(hzfreq)
            dwf.DeviceClose(hdwf)
            hdwf = -1

    # ensure all devices are closed
    dwf.DeviceCloseAll()
Esempio n. 2
0
def AnalogOut_Sine():
    channel = 0

    #print DWF version
    version = dwf.GetVersion()
    print "DWF Version: " + version

    #open device
    print "Opening first device..."
    hdwf = dwf.DeviceOpen(-1)

    if hdwf == dwf.hdwfNone:
        print "failed to open device"
    else:
        print "Generating sine wave..."
        dwf.AnalogOutNodeEnableSet(hdwf, channel, dwf.AnalogOutNodeCarrier,
                                   True)
        dwf.AnalogOutNodeFunctionSet(hdwf, channel, dwf.AnalogOutNodeCarrier,
                                     dwf.funcSine)
        dwf.AnalogOutNodeFrequencySet(hdwf, channel, dwf.AnalogOutNodeCarrier,
                                      10000)
        dwf.AnalogOutNodeAmplitudeSet(hdwf, channel, dwf.AnalogOutNodeCarrier,
                                      1.41)
        dwf.AnalogOutNodeOffsetSet(hdwf, channel, dwf.AnalogOutNodeCarrier,
                                   1.41)
        print "Play sine wave for 10 seconds..."
        dwf.AnalogOutConfigure(hdwf, channel, True)
        time.sleep(10)
        print "done."
        dwf.DeviceClose(hdwf)
Esempio n. 3
0
def main():
    sel = 0x0010
    a = dwf.Enum(dwf.enumfilterAll)
    print(a)
    a = dwf.EnumDeviceType(0)
    print(a)
    a = dwf.EnumDeviceIsOpened(0)
    print(a)
    fd = dwf.DeviceOpen(0)
    print(fd)
    if sel & 0x0001:
        a = dwf.EnumDeviceIsOpened(0)
        print(a)
        a = dwf.EnumUserName(0)
        print(a)
        a = dwf.EnumSN(0)
        print(a)
        a = dwf.GetVersion()
        print(a)
        a = dwf.EnumDeviceName(0)
        print(a)
        a = dwf.GetLastErrorMsg()
        print(a)
    if sel & 0x0002:
        generateSinus(fd, 0, 12346, 1.41, sqrt(2))
        data = AcquireAnalog(fd, 1000, 1000E3)
        plt.plot(data)
        print(np.mean(data), np.std(data))
        plt.show()

        generateSinus(fd, 1, 12346, 1.00, sqrt(2))
        data = AcquireAnalog(fd, 1000, 1000E3, 1)
        plt.plot(data)
        print(np.mean(data), np.std(data))
        plt.show()

    if sel & 0x0004:
        generateDigitalPattern8(fd, [0, 1, 2, 3, 4, 5, 6, 7], 1E3)

        data = AcquireDigital(fd, 1024)
        print(data, len(data))

    if sel & 0x0008:
        DigitalIO(fd)

    if sel & 0x0010:
        SysMon(fd, 10)

    dwf.DeviceClose(fd)
Esempio n. 4
0
def AnalogOut_Sync():
    
    #print DWF version
    version = dwf.GetVersion()
    print "DWF Version: "+version
    
    #open device
    print "Opening first device..."
    hdwf = dwf.DeviceOpen(-1)
    
    if hdwf == dwf.hdwfNone:
        print "failed to open device"
    else:
        print "Generating sine wave..."
        # enable two channels
        dwf.AnalogOutNodeEnableSet(hdwf, 0, dwf.AnalogOutNodeCarrier, 1)
        dwf.AnalogOutNodeEnableSet(hdwf, 1, dwf.AnalogOutNodeCarrier, 1)
        # for second channel set master the first channel
        dwf.AnalogOutMasterSet(hdwf, 1, 0);
        # slave channel is controlled by the master channel
        # it is enough to set trigger, wait, run and repeat paramters for master channel
        
        # configure enabled channels
        dwf.AnalogOutNodeFunctionSet(hdwf, -1, dwf.AnalogOutNodeCarrier, dwf.funcSine)
        dwf.AnalogOutNodeFrequencySet(hdwf, -1, dwf.AnalogOutNodeCarrier, 1000.0)
        dwf.AnalogOutNodeAmplitudeSet(hdwf, -1, dwf.AnalogOutNodeCarrier, 1.0)
    
        #set phase for second channel
        dwf.AnalogOutNodePhaseSet(hdwf, 1, dwf.AnalogOutNodeCarrier, 180.0)
    
        print "Play sine wave for 10 seconds..."
        # start signal generation, 
        # the second, slave channel will start too
        dwf.AnalogOutConfigure(hdwf, 0, True)
        
        time.sleep(10)
        
        print "done."
        dwf.DeviceClose(hdwf)