4 Bit Lcd Hookup


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    GEEZER's Avatar
    GEEZER Guest

    Default 4 Bit Lcd Hookup

    I have been running an lcd on portc of a 16F877A, (4 bit mode). I need the SPI functions of portc for a DAC. Where can I put the lcd? Porta is needed for other uses. Does lcd need a clock input to the Ebit?

    I know I am starting too high and going too fast for a first pic project because my wife left, and the dog bit me.

    Here's the code I am using to run the lcd now. Data bits are on portc.4,5,6,7.

    DEFINE LCD_DREG PORTC
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTC 'defines
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 3000 'defines
    DEFINE LCD_DATAUS 1000

    The Geezer

  2. #2
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default sup dude

    yo dude im not sure if this is what u mean but you want to be able to control the lcd by hooking the data pins from the LCD to random (unused) I/O Ports on the PIC?

    i have a hardware design problem that is causing me to create much more code than i would like, it is that the lcd data pin are not on the same port next to eachother. If I were you i would make sure that you wire your lcd like this

    ' portB could be anyport as with portC its just to show the relationship

    D7 - portB.3
    D6 - portB.2
    D5 - portB.1
    D4 - portB.0

    E - portC.0
    RS - portC.1


    it is important that the D lines are connected sequentially like this then you wont need to do much BIT math and be able to use the LCDOUT cmmand.

    finally, if a sequential connection really 100% for sure is not an option then check out the Pic BAsic Compiler forums (not pic basic pro). and look for a title called "lcd on porta and portb" ill be in there. there is alot of data on how to control the lcds using simple commands. itll work but take a lot more code.

    im sure that if your proto'ing the circuit youll find room to put these bad boys next to eachother. yes E is the clock, the lcd need 2 clock cycles when in 4 bit mode to get a complete byte. bite her back!.. the dog that is.
    Last edited by EDWARD; - 7th May 2005 at 07:00.

  3. #3
    GEEZER's Avatar
    GEEZER Guest


    Did you find this post helpful? Yes | No

    Default 4 bit LCD hookup

    Thanks Edward, sequential pins is not a problem. Portb is wide open. I was not sure about clocking. If I use portc.0 for the clocking output, can I also use that pin to clock a peripheral in serial mode.

    The Geezer

  4. #4
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default

    http://www.geocities.com/SiliconVall.../lcd/intro.htm

    if portb is wide open than just use 6 pins from that port to control the lcd.
    PIC | LCD
    -----------------------------
    portb.0 to D4
    portb.1 to D5
    portb.2 to D6
    portb.3 to D7

    portb.4 to RS ' 0 mean you are sending intructions, 1 means ur sending asci
    portb.5 to E 'tells the lcd you want it to read the 4 data pins (high-low trans)

    'the above is not code

    if you can do that then ignore the below.

    you should be able too but keep in mind that both the LCD and your other serial device will have to be syncronized. so if you pulse portc.0, to control the serial device, the lcd will interprete that as you sending it a command and will "read" what is on its data lines as data. ( so you could send a %0000, unitentially, to the lcd.

    I WOULDNT RECOMMEND IT unless your sure it will work cause the clock timing is very important in serial control, and usally run at high speeds. the lcds "clock" isnt really a clock. it is more of an "read what is on the port" signal. and the lcd is only updated as you tell it.

    a workaround coul be this:
    1. do your serial stuff using the portc.0 as clock.
    2. the lcd might display weird stuff while this is happening.
    3.after serial stuff done, clear the lcd with commands
    4. do the lcd stuff.(but this could mess up ur serial device communication)

    another could be this if you only need to use ur serial device early in the program, then dont initialize your lcd till its done.
    1.do serial stuff
    2. once serial stuff is done, init the lcd
    3. do lcd stuff(as i said above it could mess with the serial device still)

    what is your serial device? eeprom?

    if a hardware change is still posible then do some research on a digtal latch, i think thats what it is. bassically its a device that allow you to "disconnect" 8 isolated leads with just 1 pin. basically i could "hand over" a port for another device by isolating the primary device with a digital latch. it may at first seem like youll need more ports but actually is less becuase you can get 16 outputs from 10 pins on the pic (8 for the data + 1 to make the latch A open or close + 1 for latch B) ill try and get a data sheet on the device im thinking of. ok its not called a latch, i know ive used one but cant remeber. maybe somone else will know.



    i drew a picture of the "latching" device. i only drew 4 pins per latch for simplicity. also get creative maybe run the control bit for latch 2 thru an inverter making the schematic only requireing 9 bits
    Attached Images Attached Images  
    Last edited by EDWARD; - 8th May 2005 at 10:11.

  5. #5
    GEEZER's Avatar
    GEEZER Guest


    Did you find this post helpful? Yes | No

    Default 4 Bit Lcd Hookup

    Thanks Edward,

    The serial port need is to output to a digital to analog converter (pot). Both it and the lcd will be changing constantly. All I really need is another clocking pin for the lcd, and I can put the lcd on portb. There is no clocking pin on portb of the 16F877A. One more clocking pin will solve all my problems.

    The Geezer

  6. #6
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default

    the lcd's E bit is not an actual clock remember. there is no signal at all going to the lcd when its not be "updated", like it doesnt need a constant clock signal to keep the same stuff on the screen.

    you just need 6 standard I/O ports to run the lcd.

    i might not fully understand the operation of your device, but if the lcd can be updated after the the serial device id just use the setup below. and have the lcd sub run every time the serial sub is done.

    PIC | LCD
    -----------------------------
    portb.0 to D4
    portb.1 to D5
    portb.2 to D6
    portb.3 to D7

    portb.4 to RS ' 0 mean you are sending intructions, 1 means ur sending asci
    portb.5 to E 'tells the lcd you want it to read the 4 data pins (high-low trans)

    im didnt look at the datasheet of your pic, so i hope this works for ya bud.

    'holla

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by GEEZER
    I have been running an lcd on portc of a 16F877A, (4 bit mode). I need the SPI functions of portc for a DAC. Where can I put the lcd? Porta is needed for other uses. Does lcd need a clock input to the Ebit?
    why not using Shiftin/Shiftout who give you the choice to choose those pin you want?

    The Edward suggestion is also good if you don't need any pins for PWM or interrupts.

    LCDOUT and SHIFTIN/SHIFTOUT don't use any internal ressource, software based only.
    Last edited by mister_e; - 9th May 2005 at 04:45.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    GEEZER's Avatar
    GEEZER Guest


    Did you find this post helpful? Yes | No

    Default 4 Bit Lcd Hookup

    Thanks Edward, the LCD must operate whether the serial DAC is operating or not. My LCD and my serial operated DAC must be totally autonomous.

    I saw a post recently where a guy was running three serial ports out of one chip, so I am sure there is some way to run the LCD and still have one serial output.

    Steve, correct me if I'm wrong. The shift out command looks to be a one bite at a time affair with a lot of code.

    I could get a parallel operated DAC, but wouldn't I still need a clocking pin?

    Your suggestions are greatly appreciated.

    The Geezer

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    wich DAC you want to use? If i can suggest one simple MAX517 wich work with the I2C bus. Yeah ok, only 8 bit of definition but, how much precision do you need?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    GEEZER's Avatar
    GEEZER Guest


    Did you find this post helpful? Yes | No

    Default 4 Bit Ldc Hookup

    The DAC is an adXXXXX, can't rember the exact number. It's a quad with 255 steps per channel. 8 data bits and 2 bits to select channel. It requires an SPI output, an sdo, a clock pin and a ground, I believe. These are available on portC.

    I think I can work that all out, but I need to move the LCD from portc, where it is working fine, to leave those aformentioned portc pins for the DAC.

    I am not asking someone to write my code, I am willing to do the work. To make my question more clear:

    I understand that pins 7,6,5, & 4, on portb will transfer the data or commands in two 4 bit parts. I understand that the RS signal will tell the LCD chip whether the transfered data is a command such as clear-screen, or data to be displayed such as "Hello".

    I am ASSUMING that the E_BIT is a timing pin which drives the whole shbang much like an oscillatior.

    I am ASSUMING that the LCDOUT command is not just a word, but a binary routine, ( when compiled) that controls these involved pins, and in a timed sequence send commands followed by data to control the Hitachi chip and make it do what my basic program code tells it.

    I can use a clko pin from portc and make all this work. But I need another pin for this function, because I need the portc hardware to run my SPI DAC.

    Does this make sense? I am confident there is some quite simple way to do it. My novice status (read ignorance), is my drawback. If you can help me with an understanding of theory, I know I can work it out.

    You will notice In the above paragraphs I use the word "understand", (read "think I understand"), and "ASSUMING" which best describes the user of the word with the first 3 letters of the word.

    Any assistance is greatly appreciated.

    The Geezer

  11. #11
    GEEZER's Avatar
    GEEZER Guest


    Did you find this post helpful? Yes | No

    Default 4 Bit Lcd Hookup

    Thanks everyone. I am running on portb now, with EBIT and RS on portc. Have pins left on C for my serial hookup DAC.

    Thanks much,

    The Geezer

    P.S. And as Arnold says, "I'll be back".

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. having problems with Hantronix 20x4 lcd
    By Rhatidbwoy in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 22nd December 2005, 12:22
  5. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts