Ecoders directly to the GPIO of the Pi 4?

Hi, I’m trying to build my DIY Zynthian to integrate it on my Ableton set up to save some CPU with synth sounds.

I’ve this encoders and want to know if I could use it with wires direct to the GPIO and avoid to use other PCB or Arduino.
I’m working now with a usb audio card uca202 (configured on web like the 222 and works fine)
My display is a 7" with the HDMI and USB port working fine too.

Working with Ip midi on OS X connected to a switch and no latency on Ableton Live.

If I can put the encoders directly will make some wood case for all.

Can I also connect directly too a female midi port?

https://www.amazon.es/gp/product/B07D356LRH/ref=ppx_yo_dt_b_asin_image_o02_s00?ie=UTF8&psc=1

Sure! The original Zynthian has encoders wired directly to the Raspberry Pi header and this is still supported on the firmware and configuration.

This old guide includes some clues but basically you need to wire pins of the encoders to spare GPIO pins on the RPi header then select, “Prototype 1” in webconf and give the pin numbers used on RPi header as comma separated list in each field. (I think it is Prototype 1 but maybe it is custom.)

Regarding MIDI port, the Zynthian supports hardware MIDI input and output but needs a few components to interface. You could build this yourself or buy an interface board but if you are spending money on such toys then maybe the official parts. :grin:

1 Like

Yes, I’ve got several machines wired up in all kinds of strange configurations and whilst you quickly forget the difficulties of the configuration on a home built ( There’s many, many pages illustrating various examples) I would strongly suggest getting the ‘official’ interfaces as these have been heavily tested both before release and in the wider community.

I should be playing music, I actually spend far more time trying to keep long distance I2C connectors alive which is entirely my own fault !

1 Like

Thanks all, i’ve some encoders because I’m making a midi controller with arduino and encoders and ring rgb Leds to work with Ableton. So I just use it and go to complete The zynthian to go deep on it. Tomorrow will try it.
Thanks for the support guys. <3

one thing, my encoders have 5 pins. GND, +, SW,DT and CLK. Need to wire all? just GND to Ground on the PI and he other 4 to GPIO numbers?

Those encoders have pull-up resistors hence a connection for +V. I don’t think these are needed as RPi can use internal weak pull-up but there should be no harm connecting it to 3.3V (not 5V). You may have an issue with switch bounce. The Zynthian encoder circuit used hardware switch debounce (using some small capacitors).

1 Like

I’ve built i/O connected encoders and not used capacitors. They seem to behave but I would recommend adding them if you can… or . . . ::smiley:

1 Like

Ok, i was thinking to use the 2 3v3 and the 2 5v to wire the 4 but if you say that…Will try without wire the + then. Thanks.

Sorry for all the cuestions :S
On the webconfig " MCP23017 INT-A Pin: and MCP23017 INT-B Pin: " I need to put default if I don’t have one? And this pins will be on the " Encoders A-pins: and Encoders B-pins:" right?

Yep and enter switch pins too.

1 Like

EDIT
I wired it and make Prototipe 1 config like this:

Encoders A-pins: 3,4,15,18
Encoders B-pins: 17,27,25,8
Switch pins: 2,14,22,7
The other MCP default and the last empty.
Only works the 1st encoder down and the clk

Actually doesn’t work and can’t connect to the Zynthian. DHCP doesn’t works. No web and ssh access.

09-16-2020

09:45:12

Successfully assign IP [192.168.0.17] to client mac [dc:a6:32:11:c2:c4], lease time [86400]

LAN

09-16-2020

09:45:12

Received REQUEST from client ip [0.0.0.0] mac [dc:a6:32:11:c2:c4]

LAN

09-16-2020

09:45:12

Send OFFER of ip [192.168.0.17] to client mac [dc:a6:32:11:c2:c4]

LAN

09-16-2020

09:45:11

Received DISCOVER from client mac [dc:a6:32:11:c2:c4]

EDIT:

Pushing back key on start I recover it and now works webconfig.

On web midi test only works this on all the controllers wired.

CH#01 CONTROL_CHANGE 71 => 0

CH#01 CONTROL_CHANGE 71 => 0

CH#01 CONTROL_CHANGE 71 => 0

CH#01 CONTROL_CHANGE 71 => 0

CH#01 CONTROL_CHANGE 71 => 0

CH#01 CONTROL_CHANGE 71 => 0

Some help here? What’s the right order of the wires on web config?

Try:
Encoders A-pins: 4,27,15,8
Encoders B-pins: 3,22,14,7
Switch pins: 2,17,18,25

You don’t make it easy, hiding the GPIO numbers in your picture and using different colour arrows for the same parameters :wink:.

2 Likes

I use the color of the wires. Yes my pixelmator skills are bad :dizzy_face:

1 Like

doesn’t work with custom or prototype 1.

on midi router only the 4 encoder sends messages:
CH#01 AFTERTOUCH 0

CH#01 AFTERTOUCH 0

SYS RESET

SYS RESET

I’m so confused. Which correspond to clk and which to DT on my key-040 :confounded:. I need to find this to wire all like you do and see if works.
So complicated this gpio thing.

These rotary encoders use a quadrature encoding. In their rest state both signal pins are disconnected. As you turn the shaft, the common (ground) pin is first connected to one signal pin, then both pins then the first signal pin is disconnected and finally both are disconnected as you return back to a detent. The Zynthian decodes this to detect direction and rotation, one detent at a time. The “Clk” and “DT” pins are actually just these two signal pins. As long as you connect ground to the common pin and each signal pin to a GPIO then assign the pins in the webconf it should work. It is possible that it will work in reverse if the pins are reversed but that is simply resolved by reversing the configuration in the webconf. The switch is activated when the shaft is pressed connecting. This needs ground on one side and a GPIO on the other.

Checkout the link that @wyleu posted. He has made this work.

Yes. THe major confusion is the Numbers we refer to from within the webconf display.
This is the webconf of the machine (zynthian-ceed.local) using the wiring described. It’s my dev machine which gets all kinds of abuse.

As you can see it refers to pins and the interrupts. but these numbers refer to BCM column in the chart which then need mapping across to the PIN’s on the GPIO connector.


This is done because these are the pins on the main raspberry Pi chip BCM (something or other) which is the real target of software, this way we could move zynth outside of the Raspberry Pi should it be required. Much more flexible!

Course the Raspberry IO pin connector is a standard that has been adopted all over the place so it all gets more confused. But If I wanted to use the chip to make my own machine without an IO connector I could and that’s why software writers do it this way.

It does work!

Here’s the advantage of all this mucking around. As you can see in this machine space is very tight and laying the ribbon cables like this it allow it all to be assembled. I can then use the mapping to just choose the relevant pins on the PI that these connect to. Software flexibility saves space in the box !! :smiley:

2 Likes