Let's Make Robots!

Creating a Picaxe 08M LCD Driver ( 2 wire Driver )

A few weeks back I decided to make another attempt at driving an LCD using picaxe. My first attempt was almost a year ago, however when the $6 LCD failed to display anything I wrote it off as defective.

But after a long night where i found it hard to sleep i stumbled on a  site that should me clearly how to power up and set the contras with backlight on. 15 minutes in and i was hooked. LCD light boxes displayed as i adjusted the contrast using a 1oK pot.

A project was born. I now have a self designed had soldered dev board with a picaxe 8M and a 74HC595 shift register. A sample code and an LCD displaying the classic "Hello World".

Over the next couple of days I will upload video and images detailing the build. 

Final board should be driven by an 8M picaxe which is fed serially by  another picaxe using serial command. Orginal board is designed to take a digital input to determine whether to write to the Data register or teh instruction registery. I have seen where I should be able to send the same registry select option serially as well along with the data to display.

More on this with PCB design and layout in the days ahead

 

<code>

#Picaxe 08M

 

SYMBOL SERIALDATAPIN = 0

SYMBOL CLOCK_PIN = 1

SYMBOL RS = 2 ; 0 - Command Mode 1 - Data Mode

SYMBOL LCD_ENABLE = 4

 

SETFREQ M4

 

EEPROM 0,("HELLO WORLD...")

EEPROM 16,("IT'S MARLON")

gosub INIT_LCD

 

main:

;write first line of text

for b0=0 to 13

read b0,b1

gosub WRITE_DATA

next b0

;move to line two

let b1=0xC0 ;move cursor to start of line two

gosub WRITE_CMD

for b0=16 to 26

read b0,b1

gosub WRITE_DATA

next b0

wait 5

let b1=1 ; clear screen

gosub WRITE_CMD

goto main

 

INIT_LCD:

pause 200

let b1 = 56 ; 8 bit operation

gosub WRITE_CMD

let b1 = 15 ; Display cursor 

gosub WRITE_CMD                                                                                                                                                                                                                                                                                      

RETURN

WRITE_CMD:

HIGH LCD_ENABLE ;lock LCD for input

LOW RS ; selecting instruction register

GOSUB TRANSFERTO74HC595

pause 2

LOW LCD_ENABLE ; release LCD to take values from 74hc595

HIGH RS ;reset register for Data default

RETURN

 

WRITE_DATA:

HIGH LCD_ENABLE ;lock LCD for input

HIGH RS ; selecting data register

GOSUB TRANSFERTO74HC595

pause 2

LOW LCD_ENABLE ; release LCD to take values from 74hc595

HIGH RS ;reset register for Data default

RETURN

 

TRANSFERTO74HC595:

LOW CLOCK_PIN

let b2=b1

let b4=0

for b3=0 to 7

b4 = b2 & %00000001

if b4=0 then

LOW SERIALDATAPIN

else

HIGH SERIALDATAPIN

endif

pulsout CLOCK_PIN,1

b2 = b2 /2

pause 20

;wait 1

next b3

pulsout CLOCK_PIN,1

RETURN

</code>

AttachmentSize
image.jpg289.56 KB
image.jpg298.61 KB
image.jpg290.25 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Why would you not just use a micro with more pins? I checked sparkfun for pricing. An 08m is 2.95. A 75hc595 is 1.50. A 14m is 3.95.

I am sure you could find better prices around, but, adding the shift register just seems to make things more complex than they need to be. With a 14m you could probably drive the LCD in 8bit mode.

I am not saying I haven't considered trying to do a whole lot with an 8 pin uC before. It just doesn't seem that this is the best way to go about things when it seems to only be adding complexity to the build.

I gave thought about using a 14m for about a second, but I like pushing the envelop with challenges. Doing it with an 8m and shift register presented me with a few challenges. I could have easily bought the frmxxx chip as well from picaxe but where is the fun in that 1) writing my own version of an lcd driver 2) doing the perfboard routing manually and watching my creation come to life 3) doing serial communication between two picaxe

The "because I can" argument. :D Perfect.