# Tooth pattern output question

**URL:** <https://forum.xod.io/t/tooth-pattern-output-question/4501>\
**Category:** Uncategorized\
**Created:** [October 11, 2020, 12:25pm UTC](https://forum.xod.io/t/tooth-pattern-output-question/4501 "2020-10-11T12:25:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamobrien-sk](https://avatars.discourse-cdn.com/v4/letter/w/74df32/32.png) [@williamobrien-sk](https://forum.xod.io/u/williamobrien-sk)\
**Post date:** [October 11, 2020, 12:25pm UTC](https://forum.xod.io/t/tooth-pattern-output-question/4501/1 "2020-10-11T12:25:25Z")

</div>

I am trying to output simulated toothed wheel signals (crank and cam) and tested the patch below

 ![Capture 3](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/d/d70e47d742ab94317018b9314aaca7efe2ca1b36.png)

It works ok at frequencies up to around 50hz but becomes erratic above that. If only a single output channel is used the frequency can be higher but again runs into some limitation which seems to be related to the clock minimum timing being 0.001. The timing resolution of the output pulses can be increased by upping the counter values but this has the effect of slowing down the loop. Is there a faster clock to use?

Is there a better way to do this in XOD? Your comments are appreciated.

---

<div class="post-metadata">

**Author:** ![evgenykochetkov](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/evgenykochetkov/32/14_2.png) [@evgenykochetkov](https://forum.xod.io/u/evgenykochetkov)\
**Post date:** [October 12, 2020, 4:21pm UTC](https://forum.xod.io/t/tooth-pattern-output-question/4501/2 "2020-10-12T16:21:53Z")

</div>

Hello!

> seems to be related to the clock minimum timing being 0.001

Yes. It is because the [setTimeout](https://xod.io/docs/reference/node-cpp-api/#void-settimeout(context-ctx%2C-timems-timeout)) function is operating in milliseconds.  
At the moment, I am working on the additional API (it will probably be called `setImmediate`) that will not have that limitation and will allow creating a faster clock. It will be available soon.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [October 14, 2020, 4:21pm UTC](https://forum.xod.io/t/tooth-pattern-output-question/4501/3 "2020-10-14T16:21:53Z")

</div>

Closed on October 14, 2020, 4:21pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
