Registering event time
MEDState Notation Repository › Forums › Coding Help Archive › Registering event time
- This topic has 4 replies, 1 voice, and was last updated 8 years, 8 months ago by
Med_Support.
-
AuthorPosts
-
January 9, 2007 at 8:59 pm #13235
Med_Support
Moderatorsalvador.arrazola
Hi, do you know if it’s possible to register an event duration, for example how many seconds or miliseconds a rat has been with its head into the head sensor in the feeder. I know I can detect the time when the event happens, but I need to detect how much time take an event.
I don’t know if I explained well? I you know something about, please make a replay.
January 10, 2007 at 3:39 pm #13236Med_Support
ModeratorGary Bamberger
Take a look at this sample source code:
\*************************************************** \ BEAM BREAK DEFINED - 20ms BREAK, 20ms RELEASE \*************************************************** S.S.2, \ Beam Break Defined - 20ms Break, 20ms Release. S1, \ Inputs in Level Mode generate an input "count" on each \ interrupt. With a 10 ms system resolution 2 counts \ will be reached in 20 ms. The Z3 pulse is used to \ signal a completed Beam Break. The second statement resets \ the counter every 20 ms so that a partial Beam Break of \ less than 20 ms will not constitute a Response. #R1: ADD Y; IF Y >= 2 [@BeamBreak, @NoBeamBreak] @Break: Z3; SET Y = 0 ---> S2 @NoBreak: ---> SX 0.02": SET Y = 0 ---> S1 S2, \ As long as the Beam is broken the second statement \ causes a re-entry to this State. This resets the \ the internal 20 ms timer so it never times out. When \ the Beam is released for 20 ms the timer times out \ and a Z4 pulse signals the release. 0.02": Z4 ---> S1 #R1: ---> S2It should do what you want. Just remember to change the inputs over to Level Mode.
January 10, 2007 at 4:41 pm #13239Med_Support
Moderatorsalvador.arrazola
Thank you so much. What do you mean with “Inputs in Level Model”? If I configure that, colud I increase a variable to determinate how much time does an event take?
Thanks for your time, and sorry for my pour English (I’m from the University of Guadalajara in Mexico).
January 15, 2007 at 3:20 pm #13241Med_Support
ModeratorOn the input card (SmartCtrl, SuperPort, Standard Input) there is either a set of jumpers or red switches. You need to change this jumper/switch to Level Mode for the input in question. The default is Transition Mode. In Transition Mode when the lever is pressed you only receive one input. In Level Mode you will continue to receive an input for as long as the lever is pressed.
The sample code will send a Z3 pulse when the lever is pressed and a Z4 pulse when the lever is released. You just need to write some code to track the time difference between the two Z pulses:
S5, #Z3: SET S = 0 ---> S6 S6, 0.01": SET S = S + 0.01 ---> S6 #Z4: ---> S5
You can place this code anywhere in your program. I hope this helps.
January 17, 2007 at 12:07 am #13243Med_Support
Moderatorsalvador.arrazola
Thank you so much.
-
AuthorPosts
- You must be logged in to reply to this topic.