Let's Make Robots!

LCD simplicity

hi peeps

i just bought a pack of these from maplin and regarding the HD44780-compatible LCD...

i know the simplest thing i can do is link the pins directly to my picaxe 28x1 but i was looking to save pins and build my own little three pin pcb "serial backpack" .

any idea what would make a good intermediary chip to do the job for me?

essentially i want to give my bot AKIRA a direct output as its programming is running (to fix problems first and then to communicate) but i'm getting seriously bogged down by all the info that is out there (amongst other things) so i'm hoping someone out there has experience of a essentially cheap alternative to the actual serial backpacks

thanks

 

dom

 

Comment viewing options

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

to make a similar circuit work. A link to the page I copied this from.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
module TW_LCD
' * Project name:
'     module TW_LCD.pbas
' * Copyright:
'     Public Domain, 2008
' * Author   :
'     Csaba Zvekan
' * Revision History:
'     20080428:
'       - initial release.
' * Description:
'     This code demonstrates the two wire Serial LCD Interface originaly
'     designed Myke Predko. The main code here was written in MikroC by Rich Irace.
'     I took a different approach for the NybbleShift Routine. More like what
'     myke suggested  on http://www.myke.com/lcd.htm. Also changed some LCD
'    timing values.
'     Except at the end I keep Data lines high then low. Different from his
'     website stated where he keeps clock High then low (to enable "E"pin)
' * Test configuration:
'     MCU:             PIC18F452
'     Dev.Board:       EasyPIC4
'     Oscillator:      HS, 4 - 48.000 MHz   fully Tested
'     Ext. Modules:    TW_LCD board, Lcd_2x16
'     SW:              mikroBasic v6.0 or higher
' * NOTES:
'     - In order to have valid function, PORTx pin's must be connected to
'       pull-up/ or down resistors !
'     - LEDiodes on PORTx should be turned off !
symbol Clk  = PORTB.4         ' PORTB6 for the Clock Signal
symbol Data = PORTB.3          ' PORTB7 for the Data Signal
'* This is where you define the two lines for Clock / Data
'**********************************************************************
symbol row1  =  %00000000        '  Define on  LCD Row1 (0)
symbol row2  =  %01000000        '  Define on  LCD Row2 (64)
'symbol Lcd_Clear = %00000001    '  Define LCD_CLEAR
 
const ClockDelay as byte  = 160
dim  progarray as string [17]
'*****************************************************************
'* Shift Out the Nybble
'*****************************************************************
sub procedure NybbleShift(dim Nybble as byte, dim RS as byte)
dim i as byte
'**  Empty shift register by writing 6 zeroes to it
    Data = 0
    for i= 1 to 6       'Clear the Shift Register  by writing
        Clk  = 1        '6 times data 0
        Clk  = 0
    next i
'** Output  E-pin on LCD at the end of the 6th bit
        Data = 1
        Clk  = 1
        Clk  = 0
'** Output RS-Pin on LCD at 5th position
        Data = RS
        Clk  = 1
        Clk  = 0
'** Output the Nybble   highest bit first
      for i= 1 to 4
        if Nybble.3  = 1 then    ' look at bit MSB  lower nybble
           Data = 1
         else
           Data = 0
        end if
        Clk = 1
        Clk = 0
        Nybble= Nybble << 1
        next i
'** Finish Nybble write with E-pin High
        Data  = 1                ' E-pin goes high by pulling Data high
        delay_us(1)              ' 450nS for the delay
        Data  = 0
end sub
'**********************************************************************
'* Write a byte to LCD with option RS(xx,1) HIGH or RS(xx,0) LOW
'**********************************************************************
sub procedure TW_LCD_Write(dim LCDData as byte,dim RSValue as byte)
dim  j,t as byte
    t = 0
    j = 0
    j = LCDData                  'save LCDData to j
    NybbleShift((j >> 4)and 0x0F, RSValue )     'Shift out High Nybble
    'delay_us(ClockDelay)        ' 450nS for the clock only if necessary
    t = (LCDData << 4)
    t = (t >> 4)
    NybbleShift(t and 0x0F, RSValue)      'Shift out Low Nybble
    'delay_us(ClockDelay)        ' 450nS for the clock
    if ((LCDData AND 0xFC) + (RSValue)) = 0  then
        delay_ms(5)              ' to be adjusted even higher !!!
        else
        delay_uS(160)            ' to be adjusted even higher !!!
    end if
end sub
'**********************************************************************
'* Converts digital value to BCD
'**********************************************************************
sub function NumToChar(dim  valu as integer)as integer
   dim ch as integer
   if valu < 10 then
    ch=valu + 48                 ' 48 = '0'
   else
    valu=valu - 10
    end if                       ' 65 = A   in MIKROC
    ch=valu + 48                 ' 48 for MikroBasic
    result = ch
end sub
'***********************************************************************
'* LCD to BCD  displays byte in decimal as either 1, 2 or 3 digits
'***********************************************************************
sub procedure LCDtoBCD(dim valu as integer,dim digits as integer)
   dim d as integer
   dim ch as integer
   if digits = 3 then           ' Take 100's Digits
     d = valu/100                 ' Divide it by 100
     ch = NumtoChar(d)           ' Take number, convert it to ASCII
        ' lcdchar(ch)            ' number (0 - 9)
    TW_LCD_Write(ch, 1)           ' Send that value to display
   end if
   if (digits >1) then           ' Take the two lowest digits
      valu = valu mod 100
      d = valu/10
      ch = NumtoChar(d)
                                  ' lcdchar(ch)
    TW_LCD_Write(ch, 1)
   end if
   if (digits = 1)then           ' Take the least significant digit
      valu = valu mod 100
   end if
      d = valu mod 10
       ch = NumtoChar(d)
         ' lcdchar(ch)
    TW_LCD_Write(ch, 1)
end sub
'**********************************************************************
'* LCD Configuration TW_LCD     but it don't work !!!
'**********************************************************************
'sub procedure TW_LCD_Config(dim byref data_port as byte,dim Clk1, Data1 as byte)
'symbol Clk  = data_port.Clk1         ' PORTB6 for the Clock Signal
'symbol Data = data_port.Data1        ' PORTB7 for the Data Signal
'end sub
'**********************************************************************
'* Reset TW_LCD
'**********************************************************************
sub procedure TW_LCD_Reset()
    TW_LCD_Write(%00101000, 0)   ' Switch to 4-Bit mode 2 lines
    TW_LCD_Write(%00010000, 0)   ' Turn Off the Display
    TW_LCD_Write(%00000001, 0)   ' Clear LCD and Home Cursor
     TW_LCD_Write(%00000110, 0)   ' Move Cursor After Each Character
    'LCDWrite(%00010000, 0)      ' Shift Cursor without chasngin DD Reg
    'LCDWrite(%00001111, 0)      ' Turn On LCD and Enable Cursor & Blink
    TW_LCD_Write(%00001100, 0)   ' Turn On LCD and Disable Cursor& Blink
end sub
'************************************************************************
'* Initializes the Two Wire LCD
'************************************************************************
sub procedure TW_LCD_Init()
    delay_ms(20)
      NybbleShift(3, 0)          ' Init LCD
    delay_ms(5)
      NybbleShift(3, 0)          ' Init LCD
    delay_us(160)
       NybbleShift(3, 0)          ' Init LCD
    delay_us(160)
      NybbleShift(2, 0)          ' Set LCD 4 Bit Mode
    delay_us(160)
    TW_LCD_Reset()               ' Call Reset LCD
end sub
'************************************************************************
'* Sends LCD Commands to the TW_LCD Interface  same as MikroE
'************************************************************************
Sub procedure TW_LCD_CMD(dim TW_command as byte)
TW_LCD_Write(TW_command, 0)     ' Send out a TW_ LCD Command
end sub
'***********************************************************************
'* Displays String to the TW LCD
'*
'* When row is 1,  Characters are displayed on LCD Row 1  v 0
'* When row is 2, Characters are displayed on LCD Row 2   v 64
'***********************************************************************
sub procedure TW_LCD_Out(dim row as byte,dim character as byte, dim byref s as string [16])
  dim i as byte
  if row =1 then row = row1
  end if
  if row =2 then row = row2
  end if
    TW_LCD_Write(%10000000 + row + (character-1), 0)      'Move Cursor to the corresponding Row
  i = 0
  while (s[i] <> 0)        'Display the string
  TW_LCD_Write(s[i],1)
  inc(i)
  wend
end sub
end.

 

And a the schematic for the connections (also, the link to the site to read more about the way the circuit works):


 

Blue Beta's picture

my basic looks nothing like that - a healthy reminder that i have a lot to learn (my different background might be affecting my style too)

having said that - at least i understand my own style ^--^

thanks tho - i'll keep it in mind

dom

Blue Beta's picture

i just found this rather decent vid explaining it

Shift Register 8-Bit - 74HC595

 

(the fact that i missed that you had put the name of the shift register in the subject line didnt help - damn im tired)

thanks bdk6

 

dom

bdk6's picture

Hope I was of some service.  Glad to help when I can.

Blue Beta's picture

i just ebayed ten of them so i really hope youre right

(dont worry - i did my research first and you were spot on - the other nine are for a potential 9 section SIPO in the future)

dom

bdk6's picture

If I remember correctly, the picaxe has a command ( shiftout?) that will do most of the work for you.  

Blue Beta's picture

it only works in X1 or X2 versions but the help menu contains subs which will create your own commands in the others

so... yes

just put it in for continuity

dom

bdk6's picture

Google likes specifics.  I googled 74hc595 lcd picaxe and found this:

http://www.electronics-lab.com/projects/mcu/015/index.html

It looks like a pretty good intro with a good schematic.  It seems to have code written for a bare pic, but it shouldn't be hard to figure out what's going on.  Basically, you put one bit of data on a pin, then raise and lower the "clock" pin.  Do that for all eight bits, then pulse another line to tell the shift register you are through and transfer all eight bits to the output.  That is how all serial interfaces work, except some provide separate clocks on each end ( RS232 serial, UARTs, and such).

bdk6's picture

This shift register is perfect for that application.  I do believe someone posted a tutorial here doing just that.  If not, Google will show you plenty.

Blue Beta's picture

In digital circuits, a shift register is a cascade of flip flops, sharing the same clock, in which the output of each flip-flop is connected to the "data" input of the next flip-flop in the chain, resulting in a circuit that shifts by one position the "bit array" stored in it, shifting in the data present at its input and shifting out the last bit in the array, at each transition of the clock input.(wikipedia)

how about we assume that most of what im reading is complete gibberish to me and that perhaps google is giving me TOO MUCH info