Jump to content
  • 0

DigiDisco: FDwfDigitalOutTypeSet for clock mode


HoWei

Question

In the Waveforms GUI there is a pattern generation mode "clock", that allows to setup the output as clock.

What would be the equivalent using the SDK (e.g. with python) ?

Does "DwfDigitalOutTypeCustom" provide the "clock" function ?

 

Also in Waveforms GUI there is an option to create a "bus" of signals - is there an equivalent in the SDK ?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Hi @HoWei

In the SDK the lines/channels are configured individually. 
There is no notion of bus, but this should be easily created in custom application/script.

The DigitalOut_BinrayCounter.py configures a 16 bit binary counter 'bus':

hzSys = c_double()
dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzSys))
print("Internal frequency is " + str(hzSys.value/1e6)+" MHz")

# 100kHz counter rate, SystemFrequency/100kHz
cntFreq = c_uint(int(hzSys.value/1e5))

# generate counter
for i in range(0, 16):
    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(i), c_int(1))
    # increase by 2 the period of successive bits
    dwf.FDwfDigitalOutDividerSet(hdwf, c_int(i), c_int(1<<i))
    dwf.FDwfDigitalOutCounterSet(hdwf, c_int(i), cntFreq, cntFreq)

The DigitalOut_CustomBus.py outputs a sample array on 16 bit 'bus':

hzRate = 1e6 # frequency
cChannels = 16
cSamples = 16
cBytes = int(math.ceil(cSamples/8))
rgSamples = [0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F]

hzDO = c_double()
dwf.FDwfDigitalOutInternalClockInfo(hdwf, byref(hzDO))


for channel in range(cChannels): # configure output channels
    rgBits = (cBytes*c_byte)() # custom bit array for each channel
    for sample in range(cSamples): # using the bits from samples array construct the bit array for the channel
        if(1&(rgSamples[int(sample)]>>channel)) : rgBits[int(sample/8)] |= 1<<(sample&7)
        else : rgBits[int(sample/8)] &= ~(1<<(sample&7))
    dwf.FDwfDigitalOutEnableSet(hdwf, c_int(channel), c_int(1))
    dwf.FDwfDigitalOutTypeSet(hdwf, c_int(channel), DwfDigitalOutTypeCustom)
    dwf.FDwfDigitalOutDividerSet(hdwf, c_int(channel), c_int(int(hzDO.value/hzRate))) # set sample rate
    dwf.FDwfDigitalOutDataSet(hdwf, c_int(channel), byref(rgBits), c_int(cSamples))

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...