Interactive MCP2307 to encoders and button Diagram

Hi, I’m new to electronics and find traditional diagrams overwhelming. I apoligies for my use of AI, but I asked it to generate an easy to follow interactive diagrams for wiring configuration. I will share it here it’s a HTML file. Could anyone in the know help advise if this is a schematic that will work. Or is a product of AI hallucination.

Webconfig generated by Gemini:
Step-by-Step Webconf Navigation

  1. Open your web browser, navigate to http://zynthian.local, and log in (the default password is raspberry).

  2. Navigate to the top menu and click on HardwareKit.

  3. Set the Kit dropdown menu parameter to Custom.

  4. At the very top of the page, ensure you toggle on the Advanced view switch. If Advanced view is hidden, several of the custom assignment boxes for individual pins will not appear.

  5. Scroll down to the Wiring Layout section and change it to Custom.

Exact Software Values to Enter

Because you used the recommended sequential wiring mapping on your MCP23017 chip, your Webconf parameters will follow an ordered numerical sequence. Here is the exact cheat sheet of values to type into each box:

1. Global I2C & Interrupt Settings

  • MCP23017 I2C Address: 0x20 (This matches setting pins A0, A1, and A2 to ground).

  • MCP23017 Interrupt Pin: 25 (This tells the Pi to look at physical Pin 22 / BCM GPIO 25 for physical changes).

2. Rotary Encoder Pins (CTRL-1 to CTRL-4)

  • Hardware CTRL-1 (Top Left / Channel):

    • Pin A: 100

    • Pin B: 101

    • Pin SW: 102

  • Hardware CTRL-2 (Bottom Left / Back):

    • Pin A: 103

    • Pin B: 104

    • Pin SW: 105

  • Hardware CTRL-3 (Top Right / Layer Select):

    • Pin A: 106

    • Pin B: 107

    • Pin SW: 108

  • Hardware CTRL-4 (Bottom Right / Select):

    • Pin A: 109

    • Pin B: 110

    • Pin SW: 111

3. Standalone Tactile Switches (Buttons S1-S4)

Look for the section labeled CUI Switches or Extra Tactile Switches further down the hardware page:

Pi_MCP_Encoder_buttons_pin_layout.txt (2.3 KB)

Hi @Rogenjosh! A very warm welcome to you.

The LLM response is in my opinion, unhelpful and wrong, e.g. the default password is “opensynth”. It does not appear to offer any advice on configuration beyond how to configure the default that would already be configured and the html diagram shows connections in free space (not connected to any device) without any pin labels. (I am an experienced electronics engineer and would be unable to build from that diagram.

So yes - totally a “plausible lie” (or “hallucination”).

What are you actually trying to do? You show the Gemini answer but not the question.

Yeah, I thought that aswell, it’s the uploaded HTML file at the bottom I’m more interested if is wired correctly.

my questions were:

1
Adding Encoders - ZynthianWiki I’m building a box. I’m wanting to add some encoders and four buttons like the boxes prior to the 5. I have an MPC 23017 board, encoders and buttons. Can you help talk me through adding it in a DIY up?
2
Can you create I diagran of the Encoders, connected to the MPC then Rasberry PI using the most recomended configuration, create a second picture heavier diagram to help me understand all connections needed

the pictures would not show, and I informed gemini so it created the HTML interactive wiring

"I appreciate you letting me know. Because standard static image links can sometimes fail to render correctly depending on the chat interface settings, I have built a dedicated, interactive wiring visualizer for you right here instead.

This interactive tool functions as a dynamic diagram. It maps out your hardware components—the Raspberry Pi 5, the MCP23017 expander, your four encoders, and your four standalone buttons—using the recommended configuration we corrected. You can select individual components or sub-systems to highlight exactly how the wires trace between them, see where the hardware debouncing capacitors and pull-up resistors sit, and get the exact pin numbers to enter into your Zynthian Webconf screen.

Wiring Reference Sheet

Before exploring the interactive layout below, here is the verified map of your point-to-point connections:

  1. Power & Addressing Bus:

    • Pi Pin 1 (3.3V) $\rightarrow$ MCP Pin 9 (VDD) & MCP Pin 18 (RESET)

    • Pi Pin 6 (GND) $\rightarrow$ MCP Pin 10 (VSS) & MCP Pins 15, 16, 17 (A0, A1, A2)

  2. I2C Communication Bus:

    • Pi Pin 3 (SDA) $\rightarrow$ MCP Pin 13 (SDA)

    • Pi Pin 5 (SCL) $\rightarrow$ MCP Pin 12 (SCL)

  3. Hardware Interrupt System:

    • MCP Pin 19 (INTB) & MCP Pin 20 (INTA) are tied together.

    • Run a 10k$\Omega$ resistor from this combined junction to 3.3V.

    • Run a signal wire from this junction to Pi Pin 22 (GPIO 25).

  4. Encoders & Buttons Pins:

    • Encoder 1: A $\rightarrow$ GPA2, B $\rightarrow$ GPA1, Switch $\rightarrow$ GPA0

    • Encoder 2: A $\rightarrow$ GPA5, B $\rightarrow$ GPA4, Switch $\rightarrow$ GPA3

    • Encoder 3: A $\rightarrow$ GPB2, B $\rightarrow$ GPB3, Switch $\rightarrow$ GPB0

    • Encoder 4: A $\rightarrow$ GPB5, B $\rightarrow$ GPB4, Switch $\rightarrow$ GPB1 (Corrected configuration pin)

    • Tactile Buttons (S1-S4): S1 $\rightarrow$ GPA6, S2 $\rightarrow$ GPA7, S3 $\rightarrow$ GPB6, S4 $\rightarrow$ GPB7

Use the interactive visualizer below to trace these lines physically and verify your software settings."

so basically I’m asking is the interactive HTML file correct in regards to correct wiring?

zynthian_encoder_button_mcp23017_wiring.html (22.0 KB)

Hi @Rogenjosh !

Traditional diagrams, although intimidating at first glance, are really easy to understand. I think it’s worth the effort and you would gain a very useful skill, specially if you want to build electronic devices, like zynthian.

For sure, it’s the best way you can take if you really want to build your zynthian. Forget the IA for this. The IA is good for giving a generic overview (you can learn a lot of electronics with the IA!!), but if you want the IA helps you with the details in a project, then you need to have a good background and criteria. If you don’t, trying to get the details from the IA is worthless.

All the best!

4 Likes

AI has many skills but for some reason, so far, it’s truly appalling at designing circuits.
This is still an area of human endevour that requires some understanding, if you don’t want to produce the magic smoke.

A very good point to start understanding things are digital circuits as realising that everything in that design world breaks down to a few simple logic operations, that are easily understood. OR, AND, NAND, NOR and the are these inputs different XOR.

You don’t find too much circuitry doing this sort of thing nowadays. Microcontrollers do it in code which saves chips, manufacture and testing, but it get’s you familiarity with schematics…

This is a walk throu’ that get’s you a long way in a short time if you are willing to follow it carefully. Look up any terms you don’t understand in Wikipedia. It may appear confusing, but will at least instill a familiarity with terms, which is an excellent bed on which to branch out to things that you are actually trying to do.

https://www.electronics-tutorials.ws/logic/logic_1.html

It takes you throu’ at a fairly brisk pace, but don’t be intimidated.

1 Like

Cool, thanks guys. I appreciate the guidance. I agree AI does have some applications of use, but is way to confident in giving the wrong answer especailly for more specialised skills.

Wyleu I will be checking that link out thanks.

I have could a few diagrams, what would be the best for me, I want to either have a 2 encoder each side of screen or 4 on the right, with the 4 scence buttons below it. I have found several, but not sure which is the most appropriate.

I’d go for four encoders on the right.

It’s the future,

The two either side is supported but the GUI is tending to assume a column of encoders because it free’s up more screen territory for other purposes.

This is the sort of thing that would look confused with encoders either side…

I’ve got probably the universe’s largest collection of zynthian front panels both connected and remote and they are all 2 * 2 but the next one I build ( 4 RGB I2C encoders and Pi Pico) is waiting on a suitable case and a satisfactory solution to providing the Version 5 buttons.

I’m left handed as well and that adds to the fun.

This is the Kicad drawing of one of my control boxes using a Pi Pico2w

Hopefully someone will be a long shortly to ask about de-bounce and decoupling capacitors . . .

A Pi Pico 2W is a excellent way to get into this stuff as it can all be connected to a laptop or desktop machine, and it powers itself and can be easily programmed and provides you with digital pins to do all kinds of relevant things related to zynthians.

This will delay the realisation of pretty much all electronics tends to be about the physical mounting of plugs, sockets and power supplies.

Apparently it’s all canal boats and trains . . .

1 Like

This one is not using an MCP though. But the configuration you’re aiming for might be possible without it.

I did build a similar device with the help of the guy above and wrote it down here:

It doesn’t have the 4 switches, but you would add them to the free mcp pins and some common ground and configurate it accordingly, but using any of the V4 wiring configurations.

You may need to check if your MCP has the mentioned 10k resistor already included. If you would list the parts you already have, someone may be capable of telling you that.

1 Like

So I have tried to follow these instructions Building a custom Zynthian - ZynthianWiki and have not have any luck. I noticed each encoder in the picture has 5 cables coming from them instead of the 4 that were directed in the instructions. on my encoder the pin in that spot has a + symbol. so it has CLK, DT, SW, +, GND.

With the gnD my MCP only has 2 GND pins so I connected the others to GND pins on the Rasberry pi’s pins, is that correct?

I have followed all this:

"First we need to connect some PI GPIOs to the soldered board. We use the two 13-pin headers next to the MCP23017. Therefore we check the Pi GPIO pinouts.

Connections from PI GPIOs to MCP23017 board

From Pi… (Physical Pin Number) 5V (2) GND (6) SDA (3) SCL (5) GPIO (36) GPIO (37)
To MCP23017 VIN GND SDA SCL Int-A (IA) Int-B (IB)

Now we connect the encoders to the respective pins, in that version labeled A0-A7; B0-B7. You can basically chose every combination (see section “wiring setup”), but we’ll use this, because it’s convenient for cable lead:

Connections from MCP board to encoders

MCP23017 B4 B5 B6 B0 B1 B2 A4 A5 A6 A0 A1 A2
Encoders Enc1 CLK Enc1 DT Enc1 SW Enc2 CLK Enc2 DT Enc2 SW Enc3 CLK Enc3 DT Enc3 SW Enc4 CLK Enc4 DT Enc4 SW

Additionally we connect all encoder GND to the boards GND line, where we soldered the 4-pin header mentioned above. In picture 5 you see the second 4-pin header soldered to the 5V line already, where we connect the encoder “+” to 5V. Why is that?

I happened to have ordered encoders mounted on a PCB, don’t ask why. This includes 10kOhm pull-up resistors (don’t ask why). The two options were to desolder these resistors, cut their lines or just power the encoders. I chose the latter option. Without connecting them to 5V they actually worked, but very clumsy, unreliable and sometimes triggering other actions than intended.

5 Setup

The software sided setup of your hardware is typically done in Webconf. You may also feel like editing the file /zynthian/config/zynthian_envars.sh which is basically edited when you do changes in Webconf. The code snippets below are taken from that file for better readability. You may find the according Webconf page and settings very quickly. If you find a “\n” in these snippets, this expands to an EOL (line break).

5.1 Wiring setup

My wiring setup, which you may easily find also in your Webconf → Hardware → Wiring page looks like this:

# Zynthian Wiring Config
export ZYNTHIAN_WIRING_LAYOUT="MCP23017_ENCODERS_V5TOUCH"
export ZYNTHIAN_WIRING_ENCODER_A="112,108,104,100"
export ZYNTHIAN_WIRING_ENCODER_B="113,109,105,101"
export ZYNTHIAN_WIRING_SWITCHES="-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,114,110,106,102"
export ZYNTHIAN_WIRING_MCP23017_I2C_ADDRESS="0x20"
export ZYNTHIAN_WIRING_MCP23017_INTA_PIN="27"
export ZYNTHIAN_WIRING_MCP23017_INTB_PIN="25"

5.1.1 Wiring layout

We use MCP23017_ENCODERS_V5TOUCH because we have physical encoders, but no physical buttons, why we are using the virtual V5-onscreen buttons."

But I’m not sure what this is:

"5.1.2 Encoders

In Enc_A (CLK), Enc_B (DT) and Switches (SW) field you type in the numbers you chose when wiring the encoders to your MCP23017 circuit. Numbers between 100 and 115 are connected to the A0 to B7 pins like that: A0=100, A1=101, … B7=115. So your encoder4-CLK we connected to A0 (see table above) means, you’ll state it as 100 (=A0) on 4th position.

The bunch of 20 “-1” in the switches field represent the virtual buttons you’ll use if you use the touch or virtual V5-buttons setup. If you don’t have 20 physical buttons connected to match the V5 layout, just type it in like that.

5.1.3 MCP Adress

We soldered the adress pins all to GND, remember? This leads to adress 0x20, which has to be chosen in the corresponding field. If you add another MCP (for buttons or whatever) or you just feel to use another adress, you need to connect the adress pins in another fashion. Think binary numbers (D2; D1; D0):

--- > 0x20
--+ > 0x21
-+- > 0x22
   ...
+++ > 0x27

5.1.4 Int-A and B pins

We connected the IA and IB pins of the MCP to physical pins 36 and 37. If you look them up in the webconf menu, you can chose for example “WPi GPIO 27 (Pin 36)”, where pin 36 is the physical pin 36 (if you count on the hardware), and WPi GPIO 27 is the “WiringPi” number (not the GPIO 27). Check the pinout overview linked above: You’ll see that this Pin is actually GPIO 16. So why is the setup file storing it as “27” and “25”? It uses the WiringPi naming convention (see issue above).

To make things easier here: if you, like me, chose to use psysical pin 36 and 37, also chose that in the webconf menu."

it appears to be reasons for those settings.

I will send a picture from my phone of my wiring.

Honestly don’t know how to take a picture where the connections are clear

1 Like

oh, 10k resistor, I think that may be the issue I’m having

https://core-electronics.com.au/mcp23017-io-expansion-board-expands-16-i-o-pins.html

You also have the encoders with a PCB, which include another resistor. The easiest way is to connect the + pins to 5V each. You already quoted that part yourself:

I guess your MCP GND is connected to a PIs GND, so all GNDs are connected with each other. That way you can do that.

What exactly? The section is about configuring in the webconf wiring menu. At least you can leave out the address pin part, because your model uses solder bridges instead of pins. So I guess since you didn’t connected the bridges A0-2 in the current state it’s adress 0x20.