This is only a preview of the October 2023 issue of Silicon Chip. You can view 37 of the 112 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "1kW+ Class-D Amplifier, Pt1":
Items relevant to "2m Test Signal Generator":
Items relevant to "TQFP Programming Adaptors":
Items relevant to "30V 2A Bench Supply, Mk2 - Pt2":
Items relevant to "1.3in Monochrome OLED Display":
Purchase a printed copy of this issue for $12.50. |
Using Electronic Modules with Jim Rowe
1.3-inch (33mm)
Monochrome OLED Display
Small monochrome OLED display modules have become widely available
at a low cost in the last few years. Typically these measure only
about 35×33mm but offer a 128×64 pixel resolution in a few different
colours, like white or blue. Their I2C serial interface means that popular
microcontrollers can easily drive them.
O
LED (organic light-emitting
diodes) are solid-state light-
emitting devices like standard LEDs.
But instead of using a regular semiconductor P-N junction to emit light
when passing a current, an OLED uses
a thin film of an organic compound.
As a result, displays using OLEDs tend
to be thinner, lighter and use significantly less energy than those using
traditional LEDs.
In the last 15 or so years, they have
become widely used in smartphones,
handheld gaming consoles and, more
recently, colour TVs.
Small monochrome OLED displays
are also used extensively in portable electronic equipment, so they
have dropped significantly in price.
Among the most popular are the 1.3inch (33mm) modules, such as the one
shown in the photos.
We have already used these in a
couple of projects, like the MultiStage Buck/Boost Charger Adaptor
from October 2022 (siliconchip.au/
Article/15510).
These are available from a wide
range of online suppliers, including
via eBay, AliExpress and Amazon, and
local suppliers like Jaycar and Core
Electronics. Prices vary over a pretty
wide range, about $5 up to nearly $20
from overseas suppliers, or around $15
from local suppliers (plus postage, if
you’re getting them delivered).
We also sell them in our Online
Shop for $15 + P&P ($13.50 + P&P
for subscribers), with catalog codes
of SC5026 (blue) and SC6511 (white).
These are not the smallest OLED
modules available. Another common
size is 0.96in or 24.4mm diagonal,
with prices slightly lower than those
for the 1.3in/33mm modules. These
Fig.1: the block diagram of the SH1106 and SSD1306 controllers that are typically used in both the 0.96in and 1.3in OLED
modules.
82
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
generally have the same display resolution; the smaller size means those
pixels are smaller. We used these in a
few recent projects, like the Advanced
Test Tweezers (February & March 2023;
siliconchip.au/Series/396).
There are also even smaller OLED
modules, like those with a designated
size of 0.49in/12.45mm. Those have a
lower display resolution of 64×32 pixels. We used those in the original SMD
Test Tweezers from the October 2021
issue (siliconchip.au/Article/15057).
Inside the OLED modules
The 1.3in OLED modules all use a
single interface/controller and OLED
driver IC, usually the SH1106 from
Sino Wealth or the SSD1306 from Solomon Systech. The same controllers
are used in the 0.96in modules.
Fig.1 is a block diagram of the
SH1106 and SSD1306 controllers.
At upper left is the microcontroller
(MCU) interface, which can be configured to interface with an MCU via an
8-bit 6800/8080-series parallel interface, a 3/4 wire SPI interface or an I2C
serial interface. Most 1.3in and 0.96in
OLED modules use the last option, I2C.
Received display data is stored in
the graphic display data RAM (the
large block to the right of the interface), while commands are sent to the
command decoder block at lower left.
The display controller block at upper
right uses the display data to drive the
columns and segments of the OLED
via the common and segment drivers
shown at far right.
The OLED has 64 common/column
lines and 128 segment lines, matching
the 128×64 pixel resolution.
There are commands to update the
display, turn the OLED display on or
off, set the OLED addressing mode,
set the column starting address, and
adjust the OLED’s display contrast/
brightness (which also determines its
operating current).
The SH1106 and SSD1306 devices
both come in very thin (0.3mm) SMD
packages with over 260 contact pads.
In the modules, they are mounted on
the rear of the OLED screen itself.
The module circuit
Fig.2 is the circuit of a typical 1.3in
monochrome OLED module based on
the SH1106 device (those using the
SSD1306 are very similar). The OLED
is at upper right, with the SH1106
interface/display RAM/controller/
driver IC1 in the centre. The rest of the
circuit (to the left of IC1) provides the
module’s power supply and I2C input
interface.
Four-pin SIL header CON1 is used
for both power input and the I2C
interface. REG1 takes the incoming
Vcc (typically around 5V) and steps
it down to +3.3V to run both IC1 and
the OLED. The +3.3V line also drives
IC1’s reset circuit (it needs to be reset
as soon as power is applied) and feeds
the 4.7kW pullup resistors for the I2C
interface lines, SCL and SDA.
The SH1106 and the SSD1306 controllers can adopt an I2C address of
either 0x78 or 0x7A, depending on
the voltage applied to the DC input at
pin 15. If the pin is pulled to ground
(in this case, via a 4.7kW resistor), the
controller adopts the 0x78 address,
while if the pin is pulled up to +3.3V,
it responds to the 0x7A address. That
lets you run two similar OLED modules on the same I2C interface.
Most of the modules are set for the
0x78 address when you get them, but
Fig.2: the circuit diagram of the 1.3in OLED module with a SH1106 controller. The circuitry separate to the OLED matrix
and controller is for providing power and the I2C interface.
siliconchip.com.au
Australia's electronics magazine
October 2023 83
The rear of the 1.3in OLED module
shown at twice actual size.
it is relatively easy to swap the 4.7kW
resistor over to the ‘pullup’ position to change the address to 0x7A
if needed.
Some 1.3in OLED modules have a
7-pin interface header instead of the
4-pin header shown in Fig.2. These
modules allow the use of the faster
SPI interface instead of the I2C interface we’re focusing on here.
Now let’s focus on what is involved
in driving one of these modules from
an MCU like an Arduino Uno or Micromite.
Connecting it to an Arduino
Connecting a 1.3in OLED module to
an Arduino Uno is relatively straightforward, as you can see from Fig.3. The
GND and Vcc pins connect to the GND
and 3.3V pins on the Arduino, while
the SCL and SDA pins connect to the
Arduino’s A5 (SCL) and A4 (SDA)
pins, respectively.
If using an Arduino Mega 2560, the
arrangement is similar, but the module’s SCL pin goes to pin 21 of the 2560
and the SDA pin to the 2560’s pin 20.
As for software support, if you go to
the Arduino website and look at the
library listings for “Display” applications (siliconchip.au/link/abl7), you
will find quite a few libraries to do this
job: Adafruit SSD1306, GyverOLED,
OLED SSD1306-SH1106, OLED Display VGY12864L-03, ss_oled, ssd1306,
ssd1306xled and U8g2.
Another site (www.lcdwiki.com)
offers a library called “1.3inch_IIC_
OLED_Module_SKU:MC130VX”,
together with some documentation
and three example sketches. All of
these depend on the library U8g2,
which you can download as a zip file
from https://github.com/olikraus/
The three example sketches demonstrate how to draw graphics, text
strings and a BMP image on the OLED,
so they’re pretty informative. Screens
1 to 5 show some of the displays I was
able to produce using these sketches
and a blue 1.3in OLED module.
Connecting it to a Micromite
Connecting one of the 1.3in OLED
modules to a Micromite MCU is
also quite easy. Fig.4 shows the
connections needed for driving the
OLED module from a Micromite Plus
Explore 64 (August 2016; siliconchip.
au/Article/10040).
Connecting the module to a Micromite Mk2 or LCD Backpack V1/V2/
V3 would be almost the same, except
the module’s SCL pin would be connected to pin 17 of the Micromite and
the SDA pin to pin 18.
As with an Arduino, you need to
install some software to let the Micromite drive the OLED module. That
isn’t quite as easy as with the Arduinos, as there is no widely available
Micromite OLED driver software yet.
Still, because I knew that some Silicon Chip readers would want to drive
an OLED module from a Micromite,
I decided to try writing an MMBasic
program to go through the necessary
steps.
Luckily, fellow Silicon Chip staff
member Tim Blythman was able to
offer some help, as he has done quite
a bit of work with the smaller 0.96in
OLED modules (which use the same
SH1106 and SSD1306 chips) and is
very familiar with the steps needed
to drive them.
Thanks to Tim’s help, despite losing
some of my rapidly thinning grey hair,
I was able to develop an MMBasic program that can drive one of these OLED
modules from a Micromite. It demonstrates how text and simple graphics
can be displayed on its screen. The
◀ Fig.3 (left): you can use this diagram to help connect a 1.3in
OLED module to an Arduino Uno or similar.
Fig.4 (below): how to drive the OLED module via a Micromite
Plus Explore 64. You can similarly connect it to a Micromite
BackPack by connecting SCL to pin 17 and SDA to pin 18.
84
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Screens 1-6 (left-to-right, top-to-bottom): example output produced by the various test programs we downloaded or
created for use with the 1.3in (33mm) OLED module. Screen 6 at lower right is from our Micromite program.
program is called “OLED MODULE
TEST Prog2.bas”, and the display it
achieves is shown in Screen 6.
It’s a pretty basic little program
(no pun intended), and as it stands,
it only demonstrates how the OLED
module can display text and simple
graphical symbols. It doesn’t let you
type text in via the Micromite console
and display it directly on the OLED;
that would involve additional programming.
That’s because the easiest way to
drive these OLEDs is by setting the
driver chip to Page Addressing Mode,
which effectively divides the OLED
screen into eight horizontal ‘pages’,
each page consisting of 128 vertical
segments eight pixels high.
The pages are arranged vertically,
with page 0 along the top of the screen,
page 1 immediately below it and then
the remaining pages descending until
page 7 runs along the bottom of the
screen, as shown on the left side of
Fig.5.
When the driver chip updates each
page on the OLED (which it does one
page at a time), it starts at the far left
and displays the eight-pixel segments
one after the other, moving from left
to right. Each eight-pixel segment is
sent in b0 to b7 order (‘LSB-first’), as
shown on the right-hand side of Fig.5.
This Page Addressing Mode makes
it not too difficult to display lines of
text; all you need to do is work out the
sequence of segment bytes required to
show the character or symbol you want
to display, then send that sequence
to the OLED controller as a sequence
of single bytes. For text, it’s easiest to
have a line spacing of 8 pixels, meaning the characters are around 7 pixels
tall and perhaps 4-5 pixels wide.
To help you do this, I have worked
out the byte sequences for the upper
case and lower case text characters,
plus the basic numerals (0 to 9) and a
reasonable number of common symbols. These are listed in a second
dummy MMBasic program called
“OLED MODULE textchar strings.
bas”, which you can download from
the Silicon Chip website along with
“OLED MODULE TEST Prog2.bas”.
That should allow you to write a
program that can display up to eight
lines of text on the screen of one of
these 1.3in OLED modules.
Drawing detailed graphics on the
OLED screen is a bit more involved
but, as the demonstration program
shows how to write pixels into the
OLED’s display RAM, that should provide a starting point for more advanced
graphics.
A reader with more programming
experience might accept the challenge
of creating a full display driver for
these OLEDs, possibly based on the
SC
starting point I have provided.
Fig.5: Page Addressing Mode divides the OLED into eight sections as shown. This is the easiest way to drive the OLED.
siliconchip.com.au
Australia's electronics magazine
October 2023 85
|