how can display a variable
antonis
Posts: 9
hello,
i'made a circuit to drive a LCD with 3 wire, with help of 74hc595 shift register.
I can do my LCD show me message where i store in my eprom with DATA command but i don't undertand what is the way to show a value of· a variable for example i have· a bouton and every time where i pressed count increament and store in a variable.
how i can see this in my LCD:
ex:
addv VAR Nib
start:
·if IN1=1 THEN add
·GOTO start
add:
·addv=addv+1
·goto start
'How i can see the addv on LCD
THIS IS MY CODE FOR THIS WORKS
'
pin definition
'
'LCD_PINS
clk···· CON··· 0······················· 'clock pin on 74hc595
latch·· CON··· 1······················· 'latch pin on 74hc595
sdata·· CON··· 2······················· 'data pin on 74hc595
'
LCD control characters
ClrLCD· CON···· $01···················· ' clear the LCD
CrsrHm· CON···· $02···················· ' move cursor to home position
CrsrLf· CON···· $10···················· ' move cursor left
CrsrRt· CON···· $14···················· ' move cursor right
DispLf· CON···· $18···················· ' shift displayed chars left
DispRt· CON···· $1C···················· ' shift displayed chars right
DDRam·· CON···· $80···················· ' Display Data RAM control
CGRam·· CON···· $40···················· ' Char Gen RAM control
'
LCD_variables
char··· VAR···· Byte··················· ' character sent to LCD
temp··· VAR···· Byte··················· ' work variable for LCD routines
index·· VAR···· Byte··················· ' loop counter
lcd_E·· VAR···· temp.BIT2·············· ' LCD Enable pin
lcd_RS· VAR···· temp.BIT3·············· ' Register Select (1 = char)
'
EPROM DATA
msg1··· DATA·· "test circuit"
'
Initialize the LCD (Hitachi HD44780 controller)
LCDini:
· PAUSE 500···························· ' let the LCD settle
· char = %0011························· ' 8-bit mode
· GOSUB LCDcmd
· PAUSE 5
· GOSUB LCDcmd
· GOSUB LCDcmd
· char = %0010························· ' put in 4-bit mode
· GOSUB LCDcmd
· char = %00001100····················· ' disp on, crsr off, blink off
· GOSUB LCDcmd
· char = %00000110····················· ' inc crsr, no disp shift
· GOSUB LCDcmd
'
main program
Start:
·GOSUB LCDcmd
·FOR index = 0 TO 11
·READ Msg1 + index,char······· ' get character from EEPROM
·GOSUB LCDwr
·NEXT
GOTO start
'
LCD routines
LCDcmd:
· lcd_RS = 0····················· ' command mode
· GOTO LCDout
LCDwr:
· lcd_RS = 1····················· ' character mode
· GOTO LCDout
LCDout:
· temp.HIGHNIB = char.HIGHNIB··· ' get high nibble
· lcd_E = 1
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· lcd_E = 0···························· ' drop Enable line low
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· temp.HIGHNIB = char.LOWNIB··········· ' get low nibble
· lcd_E = 1
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· lcd_E = 0
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· RETURN
i'made a circuit to drive a LCD with 3 wire, with help of 74hc595 shift register.
I can do my LCD show me message where i store in my eprom with DATA command but i don't undertand what is the way to show a value of· a variable for example i have· a bouton and every time where i pressed count increament and store in a variable.
how i can see this in my LCD:
ex:
addv VAR Nib
start:
·if IN1=1 THEN add
·GOTO start
add:
·addv=addv+1
·goto start
'How i can see the addv on LCD
THIS IS MY CODE FOR THIS WORKS
'
pin definition
'
'LCD_PINS
clk···· CON··· 0······················· 'clock pin on 74hc595
latch·· CON··· 1······················· 'latch pin on 74hc595
sdata·· CON··· 2······················· 'data pin on 74hc595
'
LCD control characters
ClrLCD· CON···· $01···················· ' clear the LCD
CrsrHm· CON···· $02···················· ' move cursor to home position
CrsrLf· CON···· $10···················· ' move cursor left
CrsrRt· CON···· $14···················· ' move cursor right
DispLf· CON···· $18···················· ' shift displayed chars left
DispRt· CON···· $1C···················· ' shift displayed chars right
DDRam·· CON···· $80···················· ' Display Data RAM control
CGRam·· CON···· $40···················· ' Char Gen RAM control
'
LCD_variables
char··· VAR···· Byte··················· ' character sent to LCD
temp··· VAR···· Byte··················· ' work variable for LCD routines
index·· VAR···· Byte··················· ' loop counter
lcd_E·· VAR···· temp.BIT2·············· ' LCD Enable pin
lcd_RS· VAR···· temp.BIT3·············· ' Register Select (1 = char)
'
EPROM DATA
msg1··· DATA·· "test circuit"
'
Initialize the LCD (Hitachi HD44780 controller)
LCDini:
· PAUSE 500···························· ' let the LCD settle
· char = %0011························· ' 8-bit mode
· GOSUB LCDcmd
· PAUSE 5
· GOSUB LCDcmd
· GOSUB LCDcmd
· char = %0010························· ' put in 4-bit mode
· GOSUB LCDcmd
· char = %00001100····················· ' disp on, crsr off, blink off
· GOSUB LCDcmd
· char = %00000110····················· ' inc crsr, no disp shift
· GOSUB LCDcmd
'
main program
Start:
·GOSUB LCDcmd
·FOR index = 0 TO 11
·READ Msg1 + index,char······· ' get character from EEPROM
·GOSUB LCDwr
·NEXT
GOTO start
'
LCD routines
LCDcmd:
· lcd_RS = 0····················· ' command mode
· GOTO LCDout
LCDwr:
· lcd_RS = 1····················· ' character mode
· GOTO LCDout
LCDout:
· temp.HIGHNIB = char.HIGHNIB··· ' get high nibble
· lcd_E = 1
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· lcd_E = 0···························· ' drop Enable line low
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· temp.HIGHNIB = char.LOWNIB··········· ' get low nibble
· lcd_E = 1
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· lcd_E = 0
· SHIFTOUT SData, Clk, 1, [noparse][[/noparse]temp]
· PULSOUT Latch, 1
· RETURN
Comments
Lcd_DEC5:
· FOR idx = 4 TO 0
··· temp = (myValue DIG idx) + "0"
··· GOSUB LCDwr
· NEXT
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
this··works very good