My Hybrid Pi5 DIY Zynthian experiment

HI all.

I have a Pi5, with an hybrid NVDAC, hat+. An NVME drive where Pi OS boots up, and the DAC.
Initially I wanted to use Patchbox OS, just to play Cardinal, but the Hat wouldn’t work, the pcm5201a neither… and I didn’t know pi5 GPIO is a mess… then I re-discovered Zynthian…
it now runs on a Pi5… with WiringPi!!! That WiringPi that says it has a broken I2C implementation on the Pi5??? Wow… My jaw dropped…

I downloaded Zynthian OS, and now I’m tripping over what I should do… I have another USb Key, where I could burn Zynthian OS and try it… But let’s recap for a minute…

My project began several months ago, from an Autodafe video, Honey, I shrunk my VCV rackk…
I got the Pi5, the screen, the DAC… Cardinal was up and running in no time…
now I wanted to add just 1 encoder, a Midi in and Out, 1 10k pot and 2 CV I/O. and close verything into a small woodbox, with the Screen on the Left, and the Pi5 with the USbs popping out vertically on ots right and under it the Encoder, Pot, 2 stereo Midi TRS and 2 Mono TS CV. Audio Jacks on the back, with the PWR chord inlet also.

Only thing I needed to write a piece of python script to make everything work, and a small circuitry, an Octocoupler, a couple of PNP Transistors, some caps, resistances, 1N4148 diodes.
Or so I thought.
Zynthian uses ADS1115 and I should use at least a TL074 and a MPC6004 opamp for better CV resolution… anyway… I decided to try to use caps instead and time difference in code to determine eg pot position… for this moment, all I want is to have something working, as a proof
of concept… see if the GPIO works, the I2C works, etc…

I created a Python Tree script under the Main name, ZYN.
Under ZYN I have four sub scripts.
One for each of the main features I wanted to add to my Mini ZYN.

Encoder_midi_controller.py
Midi_controller.py
Midi_cv.py
Midi_pot.py

The scripts are very raw, and once I saw the Zynthian Github scripts, I felt like there was no chance my project could ever work… not on the PI OS… maybe on the Zynthian OS…

Anyway, I uploaded some of my codex on Raspi forum and received next to zero advice nor help. I have been mocked for the most part. Like it was my fault that I didn’t know how GPIO works on a Pi5 or something. Here is the raspi blog. In the meantime I hope to have you entertained, and I will share all pics of my build and ideas here from now on…
kepping a toe into Raspi forum to see if by mistake they update the GPIO libs…

https://forums.raspberrypi.com/viewtopic.php?t=388286

PS: I uploaded my old scripts and some Zynthian Midi script into my old Europi project into Grok, and Grok spat out a V2 version of the initial Midi script… everything is included in the zip. I read it to see some obvious monstrosity but didn’t find any… still many parts of the code the Grok uses I have Zero idea what are… it seems like it uses some ninja code I have no idea what it does… usually I have to go back multiple times to ask him to fix stuff, I rewrite the code manually, feed it back to him, and he keep modifying it…
But I have no other choice than to try what he suggests because there is zero official documentation otherwise on the Pi forum. And that that is there, or it is locked like they don’t want us to even talk about issues, or it’s straight away a corporate Ad for to buy some sort of Official Hat just to have access to say… Midi…

Europi5.zip (725.4 KB)


I didn’t install WiringPi… I need to try again… The pot is working… everything else is not… well I have Cardinal output at least… I have 12 hours before my first Gig… I don’t know if I can close it in time…

Ah, this is the diagram that I am using

enable_uart=1
dtoverlay=uart0-pi5
dtoverlay=midi-uart0
dtparam=i2s=on
dtoverlay=i2s-mmap
dtoverlay=hifiberry-dacplus
dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds1307
dtoverlay=disable-bt

      Raspberry Pi 5 40-Pin GPIO Header

==================================================
Odd Pins (1-39, Left Side) Even Pins (2-40, Right Side)

[Pin 1] 3.3V ----+ | [Pin 2] 5V
Power: 6N138 pin 8 |
(via 4.7kΩ), BC557 |
emitter, MIDI OUT |
DIN pin 4 (via 220Ω), |
Encoder pull-ups, |
Pot left pin |
[Pin 3] GPIO 2 — EP-0218 RTC | [Pin 4] 5V
(I2C SDA, DS1307) |
[Pin 5] GPIO 3 — EP-0218 RTC | [Pin 6] GND ----+
(I2C SCL, DS1307) | Ground: 6N138
[Pin 7] GPIO 14 – MIDI OUT | pin 5, MIDI
(BC557 base via 220Ω, | IN/OUT DIN
UART TXD) | pin 2, Encoder
[Pin 9] GND | common, Switch,
[Pin 11] GPIO 17 – Encoder CLK | Pot right pin,
(PEC11, 10kΩ to 3.3V) | CV1/CV2 sleeve,
[Pin 13] GPIO 27 – Encoder SW | EP-0218 GND
(Button, 10kΩ to 3.3V) | [Pin 8] GPIO 15 —+
[Pin 15] GPIO 23 – Encoder DT | MIDI IN (6N138
(PEC11, 10kΩ to 3.3V) | pin 6 via 220Ω,
[Pin 17] 3.3V | UART RXD)
[Pin 19] GPIO 10 | [Pin 10] GPIO 4
[Pin 21] GPIO 9 | [Pin 12] GPIO 18 —+
[Pin 23] GPIO 11 | EP-0218 DAC+
[Pin 25] GND | (I2S PCM_CLK)
[Pin 27] GPIO 0 — Pot wiper | [Pin 14] GND
(Capacitive discharge | [Pin 16] GPIO 22
charge) | [Pin 18] GPIO 24
[Pin 29] GPIO 5 | [Pin 20] GND
[Pin 31] GPIO 6 — CV1 Sync In | [Pin 22] GPIO 25
(3.5mm jack tip) | [Pin 24] GPIO 8
[Pin 33] GPIO 13 | [Pin 26] GPIO 7 ----+
[Pin 35] GPIO 19 – EP-0218 DAC+ | Pot wiper
(I2S PCM_FS, word | (Capacitive
select) | discharge read)
[Pin 37] GPIO 26 | [Pin 28] GPIO 1
[Pin 39] GND | [Pin 30] GND ----+ Ground:
| CV1/CV2 sleeve,
| EP-0218 GND
| [Pin 32] GPIO 12 —+
| CV2 Sync Out
| (3.5mm jack tip,
| PWM)
| [Pin 34] GND
| [Pin 36] GPIO 16 —+
| Switch (SPST,
| 10kΩ to 3.3V)
| [Pin 38] GPIO 20 —+
| EP-0218 DAC+
| (I2S PCM_DIN,
| unused)
| [Pin 40] GPIO 21 —+
| EP-0218 DAC+
| (I2S PCM_DOUT,
| data out)

External Connections:

  • MIDI IN DIN:
    Pin 4 → 220Ω → 6N138 pin 2 (anode)
    Pin 5 → 6N138 pin 3 (cathode)
    Pin 2 → GND (Pin 6)
  • MIDI OUT DIN:
    BC557 collector → 220Ω → Pin 5
    Pin 4 → 220Ω → 3.3V (Pin 1)
    Pin 2 → GND (Pin 6)
  • CV1 (3.5mm Mono Jack):
    Tip → GPIO 6 (Pin 31)
    Sleeve → GND (Pin 30)
  • CV2 (3.5mm Mono Jack):
    Tip → GPIO 12 (Pin 32)
    Sleeve → GND (Pin 30)
  • EP-0218 Audio Output:
    RCA/3.5mm jack for DAW audio
    ==================================================

I installed WiringPi/wiringPi but cpu/procinfo fail to detect pi5 board. I spent all night trying to fix WiringPi.c ,wiringPi.c.rej. and could not find a solution. tried patching hardcoding my bard info into wiringPi but I must have made too many errors and it kept refusing to see my board… tried build reinstall, three times. Maybe I missed some Grant permission to the build process… I made some giant steps tonight, I felt I almost did it… maybe I should jump this step for now and try ttymidi and gpiod… I don’t even have an ADC now, I2C was going to help with the 2 Cv, not even a TL74/6004 combo…

Its almost 8 Am… 8 hours left… maybe I should try sleep and close it for now i’d give up… after the gig I’ll try again… maybe I can hook an SQ1 and get a Sync in that way… last minute solution… Korg drivers on ARM… notoriously anti USB compliant… highly improbable… Also a Crea8Audio NiftyCase Usb-to-Gate interface, already tried, zero connection…

Scraptch Pi oS!
I installed Zynthian OS, connected my SQ64, and I’m playing Dexed via
Usb_Midi!!!
I run the Midi test but haven’t figured out yet the whole “package”
But it’s running!!
Yippiee!!


3 Likes
1 Like

Now that is deadline driven development.
WiringPi is proing a bit of a sticking point at the moment.

I haven’t seen mention of SQ64 in a while! zynseq seems to have replaced the need.

What’d ya think of the Zyntek - 3 Midi board? Should I get it??

I tried the Breadboard connections to the Zyn tty Midi but he didnt like it very much. I only got one Octo and I don’t have neither and ads115 ADC nor a MCP23017 or a MCP4728 . This version 3 board is a bombshell of possible connection addendum… My Box is tiny in comparison, two knobs and 6 minijacks and I have already run out of space!

How do the Zynaptic-3 midi connects?? it seems to have a passthrough Gpio…

Ah yeah the SQ64… She has been filled to the brim with Beethoven Midis, yesterday I stretched Dexed polyphony over its limits! I need to know how to enable Midi Round Robin an stuff here… ya know, arp, divisions, gate probs, its still good fun playn some classic Beethoven to just go sudden crazy!!

I got Wiring Pi on Py (5) Os without venv but had a Pi3.11-armhf error breaking dependencies… on Pi OS is complete madness…

I need to close this project has been open for way too long, next time I get a Zyn 5 anf…off

It’s by far the easiest way of adding Encoders to a zynth, and the MIDI connections can prove to be very useful if you have that sort of kit.

Most of the issues are about how you mount all this. The box and how to mount it so the Pi connectors and the SSD are all accessible, and how the screen is supported are a lot of the issues. Then how the box itself is mounted near equipment and the wires routed is certainly worthy of consieration.

The connector on the zynaptik is simply a mirror of the GPIO connector so it can easily be connected with ribbon cables. Indeed old floppy disk drive leads are perfect. It won’t mount like a traditional Pi hat unless you contrive something. Solid mountings need to be considered for all this. There are drummers about remember and their approach can be robust.

The box is out of wood, the Pi5 stay upright laterally to the screen, inside the box there is the ac adapter only, and a lot of free space. Modules behind the PI5 goes under the screen without touching it. So there’s ample room for another module and some extra wiring if needed.

I am monitoring the Midi input now and I get data from the ring to the 6N138 with spikes on the scope but no spikes on the RX side of the 6N138… checking cables and everything now…
that’s why I was considering the Zintek in the first place… less worries…
Also got a drum patch for Cardinal on patchstorage, it’s more about rotate some knobs atm,
i’d bear that in mind!

One of the problem I’m facing is the Pi5 side of things

The Midi over Uart clock issues span across multiple threads

https://forums.raspberrypi.com/viewtopic.php?t=365126

Joe says he would prefer a Pi5 Uart Midi working instad of having to use I2C for Zynthian… thread locked…

new thread, locked also…

UART clock setting on RPi 5

another thread this time I had time to jump in and make some questions…
but I didn’t know at the time of the existance of the other threads and that it
has been a problem for so long, neither I did understand all related broken libs stuff
Juts now, after two weeks, I finally run rpi-update on the Pi5 Os…

https://forums.raspberrypi.com/viewtopic.php?p=2305648

So, hopefully, I can now make my 6N138 work… otherwise I must assume at this point
Pi5 Os is screwed and only Zynthian Os has pulled the Uart Midi things right…
And that also the Zyntec-3 Midi board is using Uart for Zinthian Os and not I2C protocol,
hopefully, but that do not guarantee me that Pi5 Os kernel has been updated with
all the right clock function, baud rate, etc…

Currently testing my circuit, I don’t see any spikes on the output of the 6N138 side, so
I am going to brute force bypass the data stream directly to the RX pin, with just a clipping to 3.3V diode. If that do not work, I can then try with Zynthian Os to check it’s working.

From memory I don’t think the MIDI in & Out actually go over the i2C connection. They are routed via the 40 pin connector back to the Pi GPIO.

From the zynaptik schematic…

MIDI Out on Pin 8
MIDI IN on Pin 10

1 Like

One thing I didn’t yet understand, if I install Cardinal as an Lm2 plugin via web-browswer config, is it possible to start its Gui also? Or it should be pre-configured to work with Zytnhian Ui in some ways???

You can run the engines guis from the webconf interface via their own dedicated vnc connection.

1 Like

It arrived yest the Domoshop SLIM Midi had, with only Midi DIN and a mcp23017 for up to 5 encoders. I wanted to start with just one encoder. Webtool sees it but then need to go to custom boards and I don’t know how to configure the encoders…

I just wanted to use one encoder for navigating around, lef, right, up and down, but only saw switch properties (numpad?) avail to tweak. No idea how to tweak my single encoders at GP0,1,2 -2 being the SW of the enc (Bourns11R, the same of my TubeOhm Jeannie, 30.000 cycles, not the 11L with 100.000 cycles but still not total crap).

I wanted to use short press to left mouse click objects, and long press to esc, go up or back in folders structure, and then rotation for moving around, Left/Up, Right/Down. Very simple stuff.
I wrote a simple script but in Pi OS I coulld not even make Blinka work…

…And then there is DIN MIDI… which of course didn’t work straight away…
Neither in Pi OS nor Zynthian with Vangelis atm… connection are good…
Everything has been soldered on circuit board so no loose connections,
continuity tests etc, probes to check activity… flat as the dead sea…

PS: the 23017 says iyt doesn’t support 10k pullups, so the Jeannie schematic (Teensy based DIY Synth) seems unattainable… I just decoupled left and right of enc to C-ommon with two 103 caps, then straight to 23017 GP0,1,2 input.

enc info around page 54-64

PS: I wanted to give a chance at Domo guy, Ludo, who maintain tty.midi github page, and support him. And I also thought why take the Zyntek3 board if I’m probably going to get the full Zynthian V5 package anyway :smiley: ( He also boasts it as Zynthian compatible on its shop page)

PPS: I found the schematic I wanted to show regarding the enc circuitry in the Jeannie, which I didn’t use NOW, but I can implement very easily… If it was not for the 23017 specs saying it doesnt support external pull-ups…

PPS, here Common is on the right most pin… I’m suspecting I might have done a small
error in my circuit… supposing C was in the middle pin… I need to retest for ground continuity…
I have the slight feeling I have made a wrong Enc connection… my ex-Jeannie Enc do not have the part n. printed anywhere… but this is supposedly valid for both the old and new enc, otherwise the Jeannie PCb should have been “fixed” when the was the enc swap with the 11R (the old enc didn’t work with fast rotation, soft edges or something… the new enc costed 10$ just for one! But it solved the problem, no more “skippin”

Anyway, in Pi OS I tried to install Adafruit_mcp230xx lib, Adafruit-busdevice and Adafruit-Register.
There is also a Adafruit-bundle but git clone doesn’t work… and all install info avail are not working
for PI5 Os… obviously… So I tried venv and install all libs with pip there and, enabling i2c from raspi-config and tried running my little script to enable the GP0,1,2 for the encoder test, but failed at scope level, absolutley zero response… now I think I might have scrambled the Common pin with the B pin of the Enc… I’ll go fix that in the meanwhile…

Also Midi DIN on Pi OS was opened but couldn’t receive any Midi message whatsoever…
maybe I have to install mod-ttymmidi also on Pi oS?

So yeah, I’m testing on both fronts. Pi Os for Cardinal basically only, untill I don’t figure out how to make it work as an LM2 plugin in Zynthian and VNC…

I webconf I found this under wiring… should I assume 100 stands for GpA0 in my Slim Hat???

Edit, nevermind! I’m reading zynthian-hw/ZynScreen_v1.5/ZynScreen_v1.5.sch.pdf at master · zynthian/zynthian-hw · GitHub and trying to make sense of the webcong page pins numbering… it seems totally unrelated…

Ahhh, I checked with pinctrl from Zyn web terminal, pin 100 correspond to GpA0… now everything is more clear

After rewiring the circuit, and enabling the custom setting with 23017 enabled, I recheck with the scope all pins. Now the enc pins are high… but at 50 pico(?)secs resolution I can’t figure out if turning the enc output a signal or not… in theory moving the enc mid-tick should bring it down… maybe I have to swap again connections, as it seems both left-from top view and common gives a readout of 4.5/6 volts… it shouldnt be like that… my gnd is now at the right-from-top view…
so Gp0 goes to SW, read is 4.9/5v, but pressing the SW it should be pulled down to ground… instead it stays high… I checked before soldering the enc and the SW was functioning correctly… I might have inverted the schematic inadvertly…

I just learned what the knob 4 does… I’m reading the manual for the first time…

  • Knob#4 is the select knob.
    • rotate to browse lists and move the cursor horizontally in grids.
    • short-push to select items, like the SEL button.
    • bold-push to open contextual options, like the OPT button.
  • Knob#3
    • rotate to move the cursor vertically in grids.

I’d love to know how to make my only knob encoder knob 4 basically, it would be fantastic…
I just dont’ have any idea how…
Still have a long way to go reading the manual…

I tried tonight with OStirus, but sisn’t like the rom is think

I just found the VNC conection oìin web tools, tnx!

Is there a way to configure or check Encoders activity from the web GUI also???
In WIRING options I can set Switch behavior (which I don0t have)
and Encs are numbered 100>plus.
Should I leave only the first three 100,101,102?? As those are the pins actually connected to my Enc?? I read the Zynthian guide on the Encoders, but there is no mention
how to customize the Encoders behaviour (or check the activity).
Tnx for yout time wyley.

It also says INT A pin 36 and INT B pin 37. I’m not sure 100% that on Pi5 those are the correct pins… might that also be a cause for the enc not being recognised?

By default if I connect the enc to the first three pins addresses that would work as enc 1 so if I would connect it to the last four pins addresses that would work as knob 4??
How that works??

You must configure at least the first 4 switches and encoder pins. For unused ones, set values to ‘-1’.

The RPi onboard pins use the wiring-pi GPI numbering scheme, starting at 0. The I2C extenders use 100+.

You should set the INT configuration to match the GPIs that you have connected to.

I don’t think we have a GPI test function. I know @wyleu has been requesting this for some time and I had a memory of @jofemodo having implemented something, but that might have just been a dream!

1 Like

My slim midi says INTA to pin 36 - GPIO16 and INTB pin 37 -GPIO26

There seems no options to change the GPI in the webconf, there could
be an error there…?
I updated Wiring as your suggestion, this is how it looks: