Jump to content

Philipp

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Philipp

  1. Hello @attila

    thanks for the fast response. The exact timing is not that important but it is important to configure the pulse first and be able to call another function in the sequential program when the pulse is output. Is this possible with the DIOs?

    Also do you know why I don't get an Output with AutoConfigure enabled when I don't call the FDwfDigitalOutConfigure funtion?

  2. Hello,

    I'm using the python SDK to control a Digital Discovery. I want to have a constant clock output signal on one port and sometimes trigger 1/2/5 pulses on another port. With the FDwfDigitalOutRepetitionSet function this works pretty good but sometimes the initialization of the pulse leads to an interrupt in the clock signal.

    I think it could be because I am using "FDwfDigitalOutConfigure" after configuring every single signal. If I set AutoConfigure on and don't use FDwfDigitalOutConfigure I don't get an output. Maybe I am doing something wrong/ forgetting something in configuring the output. This is the code I call every time to start a output signal:

    Quote

    #check if analog discovery is connected
                if self.hdwf.value == hdwfNone.value:
                    #if not, set error code to NOK_NO_DEVICE_CONNECTED before other functions
                    return self._retval_helper(self._error_codes.NOK_NO_DEVICE_CONNECTED[0])
                
                # get clock info clock
                hzSys = _ct.c_double()
                if not self.dwf.FDwfDigitalOutInternalClockInfo(self.hdwf, _ct.byref(hzSys)):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_GET_CLOCK_INFO[0])
                
                # enable DIO
                if not self.dwf.FDwfDigitalOutEnableSet(self.hdwf, data.port, 1):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_ENABLE[0])
                
                # prescaler to xkHz, SystemFrequency/x/2
                # frequency is doubled because for an alternating signal a minimum counter high + counter low of 2 is neccessary
                # the divider defines the frequency of one step --> 2 steps for a clock signal requires frquency*2
                # with higher counters (eg. for duty cycle) the frequency needs to be adjusted accordingly
                if not self.dwf.FDwfDigitalOutDividerSet(self.hdwf, data.port, int(hzSys.value/data.frequency/2)):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_DIVIDER[0])
                
                # set divider init to delay signal output
                if not self.dwf.FDwfDigitalOutDividerInitSet(self.hdwf, data.port, data.divider_init):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_DIVIDER_INIT[0])
                # set counter info
                if not self.dwf.FDwfDigitalOutCounterInitSet(self.hdwf, data.port, data.startHigh, data.offset_counter):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_COUNTER_INIT[0])
                
                # 1 tick low, 1 tick high
                if not self.dwf.FDwfDigitalOutCounterSet(self.hdwf, data.port, data.counter1, data.counter2):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_COUNTER_VALUES[0])
                
                #autoConfig = _ct.c_int()
                #self.dwf.FDwfDeviceAutoConfigureGet(self.hdwf, _ct.byref(autoConfig))
                #print(autoConfig.value)
                
                if not self.dwf.FDwfDigitalOutConfigure(self.hdwf, 1):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_START_INSTRUMENT[0])
                
                return self._retval_helper(self._error_codes.OK[0])

    Attached is a photo of the signal with the interrupt

    MicrosoftTeams-image (4).png

  3. Thanks a lot. Now it works fine.

     

    I have another question. Is it somehow possible to output a constant clock signal on one pin and a single pulse with a delay on another pin?

    I need to setup the pulse in one function, leave it and than enter another function that processes the pulse with the delay and the continuous clock.

    I tried to visualize it below. The blue squares are the separate functions, the clock can run continuously or just in the yellow marked area. 

     

    Thanks

    grafik.thumb.png.1fef60e55e516d712c3335d435d3cf4e.png

  4. Hello,

    I want to use the FDwfDigitalOutWaitSet and FDwfDigitalOutRepeatSet functions but they seem to have no effect.

    This is the code:

     # init instance of Analog discovery as testDevice
        testDevice = AnalogDiscovery2()
        
        # open serial connection and print return value
        retval = testDevice.open_serial_connection()
        print("open device retval: " + retval[2])
       
        
        testDevice.dwf.FDwfDigitalOutTriggerSourceSet(testDevice.hdwf, _ct.c_ubyte(1))
        
        retval = testDevice.dwf.FDwfDigitalOutRunSet(testDevice.hdwf, _ct.c_float(2))
        print("set run time: ", retval)
        retval = testDevice.dwf.FDwfDigitalOutWaitSet(testDevice.hdwf, _ct.c_float(2))
        print("set wait time: ", retval)
        testDevice.dwf.FDwfDigitalOutRepeatSet(testDevice.hdwf, 1)
       
        # set clock signal output
        data = _ds.SET_SINGLE_CLOCK_STRUCT()
        data.frequency = 500000
        data.port = 3
        retval = testDevice.set_single_clock(data)   #function attached below
        print("set clock retval: " + retval[2])
       
        testDevice.dwf.FDwfDigitalOutConfigure(testDevice.hdwf, 1)

        testDevice.dwf.FDwfDeviceTriggerPC(testDevice.hdwf)
       
        # wait for input to pause program
        input("Press enter to stop")
        
        # close connection and exit program
        retval = testDevice.close_connection()
        print("close device retval: " + retval[2])
        # retval = testDevice.close_connection()
        # print(retval)

     

    set_single_clock:

    def set_single_clock(self, data: _ds.SET_SINGLE_CLOCK_STRUCT) -> (int, type(None), str):
                
                # configure and start clock
                hzSys = _ct.c_double()
                if not self.dwf.FDwfDigitalOutInternalClockInfo(self.hdwf, _ct.byref(hzSys)):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_GET_CLOCK_INFO[0])
                
                # enable DIO-0
                if not self.dwf.FDwfDigitalOutEnableSet(self.hdwf, data.port, 1):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_ENABLE[0])
               
                if not self.dwf.FDwfDigitalOutDividerSet(self.hdwf, data.port, int(hzSys.value/data.frequency/2)):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_DIVIDER[0])
                
                # set counter info
                if not self.dwf.FDwfDigitalOutCounterInitSet(self.hdwf, data.port, data.startHigh, data.offset_counter):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_COUNTER_INIT[0])
                
                # 1 tick low, 1 tick high
                if not self.dwf.FDwfDigitalOutCounterSet(self.hdwf, data.port, data.counter1, data.counter2):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_SET_COUNTER_VALUES[0])
                
                if not self.dwf.FDwfDigitalOutConfigure(self.hdwf, 1):
                    return self._retval_helper(self._error_codes.NOK_FAILED_TO_START_INSTRUMENT[0])
                
                return self._retval_helper(self._error_codes.OK[0])

     

×
×
  • Create New...