# How to create a clock that is relative to the beginning of the experiment?

**URL:** https://discourse.psychopy.org/t/how-to-create-a-clock-that-is-relative-to-the-beginning-of-the-experiment/22813
**Category:** Builder
**Tags:** timing
**Created:** [May 6, 2021, 9:25am UTC](https://discourse.psychopy.org/t/how-to-create-a-clock-that-is-relative-to-the-beginning-of-the-experiment/22813 "2021-05-06T09:25:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jana\_Maresch](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jana_maresch/32/9295_2.png) [@Jana\_Maresch](https://discourse.psychopy.org/u/Jana_Maresch)
#### Post date: [May 6, 2021, 9:25am UTC](https://discourse.psychopy.org/t/how-to-create-a-clock-that-is-relative-to-the-beginning-of-the-experiment/22813/1 "2021-05-06T09:25:28Z")

</div>

Win10, PsychoPy version 2020.2.5, standalone.

**What are you trying to achieve?:**  
I’ve build a visuomotor rotation experiment but now I’m struggling with some of the timers. I’m using the start time of some of my components and I need to align this start time with an event (movement onset).

**What did you try to make it work?:**  
I used core.Clock as my clock for the movement onset. But apparently this clock starts counting at the time it has been created and not at the beginning of the experiment (like the component clocks do). I tried resetting my clock to the global time (by using the win.FutureFlipTime(clock=None), which is what the component clocks are set to) but this didn’t work. I also tried creating my clock at the beginning of the experiment, which decreased the difference between the component clocks and my own clock but it didn’t align the two times. I also tried using core.motonicClock but it works differently than the other clocks and I don’t understand how to extract the time from it…

---

<div class="post-metadata">

### Author: ![Jana\_Maresch](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jana_maresch/32/9295_2.png) [@Jana\_Maresch](https://discourse.psychopy.org/u/Jana_Maresch)
#### Post date: [May 6, 2021, 12:08pm UTC](https://discourse.psychopy.org/t/how-to-create-a-clock-that-is-relative-to-the-beginning-of-the-experiment/22813/2 "2021-05-06T12:08:10Z")

</div>

So I got a step further. I now used the `win.FutureFlipTime(clock=None)` to reset my own clock to the global time that the components in my routine are using (I’m doing this in a code component in the “begin routine tab”). This, however, gives me decreasingly negative times. The timing actually looks right but I don’t understand why it’s negative. If I print the times of `win.FutureFlipTime(clock=None)` and of `tThisFlipGlobal` (which should be the same variable according to the Coder), `tThisFlipGlobal` gives me positive values and `win.FutureFlipTime(clock=None)` gives me the exact same ones with a minus in front of it. Can anyone help me or explain to me what’s happening here?

---

<div class="post-metadata">

### Author: ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)
#### Post date: [May 7, 2021, 8:40am UTC](https://discourse.psychopy.org/t/how-to-create-a-clock-that-is-relative-to-the-beginning-of-the-experiment/22813/3 "2021-05-07T08:40:20Z")

</div>

Hi there,

this thread might be helpful. [Saving stimuli time from the beginning of the experiment - #8 by Becca](https://discourse.psychopy.org/t/saving-stimuli-time-from-the-beginning-of-the-experiment/20973/8)

---

<div class="post-metadata">

### Author: ![Jana\_Maresch](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jana_maresch/32/9295_2.png) [@Jana\_Maresch](https://discourse.psychopy.org/u/Jana_Maresch)
#### Post date: [May 9, 2021, 7:13am UTC](https://discourse.psychopy.org/t/how-to-create-a-clock-that-is-relative-to-the-beginning-of-the-experiment/22813/4 "2021-05-09T07:13:55Z")

</div>

This is great, thank you! I already figured out parts of it but your reply to the thread explained it all in detail.
