Jump to content
  • 0

Pattern Generation with SDK on Analog Discovery 2


Citronjack

Question

Hi there,

 

I am currently working on generation patterns with the AD2. I am using python. I closely looked at the example. Among other functions it calls:

rgdSamples = (c_double*cSamples)()
dwf.FDwfAnalogOutNodeDataSet(hdwf, channel, AnalogOutNodeCarrier, rgdSamples, cSamples)

The maximum for cSamples seems to be 1024, even though in the GUI I can select a value up to 8192, why is that? (I did adjust the length of rgdSampleTmp)

Also, if I just setup up the rdgSamples, I cannot observe an output, I had to find a work around using bytearray and then creating a ctype. I did not find a clear explanation why that is.

rgdSampleTmp = bitstring.BitArray(
                '0x'
                '0000000000000000000000000000000000000000000000000000000000000000'
                'FFFFFFFFFFFFFFFFFFFFFF0000000000000000000000'
                '0000000000000000000000FFFFFFFFFFFFFFFFFFFFFF'
                'FFFFFFFFFFFFF0000000000000000000000000000000'
                '00000000000000000000000000000000000000000000'
                '0000000000000000') # 256 bytes --> 1024 bit
ba = bytearray(data.bytes)
rgdSample = (c_uint8 * len(ba)).from_buffer(ba)

Thank you very much for reading this and trying to help out, I am available for further questions. Have a nice day!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi @attila,

thank you for your answer, it helped me out. Another question though. I want to generate a pattern that look like the signals below, they should repeat every 6ms. The time both the ACT and SEND signal are not zero is called Tact=0.2ms. The ACT signal should alternate with a frequency of 21kHz. 

image.thumb.png.5f785919e664a508e884cbd293ba5983.png

I created 2 arrays and loaded the ACT and SEND values into them respectively.

sendSignal = (c_double*samples)() 
actSignal = (c_double*samples)()

What seems to be the problem right now, is to find the correct values for the runTime, waitTime and the divider. I am not sure how to select them and my trial and error approach was not successful. I want to generate 8 different ACT and SEND signal pairs, i.e. use all 16 GPIOs. Later on, I want both the ACT and SEND signal pair to have a specific delay in the range from 0 to 350ms. The maximum Tact=400ms. So I am thinking to define the signals for 1ms and then wait for the remaining 5ms.

dwf.FDwfDigitalOutRunSet(hdwf, c_double(runTime))
dwf.FDwfDigitalOutWaitSet(hdwf, c_double(waitTime))
FDwfDigitalOutDividerSet(hdwf, c_int(0), c_int(signalDiv))

Also, in the GUI I can set a frequency value, I did not find how to manipulate it

image.png.bc69a7551edeb1d3bc3189bd8c67d756.png

 

Edited by Citronjack
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...