Jump to content
  • 0

Waveforms SDK run pulse once after waiting for 2 seconds


Philipp

Question

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])

 

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Yes, exactly. The TriggerPC call works as intended. But no matter what I set as Run/Wait/Repeat, the pulse signal starts immediatly after the TrigerPC call and doesn't stop.

Am I forgetting some setting?

I also tried to disable the Autoconfig.

I am using a Analog Discovery 2.

Edited by Philipp
Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

Hi @attila

thanks for the quick response.

I didn't know about this difference between Analog and Digital Discovery but I can use a Digital Discovery for this.

Is there any documentation on how to use the Delay and Repetition function for single DIOs in python? I couldn't find anything in the SDK Reference Manual or the python examples. Maybe I was looking in the wrong document.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...