# Time stamp animation

**URL:** <https://discourse.psychopy.org/t/time-stamp-animation/13992>\
**Category:** Coding\
**Created:** [June 5, 2020, 9:39am UTC](https://discourse.psychopy.org/t/time-stamp-animation/13992 "2020-06-05T09:39:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanJ](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@jeanJ](https://discourse.psychopy.org/u/jeanJ)\
**Post date:** [June 5, 2020, 9:39am UTC](https://discourse.psychopy.org/t/time-stamp-animation/13992/1 "2020-06-05T09:39:38Z")

</div>

Hello,  
i would to animate an object and would like to display it each refresh rate of the screen.  
My code is :

```auto
timing=0
        for frameN in range (timeStim*60):
            x=self.queueGui.get_nowait() 
            y=0
            print(timing)
            self.stimU.draw()
            self.stimU.pos =(x,y)
            timing=self.windo.flip()

```

‘timeStim’ is in second.  
My increment of my variable ‘timing’ is not related to my refresh rate (0.0016s) and i dont know why!  
Any idea?  
Thanks!

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [June 6, 2020, 8:26am UTC](https://discourse.psychopy.org/t/time-stamp-animation/13992/2 "2020-06-06T08:26:19Z")

</div>

Your code is difficult to read, because we know little of the context. The code seems to be part of a custom class definition and we have for example no idea, what `queueGui.get_nowait() ` does. That being said, I don’t think that you need the `print` function to check the timing. Use Psychopy’s [logging module](https://www.psychopy.org/api/logging.html) and the window method [psychopy.visual.Window.logOnFlip](https://www.psychopy.org/api/visual/window.html#psychopy.visual.Window.logOnFlip). Or record your [frame intervals](https://www.psychopy.org/api/visual/window.html#psychopy.visual.Window.recordFrameIntervals).  
These options distort your timing less than the print statement, which itself takes considerable time if you call it on every frame.

---

<div class="post-metadata">

**Author:** ![jeanJ](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@jeanJ](https://discourse.psychopy.org/u/jeanJ)\
**Post date:** [June 7, 2020, 4:21pm UTC](https://discourse.psychopy.org/t/time-stamp-animation/13992/3 "2020-06-07T16:21:39Z")

</div>

Thanks @LukasPsy,  
i would like to animate an objet in psychopy (stimU) with data recorded in real time by another soft.  
I understand now that maybe i have not see the real problem. My data come from a lifo queue (queueGui) feed by another soft in real time (140Hz) , i can set this frequency. However i don’t know how to “synchronise” data of the other soft with the displaying stimuli of psychopy (stimU) in order to avoid lag between data recorded and stimU object.  
I thought about that but no idea for the moment…  
Thanks!
