Jump to content

liu

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by liu

  1. Hi Attilia,

    I am trying to synchronize an 80Hz clock (from Digital output) and an 80 Hz customized analog waveform (see below). However, I am having an issue introducing a phase between them. While I can shift the phase of the analog signal, its range is much smaller than I expected. Below is the clock signal (yellow) and the analog waveform with different phases (0, 90, 180, 270 degrees), where I was expecting them to spread over one period instead of just ~1/4 period.   

    image.thumb.png.11a148af4f79e553b12cd242870b4ded.png

    My code for setting the analog waveform is as below. I tried to introduce the phase difference with FDwfAnalogOutPhaseSet & FDwfAnalogOutNodePhaseSet and had similar results, where "triggerPhase" was set to 0, 90, 180, 270. I wonder if I used the wrong function or if anything wrong with my setting?

            nRet = dwf.FDwfAnalogOutMasterSet(hdwf, c_int(LG_Chan), c_int(1));
            nRet = dwf.FDwfAnalogOutNodeFunctionSet(hdwf, c_int(LG_Chan), c_int(0), funcCustom);
            nRet = dwf.FDwfAnalogOutNodeFrequencySet(hdwf, c_int(LG_Chan), AnalogOutNodeCarrier, c_double(DACFreq));
            # dwf. FDwfAnalogOutTriggerSourceSet(hdwf, c_int(LG_Chan), trigsrcNone)
            dwf. FDwfAnalogOutTriggerSourceSet(hdwf, c_int(LG_Chan), trigsrcDigitalOut)
            dwf.FDwfAnalogOutTriggerSlopeSet(hdwf, c_int(LG_Chan), DwfTriggerSlopeRise)
            
            nRet = dwf.FDwfAnalogOutNodeDataSet(hdwf, -1, AnalogOutNodeCarrier, DAC, c_int(len(DAC)));
            nRet = dwf.FDwfAnalogOutNodeAmplitudeSet(hdwf, c_int(LG_Chan), c_int(0), c_double(absmax));
            nRet = dwf.FDwfAnalogOutNodeOffsetSet(hdwf, c_int(LG_Chan), c_int(0), c_int(0));
            # nRet = dwf.FDwfAnalogOutNodePhaseSet(hdwf, c_int(LG_Chan), c_int(0), c_double(triggerPhase));
            nRet = dwf.FDwfAnalogOutPhaseSet(hdwf, c_int(LG_Chan), c_double(triggerPhase));
            
            dwf.FDwfAnalogOutConfigure(hdwf, c_int(LG_Chan), c_int(1))
            time.sleep(0.1)
            dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))

    Thanks again for the help.

    Yisi

  2. Thanks for the response.

    So you mean I cannot have I2C and Digital Output at the same time. Is there a way to disable I2C after I setup my board so I can turn on Digital output? Which command should I use?

    The frequency I am trying to generate is 100Hz so the trigger IO is way too fast for me. And I am already using the two analog-out channels for other functions. 

    Best,

    Yisi

  3. Hi Attilia,

    I am trying to run I2C (IO 3&4) and have digital output (IO 5&6) as clock together. I tested each function separately and run well (except  FDwfDigitalIOOutputEnableSet bahaves oppositely to the reference as in my previous question). Yet, when I put them together, I2C always works but the digital output will stop once there is a I2C write. Below is my code (in python). 

    Also, I want to set IO 6 as low (or high)  and wonder if there is simpler way than using pulse as in the code?

    And I want to set FDwfDigitalOutModeSet to PP but cannot find any reference or sample code on how to do that.

    Thanks. 

    Yisi

    # setup digital IO for trigger pattern 
    print("configuring trigger")
    # enable output for DIO 5, disable 6 so it is low 
    dwf.FDwfDigitalIOOutputEnableSet(hdwf, c_int(0x0000)) # 1<<1
    pfsOutputEnable = (c_uint*16)()
    dwf.FDwfDigitalIOOutputEnableGet(hdwf, byref(pfsOutputEnable))
    print("FDwfDigitalIOOutputEnableGet", pfsOutputEnable)
    # set value on enabled IO pins
    dwf.FDwfDigitalIOOutputSet(hdwf, c_int(0x0000)) # DIO-5&6 low
    dwf.FDwfDigitalIOConfigure(hdwf)
    # dwf.FDwfDigitalOutTriggerSlopeSet(hdwf, c_int(0)) # 0: rise, 1: fall, 2: either
    
    # configure and start clock
    hzSys = c_double()
    dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))
    print("internal frequency: ", hzSys)
    # 80 Hz pulse on DIO-5
    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(5), c_int(1))
    # prescaler to double, SystemFrequency/xHz/2
    dwf.FDwfDigitalOutDividerSet(hdwf, c_int(5), c_int(int(hzSys.value/80/2)))
    # 50% duty cycle, 1 tick low, 1 tick high
    dwf.FDwfDigitalOutCounterSet(hdwf, c_int(5), c_int(1), c_int(1))
    dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
    
    # low Hz pulse on DIO-6
    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(6), c_int(1))
    # prescaler to double, SystemFrequency/xHz/2
    dwf.FDwfDigitalOutDividerSet(hdwf, c_int(6), c_int(int(hzSys.value/80/2)))
    # 50% duty cycle, 1 tick low, 1 tick high
    dwf.FDwfDigitalOutCounterSet(hdwf, c_int(6), c_int(1), c_int(0))
    dwf.FDwfDigitalOutConfigure(hdwf, c_int(1))
    
    print("IO configured")
    time.sleep(3)
    
    # setup I2C
    print("Configuring I2C...")
    iNak = c_int()
    dwf.FDwfDigitalI2cRateSet(hdwf, c_double(1e5)) # 100kHz
    dwf.FDwfDigitalI2cSclSet(hdwf, c_int(3)) # SCL = DIO-0
    dwf.FDwfDigitalI2cSdaSet(hdwf, c_int(4)) # SDA = DIO-1
    dwf.FDwfDigitalI2cClear(hdwf, byref(iNak))
    if iNak.value == 0:
        print("I2C bus error. Check the pull-ups.")
        # quit()
    time.sleep(1)
    
    rgTX = (c_ubyte*16)(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15)
    rgRX = (c_ubyte*16)()
    
    I2C_Addresses = ""
    I2Cadd = [0xa,0xd,0x44,0x49,0x4a,0x4b]
    # for i in range(8,119):
    for i in I2Cadd:
        # print(c_int(i<<1))
        blnCheck = dwf.FDwfDigitalI2cWriteOne(hdwf, c_int(i<<1),None, byref(iNak))
        # blnCheck = dwf.FDwfDigitalI2cRead(hdwf, c_int(i<<1), rgRX, c_int(1), byref(iNak))
        print(i, blnCheck, iNak)
        if iNak.value == 0:
            I2C_Addresses = I2C_Addresses + str(i)+" "
    
    print("I2C addresses: ", I2C_Addresses)
    
    print("values of output pins: ", dwf.FDwfDigitalIOOutputGet(hdwf, 0x00))
    time.sleep(0.1)

     

  4. Hi Attila,

    I am using discovery 3 and downloaded the latest version of waveform. I just notice that the python code 

    dwf.FDwfDigitalIOOutputEnableSet(hdwf, c_int(0x00ff))

    actually disables pins as output, while c_int(0x00) enables them, which is opposite to what says in the reference.

    I wonder if I misunderstood anything here?

    Thanks.

    Best,

    Yisi

×
×
  • Create New...