MiniDexed Raspberry Pi IO Board – Part 2

This is the set of build notes for the smaller of my MiniDexed Raspberry Pi IO Boards.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key tutorials for the main concepts used in this project:

If you are new to microcontrollers and single board computers, see the Getting Started pages.

Bill of Materials

  • Raspberry Pi 3 or 4 with associated power, uSD card, etc.
  • You’ll need the smaller (SSD1306 version) of the PCB: MiniDexed Raspberry Pi IO Board (GitHub link below).
  • 1x 128×32 I2C OLED SSD1306 display (see photos).  Note it requires the pinout SDA-SCL-5V-GND.  WARNING: Similar looking modules have been seen with different variations of this!  Also, ensure it has built-in level shifting for 3V3 I2C operation.
  • 1x GY-PCM5102 module (see photos).
  • 1x H11L1 optoisolator.
  • 1x 220Ω resistor.
  • 1x 470Ω resistor.
  • 1x 1N914 or 1N4148 signal diode.
  • 2x 100nF ceramic disk capacitors.
  • 5x 10nF ceramic disk capacitors (not 10pF as stated on the PCB).
  • 1x rotary encoder with switch (see photos).
  • 1x 5-pin 180 DIN PCB mounted socket (see photos).
  • 2x “button” push-switches (see photos) – optional.
  • 2x 2-way header pins – optional.
  • 1x 6-way DIP socket – optional.
  • 1x extended 2×20-way GPIO header socket for the Raspberry Pi.
  • 1x 4-way header socket – optional.
  • 1x 6-way header socket – optional.

As always, a socket are recommended for the H11L1, and the SSD1306 and PCM5102 modules can either be used with sockets or soldered directly, depending on how brave (or lucky?) you’re feeling.

Build Steps

This should be a relatively straight forward “through hole components” build.  I did things in the following order:

  • Resistors and diode.
  • 6-pin DIP socket.
  • Capacitors.
  • Buttons (if used).
  • If you are using headers for the SSD1306 and PCM5102 then do them next.
  • If you are using header pins for the switches, do them next.
  • MIDI socket.
  • Rotary Encoder.
  • PCM5102 and SSD1306 (if you aren’t using headers) – WARNING: see note below about the PCM5102 solder bridges before soldering.
  • GPIO socket.

Note that an extended GPIO header is recommended to give the board a little extra clearance from the Raspberry Pi, but it means that if you don’t want the extra pins above the board, they should be cut off once soldered in place.

PCM5102 configuration:

The GY-PCM5102 modules I’m using, as shown in the photos, as the same as used for the Clumsy MIDI project and you have to be sure the configuration jumpers on the back of the modules are correctly set up before soldering in place.  Full details of what is required can be found on the Clumsy MIDI pages here (see the important note about the “DAC solder bridges”): https://github.com/gmcn42/clumsyMIDI.

SSD1306 OLED Logic Levels

Several versions of these modules exist, but to use it with a Raspberry Pi requires one with 3V3 level shifters included.  The 128×32 variety used in the photos often seems to include these, but the 128×64 variety often won’t!

The level shifters can be spotted on the back as follows:

In this case, marked “U2”.  But to be sure, power the unit from 5V and measure the voltage on the SCL and SDA pins to see if it is pulled up to 3V3 or 5V.

Testing

I recommend performing the general tests described here: PCBs.

I used the “fishing wire trick” to be able to plug in the SSD1306 and PCM5102 without soldering and require using headers (nylon fishing wire in the holes gives enough traction to be able to push a header pin in, have it grip and make contact, without soldering.  This allowed me to check everything was working, including the modules, whilst still giving me options for debugging.

It is probably also worth attempting to power up the board without connecting it to the Raspberry Pi as a “smoke test”.  The PCM5102 and SSD1306 are powered from the 5V line, whilst the H11L1 is powered from the 3V3 line.

PCB Errata

Functionally, all seems ok, but there are a couple of markings I’d change.

  • First off, an error in the capacitor values – the debouncing capacitors should be 10nF not 10pF.
  • I labelled the switches Home and Select, but given the flexibility in the configuration (and the fact that typically the encoder’s switch will be “select), maybe they should just be “button 1” and “button 2”.
  • The diode is labelled 1N914 but I believe 1N9148 tend to be preferred?
  • I suspect I ought to use better capacitors (I know the Clumsy MIDI board recommends “X7R or film (e.g. WIMA MKS2)”).
  • It might be worth adding a larger capacitor for the power to the board in general.

You can find the PCB design files on GitHub here:  https://github.com/diyelectromusic/sdemp_pcbs/tree/main/RpiMiniDexedSSD1306

MiniDexed Configuration

I’m not going through how you set up and run MiniDexed.  My own notes on it can be found here: “Bare Metal” Raspberry Pi MiniDexed DX7.

The following settings are required in the minidexed.ini file (correct as of time of writing, but the MiniDexed project shifts pretty quickly!).

For the SSD1306 LCD:

SSD1306LCDI2CAddress=0x3CSSD1306LCDWidth=128SSD1306LCDHeight=32LCDColumns=20LCDRows=2

For the Rotary Encoder:

EncoderEnabled=1EncoderPinClock=10EncoderPinData=9

For the two buttons, and the rotary encoder switch itself:

ButtonPinBack=5ButtonActionBack=clickButtonPinSelect=11ButtonActionSelect=clickButtonPinHome=6ButtonActionHome=clickButtonPinShortcut=11

If you don’t want to use the buttons, but would rather use the button on the rotary encoder for everything, then I suggest (which is the default, at the time of writing):

ButtonPinBack=11ButtonActionBack=longpressButtonPinSelect=11ButtonActionSelect=clickButtonPinHome=11ButtonActionHome=doubleclickButtonPinShortcut=11

Closing Thoughts

I love the idea that all I need is power, an audio output and a MIDI link (either USB or serial) and I have eight DX7s on hand and ready to go in this small, neat unit!

This one doesn’t really lend itself to being put in a case, although I guess it could if you extended the link to the display and buttons.  But my next build, using the larger of the two PCBs, hopefully will!

As always, I have a small number of prototype boards, so if you might be interested in having a go yourself, ping me a private message somehow and we can talk.

Disclaimer: Once again, I used the Seeed Fusion service as I had some discount coupons I’d been sent, and once again I have absolutely no complaints about their quick, cheap service.  I’m very pleased with these boards.

I am in no way connected to or affiliated with Seeed, but if they (or any other manufacturer for that matter) want to send me discounts, I for one am very happy to receive them.

Either way I’ll always post things here as I see them and make it clear when I’ve taken advantage of any special offers or vouchers.

Kevin

#midi #minidexed #pcb #pcm5102 #raspberryPi #ssd1306

MiniDexed Raspberry Pi IO Board

I’ve been toying with the idea of some kind of IO board for my MiniDexed experiments for use with a Raspberry Pi.  I initially wanted something fully self-contained – i.e. just pop it on a Raspberry Pi and you’re good to go.  But then it was pointed out that having all the IO connections on one side is much more friendly from a “putting it all in a case” point of view.

In the end, I used many of the same circuit elements and came up with two designs.

Update: Here are links to the build guides for these PCBs:

There is a version for the Raspberry Pi V1 here: MiniDexed Raspberry Pi V1 IO Board and my pseudo TX816 can be found here: MiniDexed TX816.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key tutorials for the main concepts used in this project:

If you are new to microcontrollers and single board computers, see the Getting Started pages.

Basic Requirements

I wanted a board to do the following:

  • Include a screen or display.
  • Have MIDI IN.
  • Optionally include MIDI OUT and THRU.
  • Have a rotary encoder for input.
  • Incorporate a PCM5102 DAC for audio output.
  • Optionally include a couple of buttons.

As I mention above, I was initially after something that would fit within a normal “HAT” type footprint for a Raspberry Pi, which is pretty constraining, but following on from the Clumsy MIDI board, should be possible with a small SSD1306 OLED display.

But I was also keen to try to build something that would allow all the IO to line up along the back, so I’ve also designed a larger board that overhangs the Pi and allows for a full three MIDI din sockets.  This larger board can accommodate a HD44780 LCD display as used in the original MiniDexed setup.

I’m happy for the whole thing to receive power via the Pi and of course USB and ethernet connections are also available on one side.

MiniDexed RPi IO Board (SSD1306 Version)

Starting a new project in KiCad, there is already a “Raspberry Pi 40-pin Extension Board” template which provides the basic outline, PCB footprint for the GPIO, and cut-outs for the display and camera.

Here is the schematic I’m working to.

Points worthy of note:

  • A H11L1 based MIDI IN circuit connected to RX0.
  • A rotary encoder (not a KY-040 module) is used with 10pF capacitors for debouncing the connections.
  • A PCM5102 in the “GY module” format (as used by Clumsy MIDI).
  • Two optional button push-switches which are also broken out to headers, also with debouncing capacitors.
  • I’ve included the header for the SSD1306 in SDA-SCL-VCC-GND format.

This is the GPIO map used:

If the rotary encoder seems to be “backwards” then swap RE_A and RE_B in the configuration.  Note that at the time of writing, I2C SSD1306 displays are in development but hopefully will be available in MiniDexed by the time you read this.

Here is the board that has been sent off for manufacturing.

Design notes:

  • I used the GY-PCM5102 symbol and footprint library from the Clumsy MIDI GitHub repository.
  • The H11L1 is upside down as that made routing easier.
  • I’ve included footprints for two push-buttons (the very common “through hole” type used in many maker projects) but also included two sets of header pins so these could be wired off to something else if required.
  • I’m using a 32×128 OLED (again the same one used with Clumsy MIDI).  As I say, MiniDexed doesn’t support this directly at the time of writing, but I’ve submitted a PR for support that is waiting to be accepted, so hopefully it will be fully supported soon.
  • Unlike my previous boards, I used a filled zone to create a link to the GND net and provided a ground plane on the rear copper layer of the board.
  • Both the SSD1306 and PCM5102 modules I’m using have a built-in regulator to take 5V down to 3V3.  This is particularly critical for the SSD1306 as it includes pull-ups for the I2C connection to the 3V3 level (not 5V).  But this is why they are hooked up to 5V yet I’m not using level-shifters to interface to the (3V3 logic) Pi.

Here is an early “space test” (without the buttons) with a paper printout to give you an idea of what I’m aiming for.

And an image of the Gerbers as sent off for manufacture:

MiniDexed RPi IO Board (HD44780 Version)

Again starting a new KiCad project from the Raspberry Pi 40-pin extension board template, this is the circuit I’m working with for this one.

Schematic Notes:

  • This is using the same PCM5102, rotary encoder, and switches as above (although I’ve just realised I never swapped the schematic and pcb over to use the GY-PCM5102 module symbol and footprint – oh well, for this board it is a 6-way set of headers!).
  • This uses the “data interface” version of the HD44780. I did think about using the I2C version, but thought this would be the simplest case to build if it could be made to work.
  • There is MIDI IN, OUT and (optional) THRU.
  • The MIDI circuit borrows heavily from Clumsy MIDI and includes a 74HCT14 hex inverter as an output buffer for OUT and THRU (although it is labelled as a 74HC14 on the schematic and pcb).
  • THRU is optional, in which case the unused inputs to the 74HCT14 should go to GND instead (selected by solder jumpers).
  • OUT can optionally be changed to a(nother) THRU rather than an OUT, in which case it can be switched via solder jumpers to be connected to RX0 rather than TX0.

To simplify the routing of the PCB, the pinouts for the various components have changed.  Here is the pinout being used (this is now quite different to the original MiniDexed pinout).

So this is the design for the pcb that has been sent off for manufacture:

Design notes:

  • The PCB is designed to be used with a Raspberry Pi “upside down”.  That is, with the connectors at the top, and GPIO at the bottom.  This means the USB/RJ45 ports will be on the left hand side, as shown.
  • The MIDI THRU section is optional.  If only two MIDI sockets are required that part of the board can be cut off along the line indicated.  If that is done then the solder jumpers beneath the 74HC14 must be changed as follows:
    • Cut the “THRU” jumper (this disconnects the 74HC14 from RX0).
    • Solder the “NO THRU” jumper (this connects the unused 74HC14 port to GND).
  • The MIDI OUT port can be changed to a THRU too.  If the original THRU is removed, this means you can just have MIDI IN and THRU instead of IN and OUT if you wish. If the original THRU is retained, then you can have a MIDI IN and two THRUs. To turn the OUT into a THRU change the two solder jumpers near the H11L1 as follows:
    • Cut the “OUT” jumper (this disconnects the OUT circuit from TX0).
    • Solder the “THRU” jumper (this connects the OUT circuit to RX0 to make it a THRU).
  • Whilst on the subject of MIDI sockets, all three sockets are oriented to go underneath the board so they will go alongside the RPi.
  • The optional buttons are not provided on the PCB, but via two sets of headers on the left hand side of the board.
  • As mentioned above, annoyingly I forgot to change the PCM5102 footprint to that of a GY-PCM5102 module, so there are no holes for the additional 9-way header.  These are not used electrically, but they would have provided some additional physical support.  Instead I might solder some header pins and use the plastic pin spacer as a support under the board (but I’ll look into that when I get the boards back).
  • I’ve included a simple “preset” pot to control the contrast for the LCD.
  • Once again I used a filled zone to create a link to the GND net and provide a ground plane on the rear copper layer of the board.  Note that I left a cut-out under the traces to the THRU part of the circuit, to reduce the chance of a short if the board is cut off at this point.
  • Most LCD1602/HD44780 modules are 5V parts, with 5V required to ensure the LCD actually illuminates successfully. However, as described here, it is usually ok for a 3V3 output to drive a 5V input, so as long as the LCD isn’t attempting to drive the IO pins for the Pi, the Pi should be fine talking 3V3 to the LCD. So that is the approach I’m taking. It does mean that this won’t accept a 3V3 LCD module. But in all this, remember my level of electronics experience, and make up your own mind…

Manufacturing

Both boards should be built using the standard, cheapest manufacturing options.  Both are fine with a 6/6 mil constraint on track width and separation.

The second board is somewhat larger than the common “cheap” tier.  For me, all my other boards were $4.60 plus postage for 10 boards, but the larger one has jumped up to around $27 plus postage.

On the back of my first blog post, having used Seeed Fusion to produce my first boards, they sent me some money off vouchers, so I’ve used them once again here.  That was particularly welcome given the increased cost of the larger board!

I still don’t really have a space to store these designs.  But I’ll update this post when I do!

Closing Thoughts

Although either of these designs could potentially be used in a case to make a nice, small, self-contained unit, I can’t guarantee that the spacing of connectors and components will really allow it.  I’m also not sure what will be required in terms of cooling for the Pi, so I’ll have to see how I get on.  It may be that I’ll need more spacing between the Pi and the IO board.

I’m still learning with KiCad, so am fully expecting continued mistakes or odd design choices, but I think both of these will be interesting to try.

Update: mistakes already spotted since sending them off:

  • The afore-mentioned GY-PCM5102 footprint error.
  • Labelling on the board states 74HC14 and it really has to be a 74HCT14.

So that is the walk-through of the design of these boards.  Of course I won’t really know if they are successful until I get the boards back from manufacturing!

Kevin

#hd44780 #midi #minidexed #pcb #pcm5102 #raspberryPi #ssd1306

MiniDexed Raspberry Pi IO Board V2 Design

My two MiniDexed PCBs were some of the earliest ones I made and so I’ve wondered about revisiting them for a while now.

This is a respin of the SSD1306 version of the IO board that is, hopefully, slightly nicer to build a case around!

Here is the link to the original PCB: MiniDexed Raspberry Pi IO Board. There is the original version for the Raspberry Pi V1: MiniDexed Raspberry Pi V1 IO Board and scattered around the blog are boards for a Pi Zero, a RPi 400, a TX816 style device, a dual Pi version, and a version for a Pi5 that supports quad stereo audio output, among other things.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers and single board computers, see the Getting Started pages.

Basic Requirements

As a bare minimum I’m after a revision of the SSD1306 version of the board that is slightly more case-builder friendly than the original.

I’d also like to add or change the following:

  • MIDI TRS.
  • Better audio output socket.
  • Fix the minor errata from the original board.

It still has to fit within a normal “HAT” type footprint for a Raspberry Pi as I’d like to be using it with a Pi 3A+ again.

I’d also like to arrange the connectors to be on the same side as much as possible.

The Circuit

This is the same schematic as before with the addition of a TRS audio output direct from the PCM5102 module. I’ve also fixed a few of the non-functional errata such as some erroneous component values.

The GPIO map remains unchanged, although “SELECT” is now labelled “BACK”:

PCB Design

I’ve updated the MIDI socket footprint to my dual DIN-TRS footprint. I’m probably going to use the TRS version myself, but it is nice to keep DIN as an option. I’ve had to move the buttons to allow for a second TRS socket for the audio output and have consequently moved the GY-PCM5102 module back away from the edge of the board.

With this arrangement all of the IO is now on the same side of the board apart from the RPi’s own USB (and ethernet if using a B+ version).

Getting the height of the components correct will be a bit fiddly as the display and buttons will be determined by the height of the encoder’s body.

As I keep forgetting which GPIO is used for what, I’ve added details on the underside of the PCB.

As the GY-PCM5102 has an analog GND to support the analog OUT, I thought it might be prudent to keep that part of the PCB GND isolated from the main digital areas. But I’ve also seen that two GND planes separated by a thin non-conducting strip also has another name – “antenna”…

This is where my experience meets peak ignorance, so I’ll have to see how it goes and if I end up reconnecting everything, then I’ll patch something through somehow

Closing Thoughts

Ultimately I won’t know if this is any easier to use than the V1 board until I start designing a new case. But the addition of MIDI TRS at least removes the need for accommodating a large DIN socket on the board and having all the connectors on the same side will be better I think.

I have wondered about a Pi Zero version that could have DIN sockets on the underside of the PCB, mirroring what I did for the HD44780 version of my original board.

I might still give that a try as that would make for quite a nice compact unit too.

Kevin

#midi #minidexed #pcb #pcm5102 #raspberryPi #ssd1306

Inspired by the news that HiFiBerry are releasing an 8-channel DAC board for the Raspberry Pi 5, but slightly disappointed they’ve sold out of their beta-test programme, coupled with the news that Rene has added 4-channel I2S support for circle, and seeing that the HiFiBerry dac8x is essentially four PCM5102A modules and a high quality audio path, I set out attempting to create a similar (albeit low quality) equivalent with four GY-PCM5102 modules.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to single board computers, see the Getting Started pages.

Parts list

  • Raspberry Pi 5.
  • uSD card, HDMI, mouse, keyboard, etc to boot Raspberry Pi OS.
  • 4x GY-PCM5102A modules.
  • Breadboard and jumper wires.

The Circuit

The Raspberry Pi GPIO Pins are connected as follows:

Raspberry Pi 5GY-PCM5102A Modules5VVCC – Modules 1-4GNDGND and SCK – Modules 1-4GPIO 18BCK – Modules 1-4GPIO 19LCK – Modules 1-4GPIO 21DIN – Module 1GPIO 23DIN – Module 2GPIO 25DIN – Module 3GPIO 27DIN – Module 4

I eventually ended up using a small solderless breadboard to allow me to daisy-chain the power and common signals for the GY-PCM5102 modules.

Important: Recall that for these PCM5102 modules, there are solder jumpers that have to be setup on the back. More details here.

Raspberry Pi OS

Before connecting any of the GY-PCM5102A modules, I downloaded the latest 64-bit Raspberry Pi OS image and booted it up “as is” on my Pi 5 to make sure everything was working.

Then I installed any pending updates and rebooting to ensure everything was once again up and running.

It might be worth checking sound is working by firing up an Internet browser and watching a video or something. By default the sound will go over HDMI, so naturally you need a sound-capable HDMI device to support that.

At this point I shut it down again and connected up the four PCM5102 modules as per the diagram above then booted everything up again. The OS should boot correctly although at this point it will have no knowledge of the added boards.

Quad DAC Configuration

The basic principle is to use a device-tree overlay file to enable I2S audio and the four PCM5102 devices.

But the nice people at HiFiBerry have already done this with support from Raspberry Pi for their dac8x module, so actually all that is required is to edit the file /boot/firmware/config.txt and add the following line:

/boot/firmware/config.txt:

dtoverlay=hifiberry-dac8x

There is talk on the Internet about commenting out the audio=on parameter or enabling i2s=on, but I didn’t have to do either of these.

Then on reboot, there should be a new audio device “snd_rpi_hifiberry_dac8x” which can be selected.

At this point playing a video should output on the first PCM5102 device.

To test all 8 channels requires an application that can output audio on 8 channels. But for a simple test the “speaker-test” command can be used from the terminal:

kevin@pi5:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vc4hdmi0 [vc4-hdmi-0], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: vc4hdmi1 [vc4-hdmi-1], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: sndrpihifiberry [snd_rpi_hifiberry_dac8x], device 0: HifiBerry DAC8x HiFi pcm5102a-hifi-0 [HifiBerry DAC8x HiFi pcm5102a-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

kevin@pi5:~ $ speaker-test -t sine -f 440 -c 8 -D hw:2

speaker-test 1.2.8

Playback device is hw:2
Stream parameters are 48000Hz, S16_LE, 8 channels
Sine wave rate is 440.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 16 to 32768
Period size range from 8 to 256
Using max buffer size 32768
Periods = 4
was set period_size = 256
was set buffer_size = 32768
0 - Front Left
4 - Center
1 - Front Right
7 - Side Right
3 - Rear Right
2 - Rear Left
6 - Side Left
5 - LFE
Time per period = 23.295314
0 - Front Left
^C 4 - Center
1 - Front Right
7 - Side Right
3 - Rear Right
2 - Rear Left
6 - Side Left
5 - LFE
Time per period = 0.406018
kevin@pi5:~ $

The “aplay -l” command can be used to list all devices that ALSA knows about. In my case the pseudo hifiberry dac8x device is listed as “card 2”. This means I then need to use the device identifier “hw:2” for the speaker-test command.

The other parameters to speaker-test are as follows:

  • -t sine – output a sine wave rather than the default noise output.
  • -f 440 – set the sine wave frequency to 440Hz
  • -c 8 – use 8-channel sound output.
  • -D hw:2 – use the device “hw:2”

If all goes well, then playback on 0,1 (front left/front right) goes to PCM5102 module 1; 2,3 (rear left, rear right) goes to PCM5102 module 2; and so on.

Closing Thoughts

Now that I know the basic principles seem to work, I want to see what it would take to create a 8-channel audio output MiniDexed.

Kevin

https://diyelectromusic.wordpress.com/2024/05/27/rpi-5-quad-stereo-sound-with-pcm5102a/

#0 #i2s #pcm5102 #raspberryPi #raspberryPi5

RPi 5 quad-lane I2S · rsta2 circle · Discussion #453

Apparently the RPi 5 supports 4 lanes of I2S output. Would it be possible to expand the I2S support from 2 channels to 8? The hifiberry-dac8x-overlay.dts appears to show how this could work for a q...

GitHub

Ok, ignore my last comment about Part 4 being my last post on this topic. I thought I ought to pull together all the hardware notes on how to build one as I haven’t really written that down anywhere.

So this shows the connections required between the Pico, I2S DAC and MIDI IN.

  • Part 1 where I work out how to build Synth_Dexed using the Pico SDK and get some sounds coming out.
  • Part 2 where I take a detailed look at the performance with a diversion into the workings of the pico_audio library and floating point maths on the pico, on the way.
  • Part 3 where I managed to get up to 16-note polyphony, by overclocking, and some basic serial MIDI support.
  • Part 4 for the full MIDI implementation, voice loading, SysEx control and USB-MIDI.
  • Part 6 includes details of how to use PWM output.

The latest code can be found on GitHub here: https://github.com/diyelectromusic/picodexed

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers, see the Getting Started pages.

The Circuit

The easiest way to get a PicoDexed up and running for me, is to use one of my MIDI Proto PCBs and the Pimoroni I2S Audio Pack. This does not allow for any debug output.

Note the jumpers are set to use UART 1 on GP4 and GP5.

If only USB-MIDI is required, then the Audio Pack can be plugged directly onto the back of the Pico, in which case simply plugging into the Pico via USB to a computer and connected up the audio out will work.

It is also possible to use any 3V3 compatible MIDI module. The following shows the use of a Pimoroni “dual expander” with a MIDI module connected to GND, 3V3_OUT and GP5 (RX1).

This has the advantage that all other GPIO pins are available, so it is relatively straight forward to include a debug link via GP0/GP1 for UART 0.

A Solderless Breadboard Circuit

Of course it is also possible to build everything on a solderless breadboard.

The diagram below shows how a cheap GY-PCM5102 module can be used as the I2S DAC and a serial MIDI interface (optional) can be built using my standard 3V3 MIDI IN circuit.

This also allows for some debug output using UART 0 (GP0/GP1).

Things to note:

  • The PCM5102 board will have to have solder jumpers on the rear set as follows: 1=L, 2=L, 3=H, 4=L. Sometimes these come preconfigured with solder bridges, sometimes with zero-ohm SMT resistors, and sometimes with no connection made at all. More details here.
  • I always get pins 4 and 5 mixed up on MIDI DIN sockets. Here is my MIDI Connections Cheat Sheet which may help.

Pico GPIO Usage

The following GPIO pins are in use or allocated:

GP0Debug UART TX (unused at present)GP1Debug UART RXGP4MIDI TX (unused at present)GP5MIDI RXGP9I2S Data (DATA, DIN)GP10I2S Bit Clock (BCK)GP11I2S “Left/Right” Clock (LCK, LRCK, LR_CLOCK)GP20Optional: PWM outputGP22Optional: Mute pin for the Pimoroni Audio Pack (not used)VSYS5V power to DAC (if required)3V3_OUT3V3 power to MIDI IN (if required)GND

PWM Audio Output

It is possible to use PWM audio output on the Pico. Full details can be found here: Raspberry Pi Pico Synth_Dexed? – Part 6.

But this is a lot more limited than I2S and the quality is a lot poorer too. As a DAC can be obtained quite cheaply, the use of an I2S DAC is strongly recommended.

Closing Thoughts

I’ve uploaded a prototype UF2 file to GitHub in case anyone wants to give it a go: everything can be found here: https://github.com/diyelectromusic/picodexed

Hopefully there is enough information in the above to get something up and running.

Kevin

https://diyelectromusic.wordpress.com/2024/02/18/raspberry-pi-pico-synth_dexed-part-5/

#dx7 #midi #pcm5102 #picodexed #raspberryPiPico #usbMidi

Raspberry Pi Pico Synth_Dexed? – Part 4

I was going to leave things at Part 3 blog-wise, and just get on with filling in the gaps in code now, but I’ve come back to add a few more notes. But this is likely to be the final part now.…

Simple DIY Electronic Music Projects

Here are the build notes for my RPi 400 MIDI and Audio PCB.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

In this case – inserting this pcb incorrectly (which unfortunately is possible with the RPi-400) could damage the RPi 400. See full post below for details.

If you are new to microcontrollers and single board computers, see the Getting Started pages.

Bill of Materials

For the MIDI circuit

  • 1x H11L1.
  • 1x 74HCT14 (NB: Must be the HCT version, not the HC).
  • 1x 1N914 or 1N4148 signal diode.
  • 5x 220Ω resistors.
  • 1x 470Ω resistor.
  • 2x 100nF ceramic capacitors.
  • Either: 3x 5-pin, 180 degree PCB-mount DIN sockets (see photos for footprint).
  • Or: 3x stereo TRS PCB-mount sockets (see photos for footprint).
  • Optional: 6-way DIP socket; 14-way DIP socket.
  • 1x 2×20-way right-angle GPIO header socket.

For the additional DAC and MiniDexed sections:

  • 1x GY-PCM5102 DAC module.
  • 1x SSD1306 32×128 OLED display (pin order: GND-VCC-SCL-SDA).
  • 5x 10nF ceramic capacitors.
  • 2x 100nF ceramic capacitors.
  • 1x switched rotary encoder (see photos for footprint).
  • 2x slim toggle pcb-mount button switches (see photos for footprint).
  • Optional: 4-way header socket for SSD1306 display.

For structural support when installed:

  • 2x 2.5mm, 6mm nylon spacers
  • 2x 2.5mm nylon nuts

Build Steps

Taking a typical “low to high” soldering approach, this is the suggested order of assembly:

  • All resistors and diode.
  • DIP sockets (if used) and TRS sockets (if used).
  • Disc capacitors.
  • GY-PCM5102 module (if used) – check that the solder jumpers on the back (see below).
  • Buttons (if used).
  • 4-way SSD1306 header socket (if used).
  • GPIO headers.
  • DIN sockets.
  • Rotary encoder.

As mentioned in the design notes, it is possible to install the three main sections of the PCB independently depending on what is required:

  • The MIDI circuits.
  • The PCM5102 DAC.
  • The MiniDexed IO components (display, encoder, buttons).

If a DIP socket is used for the 74HCT14 the to install the SSD1306 display will probably require a 4-way header socket in order to lift it high enough to avoid the installed 74HCT14 and to not negate any benefits of having the chip in a socket!

If the H11L1 and 74HCT14 are soldered directly to the board then a SSD1306 with extended pin headers should be adjustable enough to be soldered over the other components.

The capacitors that are labelled “10p” are actually 10nF capacitors. This is an error in the silkscreen.

Here are some build photos for a complete build with all sections complete.

At this point the MIDI sections are complete and it is possible to now install the TRS or DIN sockets and the GPIO header if a MIDI only board is required.

To continue building the DAC and IO sections see below.

Note check the PCM5102 jumper settings before fixing – more here. Also note how the capacitor for the PCM5102 is folded down underneath the board.

At this point the TRS or MIDI sockets can be installed.

Once complete, it is strongly advised to add a couple of 2.5M 6mm spacers to the middle of the PCB in order to support it when plugged into the RPi 400. This is particularly important if using a switched rotary encoder and the buttons.

As one of the holes for the spacers is under the corner of the PCM5102, it might need trimming down slightly to fit without pushing the PCM5102 upwards. In my case I had to cut the thread down slightly as shown in the photos below.

Here is the final board.

Testing

I recommend performing the general tests described here: PCBs.

Once the above tests were complete, I tried the board with a Raspberry Pi 3A+ on the basis that if something went wrong it would cost me a lot less to replace a 3A+ than my new RPi 400.

Care must be taken to orient the board correctly though when not using a RPi 400 – see photos below.

Once all seems to be functioning, I switched to my Raspberry Pi 400.

IMPORTANT: Additional care must also be taken when installing in a RPi 400 as it is quite possible to plug the board in “one pin out”. If this happens, then there is a distinct risk of connecting one of the 5V GPIO pins to GND which would damage the RPi 400.

With hindsight, the use of a keyed header socket (assuming they exist in right-angled, pcb-mounted format) would stop this happening.

If I rebuild this board, then I might leave pin 4 5V unconnected to prevent this happening. I don’t think any other power pins are adjacent to GND, although it still leaves the possibility of feeding a HIGH GPIO directly to GND in other places.

PCB Errata

There are the following issues with this PCB:

  • As mentioned before, the capacitors labelled “10p” are really “10n”.
  • The pcb slightly overlaps the uSD card slot on the RPi-400 which means it can’t be removed when the pcb is installed.
  • Inserting incorrectly could connect GPIO 5V to GND and damage the RPi 400.

Find it on GitHub here.

Sample Applications

MiniDexed Raspberry Pi 400

The board is essentially a mirror of my MiniDexed Raspberry Pi IO Board physically arranged to support the Raspberry Pi 400 form-factor.

Below are the key minidexed.ini configuration settings that allows the RPi 400 to act as a MiniDexed synth with this board.

The MIDIThru setting is not required for general operation but can be used to turn on software MIDI THRU between the IN and OUT ports.

Also, MIDIThru can be used to direct the RPi 400 keyboard to the MIDI OUT port, turning it into a MIDI controller. The internal keyboard is device “ukbd1” which needs linking to “ttyS1” for the MIDI interface.

SoundDevice=i2s
#MIDIThru=ttyS1,ttyS1
MIDIThru=ukbd1,ttyS1

LCDEnabled=1
SSD1306LCDI2CAddress=0x3C
SSD1306LCDWidth=128
SSD1306LCDHeight=32
SSD1306LCDRotate=0
SSD1306LCDMirror=0

LCDColumns=20
LCDRows=2

ButtonPinPrev=0
ButtonActionPrev=
ButtonPinNext=0
ButtonActionNext=
ButtonPinBack=5
ButtonActionBack=click
ButtonPinSelect=11
ButtonActionSelect=click
ButtonPinHome=6
ButtonActionHome=click
ButtonPinShortcut=11

EncoderEnabled=1
EncoderPinClock=10
EncoderPinData=9

The built-in keyboard can be used as a simple 2-octave music keyboard to play the synth as follows:

Raspberry Pi 400 MIDI and Audio Interface

The board can be used as a MIDI and audio interface for the standard Raspberry Pi 400 OS too.

The basic idea is to use a I2S DAC overlay for the PCM5102 and to enable the serial port, but not the serial console, in the raspi-config and map MIDI onto it in some capacity.

Enabling the PCM5102 Sound

The full instructions are the same as described here: https://learn.pimoroni.com/article/raspberry-pi-phat-dac-install
But the short version (for 32-bit Raspberry Pi OS “bullseye”) is as follows.

Edit /etc/config.txt and comment out or add the following:

# dtparam=audio=on
dtoverlay=hifiberry-dac

There are other settings in there related to I2S but these can be ignored as the overlay file will include everything it needs. Note: commenting out the audio=on line will disable the built-in audio via the bcm device in the Raspberry Pi.

Then create an /etc/asound.conf file with the following:

pcm.!default {
type hw card 0
}
ctl.!default {
type hw card 0
}

According to this document, this tells ALSA (the Linux sound system) to override its own default with hardware card 0, which is now the PCM5102. This can be confirmed using the command:

pi@raspberrypi:~ $ cat /proc/asound/cards
0 [sndrpihifiberry]: RPi-simple - snd_rpi_hifiberry_dac
snd_rpi_hifiberry_dac
1 [vc4hdmi0 ]: vc4-hdmi - vc4-hdmi-0
vc4-hdmi-0
2 [vc4hdmi1 ]: vc4-hdmi - vc4-hdmi-1
vc4-hdmi-1
pi@raspberrypi:~ $

For it to work though I have to then select the “snd_rpi_hifiberry_dac” option in the “Device Profiles” by right-clicking on the Raspberry Pi OS Desktop “sound” icon in the tray (next to the clock).

Enabling Serial (UART) MIDI

Serial MIDI is linked up to the Raspberry Pi’s GPIO TX/RX ports on pins 14 and 15. But by default there are a couple of issues with just hooking these up to a MIDI interface:

  • They are usually either expected to be used with a serial console or configured (apparently) for a faster Bluetooth link.
  • The supported baud rates don’t include the standard MIDI 31250 baud.
  • By default there is nothing that will connect a UART based serial port to ALSA to allow it to be used.

Details of how to solve this can sort of be found around the Internet, but I’ve not found a complete “just do this and everything works, and this is why” document. The official Raspberry Pi documentation for the UART can be found here: https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts (although to be honest, I didn’t quite follow most of it myself… primary UARTs? Hmm)

Other references:

First enable the serial port and disable the console. This can be done by editing /boot/config.txt directly, but can also be done from the Raspberry Pi Configuration GUI tool.

Then in /boot/config.txt these additional updates are required:

enable_uart=1
dtoverlay=miniuart-bt
dtoverlay=midi-uart0

The first is probably already there if the serial port was enabled using the GUI. The second one apparently switches the internal Bluetooth over from using TX/RX on pins 14/15 to using ttyS0 (it is also possible to disable it completely with “disable-bt”). This frees up ttyAMA0 (TX/RX) for our use, which is the first UART on the PL011 peripheral on the bcm chip. The last setting includes some magic to tweak the clocks and baud rates so that the standard rate of 38400 will actually come out at the MIDI rate of 31250.

Details of each of these overlays can be found in the Raspberry Pi documentation (the README) here: https://github.com/raspberrypi/firmware/tree/master/boot/overlays and details of how the UARTS are set up and used on the different Pi versions, and which options are available, can be found here: https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts

Note: there are variants of midi-uart for other UARTs (which apparently can be enabled on a RPi 4) and a special midi-uart0-pi5 version for the Raspberry Pi 5.

This should have enabled the primary UART on TX/RX (pins 14,15) to be available with a suitable MIDI baud rate. But to use it, that serial port needs linking up to the operating systems sound setup.

Apparently the most common way to do this appears to be to use the ttymidi tool, which I guess fulfils a similar function to hairless-midi on a Windows PC (although I note hairless says it supports Linux too, even though it too recommends ttymidi!).

Unfortunately there doesn’t seem to be a ready-made version just to install, so it has to be built. The instructions from here worked fine for me:

$ sudo apt-get install libasound2-dev
$ wget http://www.varal.org/ttymidi/ttymidi.tar.gz
$ tar -zxvf ttymidi.tar.gz
$ cd ttymidi/
$ make
$ sudo make install

Once installed this needs to be started to connect the serial port to ALSA:

$ ttymidi -s /dev/ttyAMA0 -b 38400 -v

This provides the serial port and baud rate (remember 38400 has been tweaked to really be 31250 “on the wire”). The “v” option means it will dump any messages to the console. An optional “n” option can be used to give the link a nice name that can be used later. Without it, it defaults to “ttymidi”.

Two additional, useful tools to install (using the Raspberry Pi Add/Remove Software tool) are pmidi and midisnoop. pmidi can be used to list MIDI devices.

pi@raspberrypi:~ $ pmidi -l
Port Client name Port name
14:0 Midi Through Midi Through Port-0
128:1 ttymidi MIDI in
pi@raspberrypi:~ $

The ALSA tool aconnect can also list available ports:

pi@raspberrypi:~ $ aconnect -l
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 128: 'ttymidi' [type=user,pid=2619]
0 'MIDI out '
1 'MIDI in '
pi@raspberrypi:~ $

MIDIsnoop can be configured to use these ALSA ports and then can be used to show everything working.

How to actually use the ports I’ll might come back to, but in essence that becomes a tutorial in how to use ALSA and sound on Linux and there are lots of tutorials about that out there already.

At some point I’d like the above to all happen automatically on startup so that ttymidi is running and available to ALSA. That should be possible to add to one of the startup scripts, but that is left as an exercise for the reader (i.e. I haven’t looked that up yet).

Closing Thoughts

The “off by one” possibility of error when plugging the board in is concerning. I’d not anticipated that! But by being careful that should be manageable.

I also wasn’t anticipating not being able to unplug the uSD card! Oh well.

Apart from that, I’m really pleased with how it works.

At some point I might return to this and detail how to drive the display from Raspberry Pi OS itself as that would be a nice way to finish things off.

Kevin

https://diyelectromusic.wordpress.com/2023/12/18/rpi-400-midi-and-audio-pcb-build-guide/

#midi #MIDIThru #minidexed #pcb #pcm5102 #raspberryPi400

RPi 400 MIDI and Audio PCB Design

Now I’ve got my Raspberry Pi 400 up and running I’ve built a MIDI and I2S audio add-on board for use with the GPIO. Build guide here: RPi 400 MIDI and Audio PCB Build Guide. Warning! I …

Simple DIY Electronic Music Projects

Now I’ve got my Raspberry Pi 400 up and running I’ve built a MIDI and I2S audio add-on board for use with the GPIO.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers and singled board computers, see the Getting Started pages.

The Circuit

The key features of this design are:

  • Raspberry Pi 40 pin GPIO header connection.
  • Powered via the RPi GPIO.
  • Includes 3V3 MIDI IN circuit using H11L1.
  • Includes proper buffered MIDI OUT and THRU using 74HCT14.
  • Includes I2S connection to a GY-PCM5102 module.
  • Includes optional I2C SSD1306 OLED 32×128 display.
  • Includes optional rotary encoder and buttons with debouncing capacitors.

The primary aim for this board is Raspberry Pi 400 MIDI and I2S audio DAC. But I thought it I was going that far then I would also include the options for a rotary encoder, buttons and display which would allow the board to be used as a MiniDexed user interface too.

PCB Design

The board will plug in behind the RPi 400, so the idea is to use a 90-degree angle GPIO connector. The board supports either TRS or DIN MIDI sockets.

To just be used as a MIDI interface, the following components are required – all shaded out components may be omitted.

The I2S Audio DAC section is highlighted in purple on the left hand side if that is wanted to be added to the MIDI or just used on its own. Note how the capacitor for the PCM5102 will be situated between the PCB and the PCM5102 itself. It will need folding down to be installed.

This is a now standard (for my blog) H11L1 MIDI IN circuit paired with a 74HCT14 (not the HC variant – it has to be the HCT version to support the level shifting required) based MIDI OUT section. There is also a hardware MIDI THRU port. As can be seen from the PCB the board will take either TRS or DIN MIDI sockets – footprints are included for both.

Note: This is designed to be used with a right-angle GPIO header for plugging into a Raspberry Pi 400. Should the board want to be used with a typical RPi, then the power pins are on the far right hand side of the board with 5V on the top row and 3V3 on the bottom row. The GPIO connector will “point upwards” so it really has limited use with a normal Pi as all the components would be on the underside of the board – i.e. between the PCB and the Pi… but electrically it would all work!

To use the board as a MiniDexed user interface then the buttons, rotary encoder and SSD1306 display, and associated capacitors, can be added. Note that the SSD1306 display will have to sit above the 74HCT14.

There is one error on the board. All the debouncing capacitors for the encoder and the switches are labelled “10p” when it should be “10n”. I’ve made that mistake before and it simply got copied over to this design too without me spotting it!

Closing Thoughts

I was tempted to try to make something a bit simpler that could be used with my Cyberdeck, but instead opted for this stand-along board.

Whilst I don’t see a lot of use for a RPi-400 based MiniDexed, I couldn’t really think of a reason not to include the additional components. Having to route the PCM5102 such that the jack was in a useful position meant I wasn’t able to make the board much smaller anyway.

Kevin

https://diyelectromusic.wordpress.com/2023/12/18/rpi-400-midi-and-audio-pcb-design/

#midi #minidexed #pcb #pcm5102 #raspberryPi400

Raspberry Pi 400 Cyberdeck MIDI Player

I’ve finally gotten myself a Raspberry Pi 400 computer. I’ve wanted one for a while to use as a MIDI player for my Lo-Fi Orchestra. The idea is that eventually I might be able to run it…

Simple DIY Electronic Music Projects

Was laying out the #kicad #schematic for #muvco and it started to seem too pedestrian.

Went back and realized I had been using the #pcm5102 wrong and it does indeed do exactly what I originally wanted.

Now making a waveform generator instead of using the dds #ad9833. Much more flexible in shape and can be semi-polysynth ("chordal #synth"?) #synthdiy

Can now generate a perfect 5th in 260us! In mostly-unoptimized #micropython! Just dyads still--need to generalize to larger chords + diff shapes.

The nice thing about having a truly awful memory is that you have new ideas every day.

Hey, I thought, I should really try this #PCM5102 on the #esp32

After a few hours of frustration later, I got it working.

Then I found *my own review* on Amazon of this same device, rejecting it as having a problem that I now realize was me probably using it wrong.

If I could remember for more than 17.3us, I would never have tried this idea again.

So you see--a superpower.

The #PCM5102 also arrived and this one is even worse than #MAX98357. At least the 98357 accurately describes itself as a DAC + Class D amp. The 5102 just says it is a DAC but is also a Class D amp.

I guess the "generate waveforms" part of this project is on hold until next week. Instead, I can work on software I need to hook up all the bits.