image_34.jpg (291663Bytes)
image_35.jpg (299938Bytes)
image_36.jpg (269315Bytes)
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>