Using Z pulse to reset program
MEDState Notation Repository › Forums › Coding Help Archive › Using Z pulse to reset program
- This topic has 3 replies, 1 voice, and was last updated 9 years, 2 months ago by
Med_Support.
-
AuthorPosts
-
April 7, 2017 at 3:27 pm #12665
Med_Support
ModeratorEtaire
Hi, I’m coding for a motor impulsivity go/no go task for hens where they are trained to peck for a food reward when the PeckKey turns green (go signal) and to inhibit from pecking if the PeckKey light is not green. The birds will be given 10 seconds to peck the green light, if pecked during the 10 seconds, the light will extinguish and a food reward will come out. An inter-trial interval (ITI) of 5 seconds will occur followed by a variable pre cue period (that will be controlled by the experimenter). All responses that occur outside of the go signal resets the program with Z pulse. However, the z-pulse in my program does not work. I cannot seem the reset the program during pre-cue period.
Thanks.\ Inputs ^PeckKey = 3 ^ControlKey = 2 \ Outputs ^Pellet = 2 \light colours g = green r = red w = white ^Light1g = 6 \controlKey light ^Light1w = 5 ^Light1r = 4 ^Light2r = 7 \PeckingKey light ^Light2g = 9 ^Light2w = 8 ^Door = 1 ^No =10 \Variables \X = 1 (pecks that occur during go signal) , 0 (pecks that occur NOT at go signal) S.S.1, S1, 0.01":OFF ^Pellet; OFF ^Light1w; OFF ^Light2W; OFF ^Light1r; OFF ^Light2r; OFF ^Light1g; OFF ^Light2g; SET X =0 --->S2 S2, 3": ---> S3 S3, #R^ControlKey: ON^Light1w ---> S4 \start of pre cue period S4, 2#R^ControlKey: OFF ^Light1w; OFF ^Light2r; ON ^Light1g; ON ^Light2g; SET X = 1 ---> S5 \end of precue period and start of go cue period S5, 10":SET X = 0; OFF ^Light2g; ON^Light2r --->S1 \10s go cue period duration #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S.S.2, S1, #R^PeckKey: ---> S2 S2, 0.01": IF X = 1 [@True, @False] @True: --->S3 \if pecks occur at go signal, reward with pellet @False: Z1 --->S1 \if pecks occur anytime else, reset program with Z pulse S3, 0.01":ON ^Pellet; OFF ^Light1g; OFF ^Light2g --->S1
April 10, 2017 at 9:04 am #12666Med_Support
ModeratorGary Bamberger
Hello,
In S.S.2 you are checking IF X = 1. The only time X = 1 is when the program is in S.S.1, S5. When the program is in S.S.1, S5 that is when you want a reward to be issued. When the program is in S.S.1, S1 – S4 you don’t want a reward to be issued.
The only place that you are looking for a Z1 pulse is in S.S.1, S5 and that is the only place it is not needed. The following change should work for you:
\ Inputs ^PeckKey = 3 ^ControlKey = 2 \ Outputs ^Pellet = 2 \light colours g = green r = red w = white ^Light1g = 6 \controlKey light ^Light1w = 5 ^Light1r = 4 ^Light2r = 7 \PeckingKey light ^Light2g = 9 ^Light2w = 8 ^Door = 1 ^No =10 \Variables \X = 1 (pecks that occur during go signal) , 0 (pecks that occur NOT at go signal) S.S.1, S1, 0.01":OFF ^Pellet; OFF ^Light1w; OFF ^Light2W; OFF ^Light1r; OFF ^Light2r; OFF ^Light1g; OFF ^Light2g; SET X =0 --->S2 #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S2, 3": ---> S3 #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S3, #R^ControlKey: ON^Light1w ---> S4 \start of pre cue period #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S4, 2#R^ControlKey: OFF ^Light1w; OFF ^Light2r; ON ^Light1g; ON ^Light2g; SET X = 1 ---> S5 \end of precue period and start of go cue period #Z1: OFF^Light1g; ON^Light1r--->S1 \reset S5, 10":SET X = 0; OFF ^Light2g; ON^Light2r --->S1 \10s go cue period duration S.S.2, S1, #R^PeckKey: ---> S2 S2, 0.01": IF X = 1 [@True, @False] @True: --->S3 \if pecks occur at go signal, reward with pellet @False: Z1 --->S1 \if pecks occur anytime else, reset program with Z pulse S3, 0.01":ON ^Pellet; OFF ^Light1g; OFF ^Light2g --->S1
Now when the program is not in the cue period any pecks will reset the program.
Gary
April 10, 2017 at 11:23 am #12669Med_Support
ModeratorEtaire
THANK YOU SO MUCH!!
…
I have one more question: My code here doesn’t seem to work .. I want my no go cue to reset when PeckKey is pressed during the 3 seconds of the no go cue. When I added “ #Z1: OFF ^Light1g; ON ^Light1r —> S1″ to S5, my code stopped working completely.
\ Inputs ^PeckKey = 3 ^ControlKey = 2 \ Outputs ^Pellet = 2 \light colours g = green r = red w = white ^Light1g = 6 \controlKey light ^Light1w = 5 ^Light1r = 4 ^Light2r = 7 \PeckingKey light ^Light2g = 9 ^Light2w = 8 ^Door = 1 ^No =10 LIST A = 1, 2, 3, 4 S.S.1, S1, 0.01": ~ToneOFF(MG,1);~; RANDI B = A; SHOW 1, GO/NOGO, B; OFF ^Pellet; OFF ^Light1w; OFF ^Light2W; OFF ^Light1r; OFF ^Light2r; OFF ^Light1g; OFF ^Light2g; SET X =0 --->S2 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S2, 5": ON^Light1w; ON^Light2w ---> S3 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S3, 0.01": IF (B = 2) OR (B = 4) [@True, @False] @True: ON ^Light1g --->S4 \no go @False: ON^ Light1r--->S6 \go #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S4, #R^ControlKey: OFF ^Light1w; OFF ^Light2w; ON ^Light1r; ON ^Light2r; Z2 ---> S5 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S5, 3": ~ToneOFF(MG,1);~;OFF ^Light1r; OFF ^Light2r --->S8 S6, #R^ControlKey: OFF ^Light1w; OFF ^Light2w; ON ^Light1g; ON ^Light2g; SET X = 1 ---> S7 #Z1: OFF ^Light1g; ON ^Light1r ---> S1 S7, 10":SET X = 0--->S1 S8, 0.01": ON ^Pellet--->S1 S.S.2, S1, #R^PeckKey: ---> S2 S2, 0.01": IF X = 1 [@True, @False] @True: SET X = 1 --->S3 @False: Z1 --->S1 S3, 0.01":ON ^Pellet; OFF ^Light1g; OFF ^Light2g; Z1 --->S1 S.S.3, S1, 0.01": ~SetRack(MG,1) ;~; ~InitANL926;~; --->S2 S2, #Z2: ~ToneOn(MG,1);~; Z1 ---> S2
April 14, 2017 at 9:55 am #12672Med_Support
ModeratorGary Bamberger
In S.S.4, S1 when a response happens on the ControlKey the program issues a Z2 pulse and then —> S5.
The Z2 pulse is responded to in S.S.3, S2 which issues a Z1 pulse.
S.S.1 would now be in S5 so it responds to the Z1 pulse and —> S1 and the 3″ timer never happens.To fix this don’t issue a Z1 pulse in S.S.3, S2.
One other thing that I noticed is that you are not calling the InitANL926 command until S.S.3, but in S.S.1 you are issuing a ToneOn command. This may work under most circumstances, but you will eventually run into a time when the program doesn’t work properly.
You should move S.S.3 to be above S.S.1.
Gary
-
AuthorPosts
- You must be logged in to reply to this topic.