Jump to content
  • 0

Using DeviceAutoConfigure


Philipp

Question

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

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @Philipp

During digital-out configuration the outputs are stopped.
If the pulse timing is not important you could control this DIO using the digital-io functions.
The digital-io, in and digital-out work in independently. The DIOs are multiplexed in the device, the digital-io function having higher priority.
If timing is important you could use ROM logic to control the pulse DIO based on another DIO. This is a bit complicated to setup, see:
https://digilent.com/reference/waveforms_-_rom_logic

Link to comment
Share on other sites

  • 0

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?

Link to comment
Share on other sites

  • 0

Hi @Philipp

Yes, the digital-io functions let you control the dios from software, like the StaticIO interface in the WaveForms app.

With AutoConfigure 1 calling any FDwfDigitalOut*Set will stop the instrument and needs to be started with FDwfDigitalOutConfigure.

AutoConfigure:
- 1 (default) a call to any *Set function will configure and stop the respective instrument. This is not ideal for larger projects where a lot of Sets are called.
- 3 the analog-out state remains unchanged, this could be useful for frequency, amplitude, offset... adjustment without restarting the generator *
- 0 (recommended) device is not configured, call *Configure after *Sets
* Having AutoConfigure 0, the FDwfAnalogOutConfigure can be called with option 3 to apply new settings on the fly.

image.png

image.png

image.png

image.png

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...