people have asked me recently to convert my old 8051 based moving message
display project [shown HERE]
from the 8051 core to the PIC with PicBasic Pro. I found some
spare time - and made the code conversion from 8051 assembly to
PicBasic Pro, so here we go...!
Special thanks to Dave
Barker for making this conversion/debugging process "Super Easy" with
his excellent MicroCode Studio ICD. This project could have taken several
hours [or worse], but the ICD helped make the conversion quick & painless,
and I had the project up & going in about 45-minutes [fifteen minutes
were breaks for a cold Budweiser]. If you're not familiar with the MicroCode Studio ICD, check
out Dave's web site here
displays are a lot of fun, and one of my favorite projects to work on. A
scrolling message display would be a great
addition to a robotics or other project that needs a message display. Snap one on your hat before you go to that
next football game, but carry a few spares. You'll probably
sell a few while you're there..!
Below is a "static"
picture of the display in action. It scrolls from right to left in normal
operation, but you can experiment to see the effect of changing the scroll
Click me for a larger
photo of the display
If you have the "Windows
Media Player" - here's a short MPG movie file of
the display working. The colors aren't true, but that's the best my
"El-Cheapo" digital camera would produce. The movie file gives you a good
idea of how the finished project works, shows how the display scrolls & the
scroll speed when set to 300 as in the sample code.
I won't go into great
detail here since the simple code & datasheet will have you up & running with a
scrolling display in just a few minutes. You can easily modify this
sample code for use with other projects. I used the PIC16F877 running at 20MHz, but the 16F876
will work equally well for this project. Connections from the PIC to display
are shown in the lower section of the project code, and quite simple, but if
you have questions, don't hesitate to ask.
Before you get started, I highly recommend downloading & printing the
HDSP-2112 display datasheet
HERE so you'll
understand how & why this all neat stuff actually works....;o]
These displays aren't
cheap, but they are nice, and don't require series current-limiting
resistors for the matrix LED's. You have software control of the display
brightness settings - and current consumption. Just change the value
in the display initialization routine to change the display brightness.
To change the display
scroll speed - just change the value in:
S_Speed = 300 ' Set display scroll speed here
HDSP-2112 Display Pin
'* Name : HDSP2112.BAS *
'* Author : Bruce Reynolds *
'* Notice : Copyright (c) 2002 Reynolds Electronics *
'* : All Rights Reserved *
'* Date : 6/21/2002 *
'* Version : 1.0 *
'* Notes : Connections shown at bottom of page *
'* : Tested with HDSP-2112 Display & PIC16F877 *
DEFINE OSC 20 ' 20MHz oscillator
DEFINE LOADER_USED 1' Using boot-loader for initial prototype
TRISA = 0 ' Setup PortA = output for Address Bus
TRISB = 0 ' Setup PortB = output for Data Bus
TRISC = $80 ' RC.7 = input, rest outputs [used for loader]
ADCON1 = 7 ' A/D OFF
A_Bus VAR PortA ' PortA Address Bus
D_Bus VAR PortB ' PortB = Data Bus
W_Pin VAR PortC.0 ' HDSP-2112 write strobe pin #13
A3 VAR PortC.1 ' HDSP-2112 mode select pin #6
RST VAR PortC.2 ' HDSP-2112 reset pin #1
Digit VAR BYTE ' 8-byte digit array
DigPat VAR BYTE ' Digit pattern from lookup table
LP_Cnt VAR BYTE ' Loop counter
LowDig VAR BYTE ' Holds "low" digit # to lookup
LowDig = 0 ' 1st digit = 0
HiDig VAR BYTE ' Holds "high" digit # to lookup
HiDig = 7 ' Last digit = 7
J VAR BYTE ' Array index pointer
J = 0 ' 1st byte in array
S_Speed VAR WORD ' Holds display scroll speed
S_Speed = 300 ' Set display scroll speed here
LOW D_Bus.7 ' Set display for normal operation
EOM CON "~" ' Character used as "End of Message" marker
'* // Initialize display - then set brightness * //'
' * // Initialize Display Here * //'
HIGH W_Pin : LOW RST : PAUSE 10 : HIGH RST : PAUSE 10
' * // Set Display Brightness Here * //'
' To change display brightness
' D_Bus = | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
' Bright =| 100% | 80% | 53% | 40% | 27% | 20% | 13% |
' Set 27% | mode.bit | strobe settings into display |
D_Bus = 4 : LOW A3 : LOW W_Pin : HIGH W_Pin
HIGH A3 ' A3 used only for setting display brightness
'* // Get 8 digits into "Digit Array" for display * //'
FOR LP_Cnt = LowDig TO HiDig
LOOKUP LP_Cnt,[" Hello.! ~"],DigPat
Digit[J] = DigPat ' Load all 8 digits into array
J = J + 1 ' Increment array index pointer
NEXT ' Loop until we have all 8 digits loaded
J=0 ' Re-set array index pointer
LowDig = LowDig + 1 ' Increment to next "low" digit
HiDig = HiDig + 1 ' Increment to next "high" digit
' * // We're using the "~" character in EOM to tag the end of message * //'
IF Digit = EOM THEN ' End-of-message indicator..?
Digit = " " ' Then load a "blamk space" character
LowDig = 0 ' Re-load 0-7 MAX digit count
HiDig = 7 '
'* // Display 8 digits on display then return for more // *'
FOR LP_Cnt = 0 TO 7 ' Scroll right-to-left
A_Bus = LP_Cnt ' Place digit address on address bus
D_Bus = Digit[J] ' Place digit data on data bus
LOW W_Pin : HIGH W_Pin' Strobe data into display
J = J + 1 ' Increment array pointer to next digit
J = 0 ' Re-set array index pointer
PAUSE S_Speed ' Set display scroll speed
'* // Display connections * //'
' PortB Display | PortA Display | PortC Display
' B0 #19 | A0 #3 | C0 #13
' B1 #20 | A1 #4 | C1 #6
' B2 #23 | A2 #5 | C2 #1
' B3 #24
' B4 #25
' B5 #26
' B6 #27
' * // Display GND, VCC and N.C. [no connection] * //'
' GND 15,16,17,28
' VCC 2,7,8,9,10,11,14,18
' N.C. 12
HDSP-2112 Displays: http://www.future-active.com/
I found Future to be reasonably priced on the HDSP-2112 displays. Other
sources are well over $40.00 per unit.
Future Part #: HDSP-2112
A BIG thanks to Robert Coward for submitting this display driver
routine in C. Roberts' version can be compiled with the FREE student edition
C18 compiler available for download from
Download Roberts C source code
HERE. His source
code is very well documented, and includes hookup information.
Robert has submitted an updated
The new version has an RS232
interface (HDSP2112_serial.c). This presents a menu allowing the user to
record their own message, adjust the brightness and scroll speed and run the
display self test. Also included is an updated version of his original
driver (HDSP2112_test.c), as this still demonstrates more features of the
display (such as user defined characters).
Until the next project - have fun - and
don't blow anything up...;o]
Back to the PicBasic Projects
© 1999-2008 Reynolds Electronics