# Using Zynaptik module for encoders \[SOLVED!\]

**URL:** <https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751>\
**Category:** Hardware\
**Created:** [January 9, 2020, 6:43pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751 "2020-01-09T18:43:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 9, 2020, 6:43pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/1 "2020-01-09T18:43:04Z")

</div>

Question to @jofemodo - please share, what kind of wiring should be used with zynaptik module without zynscreen ?

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 9, 2020, 6:51pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/2 "2020-01-09T18:51:39Z")

</div>

Will try to check the soldering once again (and again, and again), maybe I’ve missed the spot somewhere. Of course I can simply replace RPi 3 with 4 in my old case, but isn’t it too simple kind of solution for the people like us 😏 who like to struggle during the process of creating (or co-creating) something new ?

Also, it will be a pity to tear down working zynth rpi3, make new wholes for ventilation etc.

Here I have a chance to design a new case for a second zynthian…

Just a few thoughts…

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [January 9, 2020, 8:41pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/3 "2020-01-09T20:41:09Z")

</div>

Hi @dhrupadiya!

> [@dhrupadiya](#):
>
> Question to @jofemodo - please share, what kind of wiring should be used with zynaptik module without zynscreen ?

Zynaptik is not designed for connecting the controllers. It’s a digital/analog input/output interface with 3 MIDI ports. It’s a part of v3 kit, designed for working with the zynscreen, that include the primary MCP23017 for connecting the controllers easily. Sorry if you thought a different thing …

You can connect the encoders to the zynaptik 40-pin connector using dupont connectors, but the MCP23017 is in a different address (0x21 instead 0x20) for avoiding conflicts with the zynscreen. This secondary MCP23017 is not implemented in the zyncoder library yet. Of course, you could change the address in the zyncoder code to use the secondary MCP23017 as primary, and then use the “standard” MCP23017 wiring from webconf (the 2 INT pins for the secondary MCP23017 are connected to RBPi’s GPIO 25 & 27, the same used by the AllInOne 😉 )

Regards,

---

<div class="post-metadata">

**Author:** ![smiths73v3](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/smiths73v3/32/5452_2.png) [@smiths73v3](https://discourse.zynthian.org/u/smiths73v3)\
**Post date:** [January 10, 2020, 12:51am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/4 "2020-01-10T00:51:58Z")

</div>

> [@jofemodo](#):
>
> Zynaptik is not designed for connecting the controllers. It’s a digital/analog input/output interface with 3 MIDI ports. It’s a part of v3 kit, designed for working with the zynscreen, that include the primary MCP23017 for connecting the controllers easily. Sorry if you thought a different thing …

Glad I saw this, I was toying with the idea of doing the same thing.

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [January 10, 2020, 1:20am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/5 "2020-01-10T01:20:06Z")

</div>

> [@jofemodo](#):
>
> Sorry if you thought a different thing …

I could change your zynaptik by an All-In-One module, if you want …

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 10, 2020, 7:06am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/6 "2020-01-10T07:06:45Z")

</div>

@jofemodo, thanks for explaining everything, because I was going a bit crazy. Checked my soldering once again with tester and all contacts seems to be fine (so my soldering skills are not the reason it’s not working ooohfffff 🙂)

Please tell me, where in zyncoder code I can change the address for the secondary mcp23017. Can it be done with text editor like nano or do I need anything else ?

Last question, do I have to apply this change every time after updating zynthian, would it be overwritten by update ?

Honestly I am happy to take more effort and to make more of zynthian on my own this time — it is really interesting to solve all these things. Also knowing it a bit better might be useful as it helps improving it for the best of our community, I had quiet a few ideas for a long time.

p.s. Glad I am not alone with zynaptik struggle - @smiths73v3 had the same ideas (but no struggle, as @jofemodo has explained the solution)

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 10, 2020, 7:32am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/7 "2020-01-10T07:32:02Z")

</div>

@jofemodo, I have edited zynaptik.c file in zyncoder and changed the address from 0x21 to 0x20, recompiled as mentioned in README.md

Didn’t change a thing (wiring is as you have mentioned - pins are as in AllinOne module).

Am I doing wrong ?

Please tell me how to proceed when you have time.

Thanks !

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [January 10, 2020, 1:37pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/8 "2020-01-10T13:37:24Z")

</div>

Did you re-build the zyncoder library after the change? Note that it’s a C library …

Regarding the update, yes It will overwrite your changes, but i will fix It ASAP …

Regards

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 10, 2020, 2:19pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/9 "2020-01-10T14:19:22Z")

</div>

Well, I’ve recompiled build folder inside zyncoder folder after changing the adress in zynatik.c file from 0x21 to 0x20 - according to instructions in README.md in the same folder. Rebooted and still zynaptic’s mcp23017 is not recognized (GPIO pins 25 & 27 are selected in web config). I didn’t apply all the necessary changes after modification and compilation ?

@jofemodo, thank you for your kind and patient support !!!

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [January 10, 2020, 6:33pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/10 "2020-01-10T18:33:34Z")

</div>

Send the output of this command:

```
gpio i2cd

```

You should see a “21” in the 3th row …

Also, please, show me how you connected the encoders to the Zynaptik …

Regards,

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 10, 2020, 7:15pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/11 "2020-01-10T19:15:39Z")

</div>

![IMG_20200110_221212__01](https://discourse.zynthian.org/uploads/default/original/2X/2/231cbb44df7e2aabc23a83a642d5df8b68fd9d28.jpeg) ![15786835726102498903695441765339](https://discourse.zynthian.org/uploads/default/original/2X/d/d134abb1327fed4984b67f9183b3f70178e90a37.jpeg)  
Sorry for the way this test encoder is made…  
“This is the way” at least for me right now 🙂

p.s. Doctor, am I alive ? Will I play piano again ? ;)))

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [January 10, 2020, 8:27pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/12 "2020-01-10T20:27:43Z")

</div>

Your MCP23017 is alive, so if you:

- changed the port in zyncoder source code + re-build
- connected the encoders in the right way
- choose the right configuration in webconf

It should work 😉

I suppose you are using this info:

> [@CV/Gate input/output](https://discourse.zynthian.org/t/cv-gate-input-output/3182/7):
>
> OK! I’ve a zynaptik with all the parts soldered on it: The second 40-pin connector is the “zynaptik connector” and has this pin-out: Where: GPAx & GPBx are digital input/output pins (MCP23017, at I2C address 0x21) INTA & INTB are interrupt pins for banks GPAx & GPBx, connected to RBPi pins 36 & 37. AD-x are analog input pins (ADS1115) DA-x are analog output pins (MCP4728) I will copy this info to the wiki ASAP wink Regards,

![](https://discourse.zynthian.org/uploads/default/original/2X/d/dbec3563d8723c83768684e6595439237ee00717.png)

Regards,

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 10, 2020, 8:41pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/13 "2020-01-10T20:41:01Z")

</div>

Bless you, @jofemodo 🥳 ! So grateful to you !

Will do it tomorrow.

One small lame question for the last, how to rebuild everything properly ?

”cmake …” & “make” after it from new “build” folder (inside zyncoder folder) will do the thing nicely or any other actions are necessary to rebuilding everything ?

The only committed changes I made are to “zynaptik.c” file were I’ve replaced “0x21” with “0x20” and saved the file before compilation.

Correct ?

It’s enough and should work ?

Thanks a lot !

🙏

---

<div class="post-metadata">

**Author:** ![jofemodo](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/jofemodo/32/2_2.png) [@jofemodo](https://discourse.zynthian.org/u/jofemodo)\
**Post date:** [January 10, 2020, 9:06pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/14 "2020-01-10T21:06:36Z")

</div>

> [@dhrupadiya](#):
>
> One small lame question for the last, how to rebuild everything properly ?

Use the “build.sh” script 😉

> [@dhrupadiya](#):
>
> It’s enough and should work ?

Yes … but AFAIK, nobody did it before 😉

---

<div class="post-metadata">

**Author:** ![smiths73v3](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/smiths73v3/32/5452_2.png) [@smiths73v3](https://discourse.zynthian.org/u/smiths73v3)\
**Post date:** [January 10, 2020, 11:04pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/15 "2020-01-10T23:04:08Z")

</div>

> [@dhrupadiya](#):
>
> Sorry for the way this test encoder is made…  
> “This is the way” at least for me right now

> **[WMYCONGCONG 8 Pcs KY-040 360 Degree Rotary Encoder Module with Knob Cap for...](https://www.amazon.com/WGCD-KY-040-Degree-Encoder-Arduino/dp/B07B68H6R8)**
>
> Specification: KY-040 Module: Working voltage: 5V Pulse circle: 20 Material: electronic components + PCB Size: 26 x 19 x 29mm/1.02 x 0.75 x 1.14inch Diameter of the thread: 7mm/0.27inch Height of the thread: 7mm/0.27inch Knob Cap: Diameter:...

@dhrupadiya if you are going custom anyways, I’ve had some luck with Arduino style 5pin header encoders with 2 changes. First, connect V3.3 to the + pin, and then reorder the GPIOs in the webconfig.

 ![image](https://discourse.zynthian.org/uploads/default/original/2X/c/c4e57e4f0da1fbf2c6132c4b86287e7c4e7219bd.png)

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 11, 2020, 3:40am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/16 "2020-01-11T03:40:36Z")

</div>

> Blockquote[quote=“jofemodo, post:123, topic:3061”]  
> Use the “build.sh” script 😉[/quote]

Great to know - will be my pleasure to use it 🙂

> [@](#):
>
> > It’s enough and should work ?
> 
> Yes … but AFAIK, nobody did it before 😉

@jofemodo, I always wanted to feel myself “Gagarin” with something done for the first time. If zynthian will fly above the clouds I will tell you 😁.

Being serious — when it will finally work, it will be a very nice pathway for anyone in the community to follow, because building zynthian in a custom way happend to be a special kind of fun and now I know it 🙂

Without your support, development team and all our experienced fellow zynthianers it wouldn’t be possible - thanks once again !

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 11, 2020, 3:44am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/17 "2020-01-11T03:44:01Z")

</div>

@smiths73v3, thank you for sharing !

I am using common button infinite encoders now, so not for this time, but it is good to know that Arduino encoders work too !

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 11, 2020, 7:21am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/18 "2020-01-11T07:21:58Z")

</div>

No luck unfortinately. Rebuilt everything a few times (using build.sh at the end), reverted changes a few times - encoder doesn’t work and webconfig says:  
GPIO Expander: Not detected

Inside zynaptik.c file I have changed only the address of MCP23017 (from 0x21 to 0x20).

When it didn’t work, I’ve used some logic and tried to change base pin number to 100 (isn’t it GPB0 on MCP23017 ?) - again no luck. Reverted back.

Tried to connect encoders to as different controls (1, 4) - no luck either.

Somehow MCP23017 seems to be not even initialized.  
According to it’s specifications INTA is pin 20 and INTB is pin 19 if I am correct.

Checked all the connections twice with tester - everything seems to be in order.

Tried MCP23017\_Extra and MCP23017\_Encoders layout for wiring.

Maybe we miss something like extra file include in the code, extra comma or something. Seems to be so close, but yet…

Still looking for solution … 😓

**UPDATE:**

Right now I have discovered, that my MCP23017 on zynaptik is still detected on the address 0x21 even as I have changed it’s address in “/zynthian/zyncoder/zynaptic.c” file to 0x20 (everything compiles and built after changes). Still “i2cdetect -y 1” (same command as ‘gpio i2cd’) shows me it’s address as 21.

Looking for the natural way to change it’s address to 0x20. Some forums says the signal on the pints A0 A1 A2 are respoisible for addressing each MCP23017 if there are several together. Can be up ti eight 🙂

Any ideas how to do it on zynaptik not to burn anything ?

A2 A1 A0 I2c Address  
0 0 0 0x20  
0 0 1 0x21  
0 1 0 0x22  
0 1 1 0x23  
1 0 0 0x24  
1 0 1 0x25  
1 1 0 0x26  
1 1 1 0x27

p.s. If I connect A0 to the GND it should let it be on address 0x20 technically, but wouldn’t it create short circuit ?

**SOLVED !!!**

In a very “russian” radical way I might say. There was some current on A0 of MCP23017 (have no idea 5 or 3.3 volts) and I have just cut this contact and immediately webconfig says:

**GPIO Expander:** MCP23017

I have 2 spare MCP chips so I sacrificed one.

Now zyncoder\_test shows activity on connected encoder and I can proceed further.

So for those, who would have similar approach with zynthian to make zynaptik module work as standalone mcp23017 extender as well as analog and digital IO extention, you need to change two things in zynaptik.c:

```
    #define ZYNAPTIK_MCP23017_I2C_ADDRESS **0x20** (was 0x21) 
    #define ZYNAPTIK_MCP23017_BASE_PIN **100** (was 200)

```

Then follow the instructions in README.md inside zyncoder folder and rebuild everything (build.sh).

Thanks for great support everyone, especially @jofemodo ! 😀

---

<div class="post-metadata">

**Author:** ![smiths73v3](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/smiths73v3/32/5452_2.png) [@smiths73v3](https://discourse.zynthian.org/u/smiths73v3)\
**Post date:** [January 11, 2020, 8:43pm UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/19 "2020-01-11T20:43:52Z")

</div>

> [@dhrupadiya](#):
>
> p.s. If I connect A0 to the GND it should let it be on address 0x20 technically, but wouldn’t it create short circuit ?

Yes, Tying A0 to GND will short out +5V.  
Best bet will be to track the trace to A0 back a bit, cut it and tie that pin to GND. Be sure to ohm it out before and after to make sure you got it right…

Here is a link to the zynaptic schematic:  
[https://github.com/zynthian/zynthian-hw/blob/master/zynthian\_zynaptik/doc/zynthian\_zynaptik.pdf](https://github.com/zynthian/zynthian-hw/blob/master/zynthian_zynaptik/doc/zynthian_zynaptik.pdf)

---

<div class="post-metadata">

**Author:** ![dhrupadiya](https://discourse.zynthian.org/user_avatar/discourse.zynthian.org/dhrupadiya/32/1440_2.png) [@dhrupadiya](https://discourse.zynthian.org/u/dhrupadiya)\
**Post date:** [January 13, 2020, 7:06am UTC](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751/20 "2020-01-13T07:06:58Z")

</div>

@jofemodo, thank you very much ! Finally everything works. Now the creation of new enclosure starts.

 ![IMG_20200113_095845](https://discourse.zynthian.org/uploads/default/original/2X/c/c327ed67c95ab08d1eb8c83401e32ae7b5f5faeb.jpeg)

[Next page](https://discourse.zynthian.org/t/using-zynaptik-module-for-encoders-solved/3751.md?page=2)
