Jump to content
  • 0

Multiple patterns with precise delay using AD2


DYLee

Question

 Hi, I'm using AD2 to generate precise SPI commands for my application using Intan's RHS2216 IC.

 

 The IC is a sort of constant current source which on/off and polarity is controllable via SPI. And I use it to make two different patterns, one is a maximum-length sequence and another is a simple biphasic pulse.

 

 The problem is that the AD2 supports up to 16k bits pattern and my MLS pattern requires about 15k bits so I have to divide two patterns.

 

 It was able to store both patterns using two separate pattern generators in WaveForms 3.19.5, but it seems that a single run using the script gives me an unintended amount of delay between two patterns.


 I want the patterns to appear with a specific amount which is an integer multiple of my recording device's sampling period but how can I achieve this?

 

 I think the first possibility is manually adjust the delay between patterns with the wait() function but it jitters according to the PC's OS. Then, maybe the trigger can be used but is it work well even if the two pattern generators are sharing the same pin?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
12 hours ago, attila said:

Hi @DYLee

You should be able to send 15kbit of SPI data in one transfer when using device configuration with 16Ki Pattern buffer and the Delays are zero.
With any delay, half of the buffer of bits, including the delay bit count.

image.png

 

 Thanks for the reply but maybe my question was not clear.

 

 As @attila said, SPI protocol can send 16k bits length of data. However, what I have to do is send lots of SPI commands each consisting of 32-bit and precisely configure the interval between them. To do so, I'm using a pattern generator of AD2 as the figures below.

 

2023-06-09091509.thumb.png.2c5f32f12f0c40326a4777121039b4a8.png

2023-06-09092454.thumb.png.b10eb0d0b791e034cf492248cc3d8999.png

 

 As the interval between CS low edge (except between the first and second) should be an integer multiple of 40.96 microseconds in my application, I adjusted the clock frequency and inserted several bits between them and this is okay. And I want the first pattern comes 30 times repeatedly and then the second pattern comes. Repetition is done simply by setting the pattern generator's repeat count to 30. But it was not able to hardcode all the patterns in a 16k bits buffer, so I separated them.

 

Quote

Patterns1.single();

wait('0.4096')

Patterns2.single();

 

 The problem is that when I tried to run the application by the script above, the interval between pattern 1 and pattern 2 is not an integer multiple of 40.96 microseconds.

 Also, it seems that when I run a pattern generator, another one becomes a busy state. Is it okay?

Link to comment
Share on other sites

  • 0

Hi @DYLee

The software delays have precision and resolution of milliseconds.
The wait function argument unit is second, 0.001 = 1ms
Yes, the device has one digital-out instrument which can be controlled by one software interface at a time, the others show busy status.

Can't you reduce the SPI frequency, so the bit delays will be longer and consume less custom buffer ?

For more device pattern buffer the AD3, Digital Discovery and ADP3x50 have 32Ki, the DD has play mode for up to 2G bits.

Link to comment
Share on other sites

  • 0
On 6/9/2023 at 8:49 PM, attila said:

Yes, the device has one digital-out instrument which can be controlled by one software interface at a time, the others show busy status.

 So, is this mean if I assign custom buffers for different pattern interfaces and set them to be triggered by the same pin, only one interface in not-busy state will be triggered?

 

On 6/9/2023 at 8:49 PM, attila said:

Can't you reduce the SPI frequency, so the bit delays will be longer and consume less custom buffer ?

 I tried this but still, the buffer size is not enough for a x30 times pattern 1 then x30 times pattern 2.

 

On 6/9/2023 at 8:49 PM, attila said:

The wait function argument unit is second, 0.001 = 1ms

 With the additional delays per script line and, in my case, even more delay for Pattern2 to be ready?

Link to comment
Share on other sites

  • 0

Hi @DYLee

On 6/11/2023 at 7:47 AM, DYLee said:

So, is this mean if I assign custom buffers for different pattern interfaces and set them to be triggered by the same pin, only one interface in not-busy state will be triggered?

Yes

On 6/11/2023 at 7:47 AM, DYLee said:

With the additional delays per script line and, in my case, even more delay for Pattern2 to be ready?

Yes

Could you please attach or send me more details about the pattern (such as the workspace) to see if I have any ideas on how to optimize the generation?

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