# Optical encoder E38S6G5-600B-G24

**URL:** <https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789>\
**Category:** XOD Programming Questions\
**Created:** [February 9, 2024, 5:24am UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789 "2024-02-09T05:24:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maksimbaturin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/maksimbaturin/32/3876_2.png) [@maksimbaturin](https://forum.xod.io/u/maksimbaturin)\
**Post date:** [February 9, 2024, 5:24am UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/1 "2024-02-09T05:24:24Z")

</div>

I am currently working on a new filament counter, but more accurate on the E38S6G5-600B-G24 optical encoder. I found that there is no interrupt handling in XOD. Digging through the library, I found amperka/pc-interrupt. But how to create an encoder model in this example does not work. I would really appreciate it if you could help me a little.

---

<div class="post-metadata">

**Author:** ![wayland](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/wayland/32/1590_2.png) [@wayland](https://forum.xod.io/u/wayland)\
**Post date:** [February 9, 2024, 9:15pm UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/2 "2024-02-09T21:15:42Z")

</div>

I’ve just wrapped Paul Stoffregen’s [encoder library](https://github.com/PaulStoffregen/Encoder/):  
[https://xod.io/libs/wayland/encoder/](https://xod.io/libs/wayland/encoder/)

This may provide the functionality you require. The XOD library provides two encoder nodes:

- **encoder** : Quadrature encoder.
- **encoder-optimized** : Quadrature encoder with optimized interrupt routines. _N.B. there is a conflict if any other code in your patch or any libraries you use require attachInterrupt()_.

For best performance it is important to use pins that support hardware interrupts.

More information on Paul Stoffregen’s library can be found here:  
[https://www.pjrc.com/teensy/td\_libs\_Encoder.html](https://www.pjrc.com/teensy/td_libs_Encoder.html)

I don’t have an E38S6G5-600B-G24 optical encoder, but apparently they have a strict input voltage range:

> **[FYI: interfacing E38S6G5-600B-G24N 600P/R rotary encoder](https://forum.arduino.cc/t/fyi-interfacing-e38s6g5-600b-g24n-600p-r-rotary-encoder/1057892)**
>
> This is an FYI, sort of a post-mortem. TL;DR: supply \>5V and specify INPUT\_PULLUP. E38S6G5-600B-G24N is an industrial 600 pulse/revolution A/B bi-phase rotary encoder; this product, among many like it, are used for building DIY racing wheel...

---

<div class="post-metadata">

**Author:** ![maksimbaturin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/maksimbaturin/32/3876_2.png) [@maksimbaturin](https://forum.xod.io/u/maksimbaturin)\
**Post date:** [February 10, 2024, 1:28pm UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/3 "2024-02-10T13:28:02Z")

</div>

Thank you so much for the work you’ve done. Everything worked for me. Just one node calculates the entire encoder operation. The encoder accurately counts the pulses and gives the correct result 2400 on the contrary. Now, with this solution, I will be able to assemble a high-precision filament counter. It is essential for my device to use a fast and highly accurate distance measuring device.

---

<div class="post-metadata">

**Author:** ![maksimbaturin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/maksimbaturin/32/3876_2.png) [@maksimbaturin](https://forum.xod.io/u/maksimbaturin)\
**Post date:** [February 10, 2024, 2:00pm UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/4 "2024-02-10T14:00:00Z")

</div>

![photo1707573441](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/c/c5ec6cae74262951bc728c0ae94ae9881d2b7e01.jpeg)  
 ![photo1707578685](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/d/d06df4731d8bcf4b91ec1cbe2e187e946586262d.jpeg)

I checked several times, the accuracy of measuring the length of the filament is ±0.2 mm.

---

<div class="post-metadata">

**Author:** ![maksimbaturin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/maksimbaturin/32/3876_2.png) [@maksimbaturin](https://forum.xod.io/u/maksimbaturin)\
**Post date:** [February 10, 2024, 3:55pm UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/5 "2024-02-10T15:55:17Z")

</div>

[Filament-counter-rotary.xodball](https://forum.xod.io/uploads/short-url/ynhaCQA0YAxWsRjBWD2khjWBpR.xodball) (13.9 KB)

---

<div class="post-metadata">

**Author:** ![wayland](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/wayland/32/1590_2.png) [@wayland](https://forum.xod.io/u/wayland)\
**Post date:** [February 11, 2024, 6:40pm UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/6 "2024-02-11T18:40:14Z")

</div>

Good to hear that the encoder library meets your needs. Thanks for sharing your project.

---

<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:** [March 12, 2024, 6:41pm UTC](https://forum.xod.io/t/optical-encoder-e38s6g5-600b-g24/6789/7 "2024-03-12T18:41:09Z")

</div>

Closed on March 12, 2024, 6:41pm UTC

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