Jump to content

kaamil1984

Members
  • Posts

    12
  • Joined

  • Last visited

Posts posted by kaamil1984

  1. Thank you. This is what I needed:

    dwf.FDwfDigitalUartTx(hdwf, rgTX, c_int(sizeof(rgTX)-1)) # send text, trim zero ending

     

    Line above is from this example (

    Digilent\WaveFormsSDK\samples\py\Digital_Uart.py

     

    """
       DWF Python Example
       Author:  Digilent, Inc.
       Revision:  2018-07-23
    
       Requires:                       
           Python 2.7, 3
    """
    
    from ctypes import *
    import math
    import sys
    import time
    
    if sys.platform.startswith("win"):
        dwf = cdll.LoadLibrary("dwf.dll")
    elif sys.platform.startswith("darwin"):
        dwf = cdll.LoadLibrary("/Library/Frameworks/dwf.framework/dwf")
    else:
        dwf = cdll.LoadLibrary("libdwf.so")
    
    hdwf = c_int()
    
    print("Opening first device")
    #dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf))
    # device configuration of index 3 (4th) for Analog Discovery has 16kS digital-in/out buffer
    dwf.FDwfDeviceConfigOpen(c_int(-1), c_int(3), byref(hdwf)) 
    
    if hdwf.value == 0:
        print("failed to open device")
        szerr = create_string_buffer(512)
        dwf.FDwfGetLastErrorMsg(szerr)
        print(str(szerr.value))
        quit()
    
    print("Configuring UART...")
    
    cRX = c_int(0)
    fParity = c_int(0)
    
    # configure the I2C/TWI, default settings
    dwf.FDwfDigitalUartRateSet(hdwf, c_double(9600)) # 9.6kHz
    dwf.FDwfDigitalUartTxSet(hdwf, c_int(0)) # TX = DIO-0
    dwf.FDwfDigitalUartRxSet(hdwf, c_int(1)) # RX = DIO-1
    dwf.FDwfDigitalUartBitsSet(hdwf, c_int(8)) # 8 bits
    dwf.FDwfDigitalUartParitySet(hdwf, c_int(0)) # 0 none, 1 odd, 2 even
    dwf.FDwfDigitalUartStopSet(hdwf, c_double(1)) # 1 bit stop length
    
    dwf.FDwfDigitalUartTx(hdwf, None, c_int(0))# initialize TX, drive with idle level
    dwf.FDwfDigitalUartRx(hdwf, None, c_int(0), byref(cRX), byref(fParity))# initialize RX reception
    time.sleep(1)
    
    rgTX = create_string_buffer(b'Hello\r\n')
    rgRX = create_string_buffer(8193)
    
    print("Sending on TX for 10 seconds...")
    dwf.FDwfDigitalUartTx(hdwf, rgTX, c_int(sizeof(rgTX)-1)) # send text, trim zero ending
    
    tsec = time.clock() + 10 # receive for 10 seconds
    print("Receiving on RX...")
    while time.clock() < tsec:
        time.sleep(0.01)
        dwf.FDwfDigitalUartRx(hdwf, rgRX, c_int(sizeof(rgRX)-1), byref(cRX), byref(fParity)) # read up to 8k chars at once
        if cRX.value > 0:
            rgRX[cRX.value] = 0 # add zero ending
            print(rgRX.value.decode(), end = '', flush=True)
        if fParity.value != 0:
            print("Parity error {}".format(fParity.value))
    
    dwf.FDwfDeviceCloseAll()

    ---

    But it would be VERY VERY useful if I could just write and send data from here:

     

    image.png.2fdfa02dd0b13def1b79af9f6173ea81.png

  2. Hi guys,

    Are there any plans to release new version of Analog Discovery with a bit deeper memory? 

    It is awesome instrument, very useful even in professional work. I have found that in many cases is waaaay better than some regular low cost scopes (like my 4ch Rigol MDO where XY mode is useless, there is no way to store setup, firmware is buggy etc.).

    There is just one little problem: not enough sample memory. I'm forced to use Record feature sometimes when just 2x more memory could do the job. 

    Can we expect AD3 with a bit deeper memory in near future? Probably 256k would be enough...

     

×
×
  • Create New...