Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 3rd November 2007, 04:27 PM   (permalink)
Default HD44780 lcd help

Hi all, I am new to electronics and micro pic's but have been playing around for the last few months and got a lcd working as i want it too, my problem is that i wanna make a project that i need alot of I/O from my 16f876a so i was wounding if it was possible to use spi on the pic to a 8 bit latch (74hc595n) to drive the lcd if i changed my code.

I came across the 74hc595n when looking at other peoples projects and falt it mite work as i wanna use spi for something else on the project to.

thanks for any help, sorry if this is a stupid question.
jay543_uk is online now  
Old 3rd November 2007, 04:30 PM   (permalink)
Default

Well it's a circuit from Myke Predko not a true SPI device but just toggle the bits on any standard I/O pins.
http://www.myke.com/lcd.htm
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 3rd November 2007, 05:42 PM   (permalink)
Default

You could also use a slave PIC just to feed the LCD, and a single pin to transfer the data over a serial link - you can even buy serial LCD's that are just that.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 3rd November 2007, 07:29 PM   (permalink)
Default

use 74138 decoder if using that port some where else too and 8255 PPI.
simpler and effective. can find alot of help around.
best of luck
jawadlateef is offline  
Old 3rd November 2007, 09:29 PM   (permalink)
Default

I'm working on a 1-pin serial interface concept that uses an 8-pin PIC but it's probably a long way from working, tested, and finished.

Good luck. Mike

Attached Images
File Type: png K8LH 1-Wire LCD+Keypad.PNG (43.6 KB, 139 views)
Mike, K8LH is offline  
Old 3rd November 2007, 09:34 PM   (permalink)
Default

Quote:
Originally Posted by jawadlateef
use 74138 decoder if using that port some where else too and 8255 PPI.
simpler and effective.
Perhaps you've misread the question?, or totally lost the plot?

An 8255 is a pretty naff PIO chip anyway, and completely unsuitable for connecting to a PIC, which already far out performs it. Likewise, what has a 74138 got to do with it?, these are suggestions for an old Z80 system.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 4th November 2007, 02:35 PM   (permalink)
Default

Mike,

I saw this concept earlier, but I didn't have time to study the code and concept. If I read you correctly,

1. You are running an LCD that requires a minimum of six I/O pins with a PIC that only has six I/O pins.

2. GP3 is both the RS control and serial input.

3. You raise the E line to write to the LCD, which is normal.

4. You prefer MS Excel Pink for your color background.

Explain the RS function more. I'm also confused by the data lines to the host PIC, that appear to by a parallel, 4 bit, input
bobledoux is offline  
Old 4th November 2007, 04:33 PM   (permalink)
Default

Hi jay543_uk,

Check page 5-69 of attached pdf.
LCD connected on PCF8574 I²C I/O expander to µC (ok it's a 8051 but principle is the same).
If later on you need other functionalities, just "plug" them on the I²C bus
Attached Files
File Type: pdf AT89C2051--AppNote I²C---DOC0593.pdf (82.2 KB, 9 views)
mcs51mc is offline  
Old 4th November 2007, 04:40 PM   (permalink)
Default

Sorry dude you are right
Infact i am a newbie and working with MCS 51 family only. no idea of PIC controllers.
As far as 74138 is concerned i suggested it because (although i have written) if he wants to use the same port for other purpose then he could select the devices through it.
thanx for my correction
jawadlateef is offline  
Old 4th November 2007, 08:22 PM   (permalink)
Default

Quote:
Originally Posted by bobledoux
Mike,

I saw this concept earlier, but I didn't have time to study the code and concept. If I read you correctly,

1. You are running an LCD that requires a minimum of six I/O pins with a PIC that only has six I/O pins.

2. GP3 is both the RS control and serial input.

3. You raise the E line to write to the LCD, which is normal.

4. You prefer MS Excel Pink for your color background.

Explain the RS function more. I'm also confused by the data lines to the host PIC, that appear to by a parallel, 4 bit, input
Hi Bob,

1) Yes, I'm driving an LCD that requires 6 signals minimum from a PIC with only 5 outputs
2) Yes, the serial signal on GP3 provides the LCD with the 'RS' register select signal during the 'E' pulse.
3) Yes, qualified by the CX bit (b6) which when CX=1 doesn't produce the 'E' pulse and so doesn't write the LCD
4) Yes, pink is "in" (grin)

The LCD 'RS' register select pin is used to select 'command' or 'data' LCD registers during an LCD write operation. This LCD interface design requires the Host to send each byte of data as two serial bytes which contain nybble data in b3:b0 and the 'RS' register select bit in b7;

send '0000 nnnn' to write nybble 'nnnn' to LCD RS0 (LCD command register)
send '1000 nnnn' to write nybble 'nnnn' to LCD RS1 (LCD data register)

This means we need a small (12 word) low-level driver on the Host to send each byte as two serial nybble+rs bytes to the LCD interface;
Code:
;******************************************************************
;
;  Host low level LCD interface driver
;
PutCmd
        clrf    mask            ; mask = '00000000' (RS=0)        |B0
        skpz                    ;                                 |B0
PutDat
        bsf     mask,7          ; mask = '10000000' (RS=1)        |B0
        movwf   Temp            ; save data                       |B0
        call    PutNyb          ; send right nybble + RS bit      |B0
        swapf   Temp,W          ; send left nybble + RS bit       |B0
PutNyb
        andlw   0x0F            ; mask off left nybble            |B0
        iorwf   mask,W          ; copy RS bit into WREG bit 7     |B0
PutSer
        btfss   PIR1,TXIF       ; UART transmit buffer empty?     |B0
        goto    PutSer          ; no, branch and wait, else       |B0
        movwf   TXREG           ; send it                         |B0
        return                  ;                                 |B0

;******************************************************************
We also need to use Host macros and code which are aware of the LCD 'command' and 'data' registers;
Code:
         radix   dec
;******************************************************************
;
;  Host program example macro usage
;
Line1   equ     128             ;
Line2   equ     128+64          ;
Line3   equ     128+20          ;
Line4   equ     128+64+20       ;
;
        PutLCD  cmd,0x20        ; setup 4 bit interface
        PutLCD  cmd,0x0C        ; display on, cursor off
        PutLCD  cmd,Line1+10    ; lcd line 1, htab 10
        PutLCD  str,"GMT"       ;
        PutLCD  cmd,Line2+10    ; lcd line 2, htab 10
        PutLCD  dat,'?'         ;
        PutLCD  cmd,0x10        ; cursor shift left
        PutLCD  cmd,0x0F        ; cursor on (blink)

;******************************************************************
Code:
;--< macro definitions >-------------------------------------------

cmd     equ     1               ; single byte command/control type
dat     equ     2               ; single byte character/data type
str     equ     3               ; multi-byte string character type

PutLCD  macro   ptype,pdata
    if ptype == cmd             ; generates 2 words
        movlw   pdata           ;
        call    PutCmd          ; send with RS=0
    endif
    if ptype == dat             ; generates 2 words
        movlw   pdata           ;
        call    PutDat          ; send with RS=1
    endif
    if ptype == str             ; generates 6 words + inline table
        local   string,done
        movlw   low(string)     ;
        movwf   PtrL            ;
        movlw   high(string)    ;
        movwf   PtrH            ;
        call    PutStr          ;
        goto    done            ;
string  dt      pdata,0         ; inline table, 0 terminated
done
    endif
        endm
I defined the 'CX' control bit as bit 6 in the serial nybble+rs bytes. This allows me to use the D4..D7 lines to drive a column driven switch matrix in-between LCD write operations. The host would send one of the following bytes to setup the column lines before reading its switch input pin(s) which you see on the left side of the matrix.

send '0100 1110' to set column 0 active low
send '0100 1101' to set column 1 active low
send '0100 1011' to set column 2 active low
send '0100 0111' to set column 3 active low

You would need one Host switch input pin for every four switches or jumpers installed on the LCD interface board.

I use interrupt-on-change to detect the start bit leading edge and trigger the (untested) ISR on the LCD interface PIC;
Code:
;******************************************************************
;*  Interrupt Vector                                              *
;******************************************************************

        org     0x0004

b0      uDelay (bTime/3)        ; delay 1/3 bit time              |B0
        uDelay (bTime-3)        ; delay bit time - 3 cycles       |B0
        bcf     D4              ; clr LCD 'D4' pin (GP0)          |B0
        btfsc   SerPin          ; bit '0'?  yes, skip, else       |B0
        bsf     D4              ; set LCD 'D4' pin                |B0
b1      uDelay (bTime-3)        ;                                 |B0
        bcf     D5              ; clr LCD 'D5' pin (GP1)          |B0
        btfsc   SerPin          ; bit '0'?  yes, skip, else       |B0
        bsf     D5              ; set LCD 'D5' pin                |B0
b2      uDelay (bTime-3)        ;                                 |B0
        bcf     D6              ; clr LCD 'D6' pin (GP2)          |B0
        btfsc   SerPin          ; bit '0'?  yes, skip, else       |B0
        bsf     D6              ; set LCD 'D6' pin                |B0
b3      uDelay (bTime-3)        ;                                 |B0
        bcf     D7              ; clr LCD 'D7' pin (GP4)          |B0
        btfsc   SerPin          ; bit '0'?  yes, skip, else       |B0
        bsf     D7              ; set LCD 'D7' pin                |B0
b4      uDelay (bTime)          ; ignore bit 4                    |B0
b5      uDelay (bTime)          ; ignore bit 5                    |B0
b6      uDelay (bTime-3)        ; test CX bit (lcd or non-lcd)    |B0
        clrf    Emask           ; assume non-lcd latch byte       |B0
        btfss   SerPin          ; bit '1'?  yes, skip, else       |B0
        bsf     Emask,5         ; setup 'E' pulse bit             |B0
b7      uDelay (bTime-3)        ; pulse 'E' during 'RS' data bit  |B0
        movf    Emask,W         ; get mask 00000000 or 00100000   |B0
        iorwf   GPIO,F          ; pulse 'E' (or not)              |B0
        xorwf   GPIO,F          ; force 'E' pin low               |B0
st      uDelay (bTime-3)        ; within middle 1/3 of stop bit   |B0
        movf    GPIO,W          ; read GPIO port                  |B0
        bcf     INTCON,RAIF     ; clr IOC interrupt flag bit      |B0
        retfie                  ;                                 |B0
Take care. Mike
Mike, K8LH is offline  
Old 7th November 2007, 02:48 AM   (permalink)
Default

I must be missing something with this circuit. How do you shift a 1 bit into the 174 without writing random data to the display?



Mike.
Edit, got it, you have to shift in all zeroes between nibbles.

Last edited by Pommie; 7th November 2007 at 02:50 AM.
Pommie is offline  
Old 7th November 2007, 03:49 AM   (permalink)
Default

The code is on Mykes site. I personally don't like glue chips anyway.
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now  
Old 8th November 2007, 04:26 PM   (permalink)
Default

Quote:
Originally Posted by Pommie
I must be missing something with this circuit. How do you shift a 1 bit into the 174 without writing random data to the display?



Mike.
Edit, got it, you have to shift in all zeroes between nibbles.
You can toggle and change values on all of the LCD lines and it doesn't really matter until you pulse the 'E' line. That's when the LCD captures the data on its pins.

Mike
Mike, K8LH is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
PIC to LCD wiring problem ? pasanlaksiri Micro Controllers 28 4th October 2007 11:29 AM
PIC16F628A LCD problems. HerbertMunch Micro Controllers 17 2nd October 2007 10:20 AM
Newbie needs help with LCD backlight dimming Mongoose General Electronics Chat 6 22nd September 2007 12:23 AM
Nokia 7110 LCD + questions regarding code and behaviour of LCD. MrNobody Micro Controllers 2 19th September 2007 08:50 AM
LCD Troubles Kyle-s4h Micro Controllers 13 11th September 2007 01:30 PM



All times are GMT. The time now is 09:12 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker