DIY Synth Page 3: OLEDs and the CV to Midi project
Using OLEDs to expand synth and other DIY projects.
The Blog for this project
(Not yet)
The Schematics, PCB files, and Simulation models are here
(Not yet)
Back to the DIY analog synth part

In Spring of '17 I began playing with Midi on Teensy and other Arduinos, and with OLED (Organic LED) graphic displays. My intro to OLEDs was with the excellent Ornament and Crime synthesizer module.  I was impressed by the types of displays they used as well as the complex menu structure. While I have built and used character and graphic LCDs for many years, I always did-it-myself, including developing FPGAs to drive dumb graphics LCD panels. What a delight to have an easy to use panel that is cheap and has great software support. Here is some test code with a 128x64 1.3" OLED displaying current and voltage plus status. I plan to adapt it to my PS-Load system. The processor is a little 8-bit Arduino Mega32u8 board. Very small and cool.

oled on leonardo

How to get started with OLEDs
Pick up an OLED display. Buy a couple since you are going to want to add them to your projects. There are a few choices you'll have to make:
Install the SW library, either u8g2 or Adafruit. Un-comment the initialization line closest to the resolution and control chip that you have. Hardware SPI requires SCK and MOSI from your processor, sometimes on a separate 6 pin connector.  SW SPI can use any pins but is slower to update the display.  With u8g2 I use:

U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R2, /*cs*/ 10, /*dc*/ 9, /*res*/ 8);


Wire up the VCC and GND, the clock, data, and 3 control signals (CS, DC and RES) from the initialization line you chose. 
Compile and load the example code. Even without a display connected, with a scope you should see the clock and data signals output from your Arduino or Teensy. Once the display is connected properly and working, you should see the demo running on your display!

How much CPU time is used?
I measured the time to transfer the 1K buffer from the CPU to the OLED on a Teensy and on a Mega32u4. Both use Hardware SPI with an 8MHz clock speed.  On Teensy 3.2 it took 1.6mS and on '32u4 it tool 4mS. Not bad.


Why do I like OLEDs?
They are small.
I like the 1.3" 64x128s. These are only 1.4" wide overall, but highly visible. They are also available 0.96", and also half height 32x128. If they are too small for you, they are available in larger sizes for more $$$. In the past I used 8x2 LCDs to keep the size down, but they are very limited in what they can display. People have made custom fonts for symbols on character LCDs, but ugh.

They are bright and very visible.
Both Blue and White are very bright and visible. You can use tiny fonts to display lots of stuff, or large fonts so you can see things at a distance. The high brightness and contrast ratio blows away all but the brightest LCDs.

They are thin.

When building a front panel for a synth or any other project, you need all the front panel components to be about the same height so they stick through the front panel the right amount.   That means displays, pots, encoders, switches, buttons and jacks. Add a thick back-lit LCD to the mix and you probably blew the height budget. OLEDs are only a few mm thick. You can mount them on any length pins or connectors to get any height you want.

They are cheap.
Like $7-9 for a 128x64 1.3".  0.96" are a bit cheaper.

They are high resolution.
What? You call 128x64 hi-res? Yes because the pixels are tiny, like 6-8 mils. Character LCD pixels are about 15 mils and so look blocky. 8 mil pixels are so nice. And at that small pixel size, you don't really need anti-aliasing.

You can add graphics and labels.
For my PS-Load project, I found myself adding LEDs as indicators to Character LCD projects. Not needed for OLEDs, so long as your indicators can be all one color. There are some specialized OLEDs with a row of yellow pixels above the blue main screen. The intention of these is to have your annunciators in a different color. I haven't played with these.

Flexible display.
Any size characters, tons of fonts, lines, icons, simple graphics, small waveforms. Anywhere from 8 lines of tiny text to 2 lines of big test. You are only limited by your imagination and code space.

Flexible interface.
Either I2C (fewer pins and wires, but lower performance) or SPI (a few more pins, but fast). I2C ad SPI can be shared with other displays or other devices. This is better than the 6 dedicated wires on a Character LCD.

No Backlight needed
Character LCD backlights require a trimpot to adjust the backlight and display contrast. Plus the added thickness to spread the LED light evenly to the display. Yuk. OLEDs can be dimmed in u8g2 with the setContrast(x) command.

Flexible Power
Monochrome OLEDs in either 0.96" or 1.3" sizes can operate from 3.3V or 5V.

Great SW support
The graphics libraries are cool, easy to use and simple. There are two that are widely available: Adafruit and u8g2. Both are great. I use u8g2 since it supports tons of panels, and am very happy with it. Just a few lines of code are needed to display many items. The libraries are small, bug-free and efficient. To get an OLED running, just run the example code, select the correct panel,  and hook up a few wires.

Supporting multiple displays in ether I2C or SPI is pretty simple. Just initialize 2 (or more), then write to one, then the other. 2 or more can share a buffer, saving RAM.

Reasonable code size
32 bit processors like Teensy 3.x have gobs of code space. But even 8 bit processors like Mega328 and Mega32U4 have enough code space and RAM for simple apps. Watch your font selection though: large fonts use up your code space. u8g2 has numeric-only, upper-case-only and no-glyph versions of some fonts to save space, so use them.

Small RAM size
The best way to use 128x64 displays (OLEDs and LCDs) is to write your graphics to a memory buffer (only  128 x 64 / 8 = 1KB) and then update the display by transferring the memory buffer to the display. Mega328 and Mega32u4 only have 4K RAM, so keep this in mind. A 320x240 TFT color LCD display with 16 bits per pixel needs 320x240x16/8 = 153KB of frame buffer. Everything takes longer and uses more memory.


OLED, meet Synth: The CV to Midi Project


Here is another OLED project, a CV to Midi converter. This accepts 1V/ octave Control voltage plus a Gate signal, and outputs Midi data to any Midi instrument. Currently it outputs Midi to the lower left connector. It also sends Midi to a Synthesizer-on-a-chip, the VS1053B, on a board by Adafruit, in the upper left corner. The display shows the Note code being output as well as the instrument being played. The two push-buttons select the instrument. I love this thing. It allows my various analog sequencers to play any midi synthesizer or other instruments.

My plan it to make a real PC board for Eurorack with a handful of trigger and CV inputs. General Midi synthesizers have plenty of drum sounds, so I plan to use trigger inputs to control drums. Additional CV inputs could affect the drum pitch or act as velocity inputs to affect the the instrument velocity.

The module on the lower left is a Teensy 3.2 processor. To process the control voltage is one op-amp. The Teensy 10 bit on-board ADC digitizes the signal and converts it to a note. A single transistor (to the right of the buttons) accepts the trigger input. The DIP near the OLED is an op-amp to process the CV input.   The DIP on the right is an opto isolator for the MIDI receiver, not used with this design. The upper right stuff is just leftovers from the VCA project.  I plan to post the schematic, board files and code....


oled 2 CV to Midi project







The Blog for this project
  Dave's Home Page

Last Updated: 7/8/2017