using two digital output ports

Discussions and questions about the script language
kayeon
Posts: 3
Joined: 16 May 2022, 14:32
Contact:

using two digital output ports

Unread postby kayeon » 16 May 2022, 14:55

Dear spike2 supporter,

Hi,
I'm a newbie of spike2.
I've been trying to trigger two stimulators controlled by spike2 sequencer using a script.
Currently, because I need to create a specific type of pulse, I need to use two digital output ports connected to each stimulator device and
I'd like to jump between these devices within the same start button created by a sequencer script, so that for example, I can send the first stimulation, and then when the first is off,
the next stimulator is triggered with the least delay possible from the second output port.

My current working script has been attached, and using this, the stimulator from digital output port 0 works well. But is there a way to inject port1 within this loop so that I can trigger
two devices in a serial manner? If yes, would you point me into the right direction
to make this work?

Thank you in advance,

best
Kayeon
Attachments
script1.png

User avatar
Tim Bergel
Site Admin
Posts: 2379
Joined: 19 Jun 2008, 14:40
Location: Cambridge, England
Contact:

Re: using two digital output ports

Unread postby Tim Bergel » 16 May 2022, 15:15

Hi Kayeon,

I'm not quite sure what you want here so please bear with me.

If you want to generate outputs to the two stimulators at the same time, you can simply extend the bits changed by the DIGOUT instructions - the dots indicate outputs which are not changed. So you could set the outputs for two stimulators with something like DIGOUT [...0101].

If you want to first generate 100 outputs to stimulator A and when that is done generate a similar train of pulses for stimulator B, you can extend your sequence to include a second loop much like the first one which starts after the first one finishes.

If you want a loop that 100 times generates a pulse for stimulator A and then a pulse for stimulator B, you can put the extra instructions inside the loop before the DBNZ2 instruction. You will probably need to adjust the delay instructions to get the effect you want, but it should be straightforward.

All of those are relatively easy though of course you may have problems getting the timing exactly how you want it. Another possibility, however, is that you want to have what is in effect two loops executing at the same time but perhaps for different number of pulses or with different timing in the two loops. That is rather difficult to achieve because the sequencer is not really designed for this.

I hope that helps. If you do need two independent simultaneous loops, or just have trouble working out what is needed, do feel free to get back to me.
Tim Bergel Cambridge Electronic Design

kayeon
Posts: 3
Joined: 16 May 2022, 14:32
Contact:

Re: using two digital output ports

Unread postby kayeon » 16 May 2022, 16:10

Thank you very much for your help.

This below is exactly what I want to do.

"If you want a loop that 100 times generates a pulse for stimulator A and then a pulse for stimulator B, you can put the extra instructions inside the loop before the DBNZ2 instruction. You will probably need to adjust the delay instructions to get the effect you want, but it should be straightforward."

Here, I'm still not familiar with DIGOUT instruction. I get the part when using just one stimulator where bits are on and off with these numbers DIGOUT [......00] and DIGOUT [......01], but would this below code work to make 2nd stimulator on and off within the loop? (I removed all delay part just to make this example simpler). If not, would you point me in the right direction?

SET 0.1,1,0

DIGOUT [00000101]
HALT

‘m MARK 83
DIGOUT [……0000]
LDCNT2 100
ES: DIGOUT [……0001] 1st stimulator on
DIGOUT [……0000] off
DIGOUT [……0100] 2nd stimulator on
DIGOUT [……0000] off
DBNZ2 ES

Thanks a lot!

Best
Kayeon

User avatar
Tim Bergel
Site Admin
Posts: 2379
Joined: 19 Jun 2008, 14:40
Location: Cambridge, England
Contact:

Re: using two digital output ports

Unread postby Tim Bergel » 16 May 2022, 16:52

Hi Kayeon,

Yes, the code you posted would work because you know that the output bits for the other stimulator have to stay at zero. If you wanted to avoid any possible problems with the other stimulator's bits then something like:

ES: DIGOUT [……..01] 1st stimulator on
DIGOUT [……..00] off
DIGOUT [……01..] 2nd stimulator on
DIGOUT [……00..] off

is neater as the dots show outputs that do not change.
Tim Bergel Cambridge Electronic Design

kayeon
Posts: 3
Joined: 16 May 2022, 14:32
Contact:

Re: using two digital output ports

Unread postby kayeon » 16 May 2022, 17:05

wow, I get it.
Thank you so much for guiding me.
This is great!


Best,
Kayeon

User avatar
Tim Bergel
Site Admin
Posts: 2379
Joined: 19 Jun 2008, 14:40
Location: Cambridge, England
Contact:

Re: using two digital output ports

Unread postby Tim Bergel » 17 May 2022, 07:50

Glad to hear it! The sequencer system is complex and takes some effort to understand, but it is very powerful.
Tim Bergel Cambridge Electronic Design


Return to “Script language”

Who is online

Users browsing this forum: No registered users and 1 guest

cron