Bit-bang Serial Control of Newhaven OLED Character Display

This page is about implementing a serial bit-bang protocol to control a Newhaven Display International OLED character display.

image

Introduction

OLED (Organic Light Emitting Diode) displays offer wider viewing angles, improved brightness and contrast, and are self-illuminating (require no backlight). Newhaven offers several models of OLED display that use the same version of built-in controller. The built-in controller offers both serial and a 6800/8080 compatible parallel interface.

Application

The application example mates a dsPIC33FJ256GP710-I/PT with a Newhaven OLED. The embedded software implements a simple serial bit-bang protocol to control the OLED and display a message.

While this example implementation uses the dsPIC33FJ256GP710-I/PT, it is easily adapted to other Microchip microcontrollers by making device appropriate pin assignments. The source code could also be used as a reference or ported to other manufacturers microcontroller products.

The Newhaven OLED displays listed in Tables 1 and 2 utilize the same version of built-in controller. The demonstration source code and accompanying program file can be used without modification to drive the OLED displays listed in Table 1.

Additionally, the Newhaven OLED displays listed in Table 2 are compatible with the embedded source code. These displays have additional characters on a line, or additional lines and characters, and can be successfully driven with minor changes to the embedded source code.

Part Number Description
NHD-0216SZW-BY5 2 line x 16 character, yellow
NHD-2016SZW-BG5 2 line x 16 character, green
NHD-0216KZW-AB5 2 line x 16 character, blue
NHD-0216KZW-AY5 2 line x 16 character, yellow
NHD-0216KZW-AG5 2 line x 16 character, green

Table 1.

Part Number Description
NHD-0220DZW-AY5 2 line x 20 character, yellow
NHD-0220DZW-AG5 2 line x 20 character, green
NHD-0420DZW-AY5 4 line x 20 character, yellow
NHD-0420DZW-AG5 4 line x 20 character, green

Table 2.

Hardware

The hardware used in this example is a Newhaven 2x16 OLED character display and the Microchip Explorer 16 DM240001-ND (requires an ICD3 or other programmer/debugger) or DV164037-ND development board with the included Microchip dsPIC33FJ256GP710-I/PT Processor Installation Module (PIM). The Prototype PICtail Plus Daughter Board AC164126-ND is used to access the port pins brought out on the Explorer 16 board.

Display interface configuration - parallel or serial?

By default, all of the displays listed in Tables 1 and 2 support the 6800 MPU parallel interface. (Note: displays factory-configured for 8080 or serial interface can be ordered as a custom option. Minimum order quantities will apply.) Jumper settings are provided in the product data sheet to configure a display to support the 6800 MPU, 8080 MPU, or a serial interface. Any changes to the jumper connection will require a soldering iron and repositioning/omitting 0 ohm resistors. The photos in figures 1-4 clarify the jumper locations on each PCB. Each photo is applicable to multiple displays indicated in the adjoining list of part numbers.


Figure 1. Jumper locations for NHD-0216KZW-AB5, NHD-0216KZW-AG5, and NHD-0216KZW-AY5.


Figure 2. Jumper locations for NHD-0216SZW-BG5 and NHD-0216SZW-BY5.


Figure 3. Jumper locations for NHD-0220DZW-AG5 and NHD-0220DZW-AY5 .

image
Figure 4. Jumper locations for NHD-0420DZW-AG5 and NHD-0420DZW-AY5.

Software

The default build supports a 2x16 display, but any of the displays will actually work with the code built as-is with limitations - the additional characters and lines available in the other display variants will be blank. Preprocessor directives provide conditional compilation of particular lines of code to accommodate the display variants with messages that take advantage of the available lines and characters.

A ZIP file with demonstration source code and hex file compiled for the example processor can be found linked below as a supporting file. The hex file can be found in folder “…/NHD_OLED_bitbang/NHD_OLED_BB.X/dis/default/production/NHD_OLED_BB.X.production.hex”.

To build for a particular display comment/uncomment the appropriate prepocessor directive in file nhd_oled_2x16_main_bb.c:

Preprocessor conditional compile directives

#define OLED_2x16     // For two line display has two lines, each line has 16 characters
//#define OLED_2x20     // For two line display, each line has 20 characters
//#define OLED_4x20     // For four line display, each line has 20 characters

The source code displays a message that utilizes the built-in font table and also the custom character capability of the display. The message displayed, depending upon line count and length:

1st line is “Newhaven OLED…”
2nd line is “From Digi-Key x”
(Where the “x” is a place holder for a character animation sequence made up of built-in and custom characters “|”, “/”, “-“, and “\”. After a brief delay a custom character clears the display and then the display sequence repeats.)

4 line displays add the following text:
3rd line is “4 lines a r e better”
4th line is “t h a n t w o …!”

Clock frequency of the dsPIC33FJ is configured for 7.37Mhz. A different clock frequency will necessitate a change to the software based time delay routine. Port pins are assigned as follows: RA4 – LCD select, RF6 – Serial clock, RF7 – Serial data in (data from LCD – this is not implemented), and RF8 – Serial data out (data to LCD).

Project Build and Load

It is left to the reader to install and familiarize themselves with MPLAB X IDE, the XC16 compiler, and hardware connections from/to the Explorer 16 development board to their display board.

Expand/copy the zip file to desired system location. Open MPLAB X IDE, connect the hardware to your computer, and open project “NHD_OLED_BB”. Open the project properties to verify hardware and software tool selection matches your installation. Make and Program device.

Supporting Files

Demo Software

NHD_OLED_bitbang.zip (84.8 KB)

Application Notes

Newhaven App Note: Serial vs. Parallel Interface