Registering event time

MEDState Notation Repository Forums Coding Help Archive Registering event time

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13235
    Med_Support
    Moderator
    salvador.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.

    #13236
    Med_Support
    Moderator
    Gary 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: ---> S2 
                  
    

    It should do what you want. Just remember to change the inputs over to Level Mode.

    #13239
    Med_Support
    Moderator
    salvador.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).

    #13241
    Med_Support
    Moderator

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

    #13243
    Med_Support
    Moderator
    salvador.arrazola

    Thank you so much.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.