Configuring Defines For 8-bit LCD


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Configuring Defines For 8-bit LCD

    HI,

    I am trying to make my pic16F648a inot a an 8 bit LCD out.
    From what I see in the basic default program ( in the manual) it is at 4 bit default.
    I did switch the define to 8 bit.
    But the ereg should now be on portA, but with one of the 4 ?
    The default at 4 it is set to RB3, why 3 ?
    the rest I believe remain unchage

    ‘ Set LCD Enable port
    DEFINE LCD_EREG PORTB

    thanks

    ken

    So far this is what I have:

    ‘ Set LCD Data port
    DEFINE LCD_DREG PORTB

    ‘ Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 0

    ‘ Set LCD Register Select port
    DEFINE LCD_RSREG PORTB

    ‘ Set LCD Register Select bit
    DEFINE LCD_RSBIT 4

    ‘ Set LCD Enable port
    DEFINE LCD_EREG PORTA

    ‘ Set LCD Enable bit
    DEFINE LCD_EBIT 3

    ‘ Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 8

    LcdOut $FE, 1, "Hello"

  2. #2
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi,
    please try this:

    ' Set LCD Data port
    DEFINE LCD_DREG PORTB
    ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_DBIT 4
    ' Set LCD Register Select port
    DEFINE LCD_RSREG PORTB
    ' Set LCD Register Select bit
    DEFINE LCD_RSBIT 1
    ' Set LCD Enable port
    DEFINE LCD_EREG PORTB
    ' Set LCD Enable bit
    DEFINE LCD_EBIT 0
    ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_BITS 4
    ' Set number of lines on LCD
    DEFINE LCD_LINES 2
    pause 100
    lcdout $fe,1,"Hello"
    end


    LCD Connection
    Pin1=Vss: connect to ground
    Pin2=Vdd: connect to Vcc=5V
    Pin3=Vo: connect to middle pin of the POT(20K) to control brightness
    Pin4=RS(register select): connect to micro pins that specify in the software(RB1)
    Pin5=RW(Read/Write): connect to ground because we want to only write
    Pin6=E(Enable): connect to micro pin that specify in the software(RB0)
    Pin7 to 10: No connection
    Pin 11 to 14: connect to RB4 to RB7
    Pin15: connect to Vcc with a resistor(100 or 200 ohm resistor is good)
    Pin16: connect to ground.
    pin 16 and pin 16 are for backligh

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    this code do not work. I forgot to say that I want an 8 bit transfer. Eventually i will want to display the output on my A/D conversion

    I tried this code:
    but still do not work

    ' Define LCD pins
    Define LCD_DREG PORTB
    Define LCD_DBIT 8
    Define LCD_RSREG PORTA
    Define LCD_RSBIT 0
    Define LCD_EREG PORTA
    Define LCD_EBIT 3
    Define LCD_BITS 8

    LcdOut $FE, 1, "Hello"

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Ok but if there is no connection for Pin7 to 10: it is then a 4 bit output no ?
    I wanted to use all the output wires including Pin7 to 10.

    ken

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    so far so good, I do get someting on the lcd. I had wire connection problems
    I found a chip that I have that did A/D conversion. Now I have another problem, my output value is always the same (around 500). It should read the input portC.0 from analog and display its decimal value to the lcd. The analog input is between 2 to 5 volt. I am using a Pic16F876a.

    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 0
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    Define ADC_BITS 10
    Define ADC_CLOCK 3
    Define ADC_SAMPLEUS 50

    adval var word

    TRISC = %11111111
    ADCON1 = %10000010
    Low PORTB.2
    Pause 500

    loop: ADCIN 4, adval
    Lcdout $fe, 1 Lcdout "Value: ", DEC adval
    Pause 100
    Goto loop
    End

    end

  6. #6
    Join Date
    Aug 2006
    Location
    Iran
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hi,
    why don't you use the internal A/D of your microcontroller?

  7. #7
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur
    this code do not work. I forgot to say that I want an 8 bit transfer. Eventually i will want to display the output on my A/D conversion

    I tried this code:
    but still do not work

    ' Define LCD pins
    Define LCD_DREG PORTB
    Define LCD_DBIT 8
    Define LCD_RSREG PORTA
    Define LCD_RSBIT 0
    Define LCD_EREG PORTA
    Define LCD_EBIT 3
    Define LCD_BITS 8

    LcdOut $FE, 1, "Hello"
    Hi Lerameur,
    Define LCD_DBIT 8
    I am no expert, but shouldn't this be Define LCD_DBIT 0 ?
    JS

  8. #8
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I thought I was calling the A/D of my controller by using ADCON and ADCIN...

    ken

  9. #9
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    mainly I just want to use this program but convert it
    in picbasic pro and have a LCD out of the input.

    ‘***Real A to D on the 876****
    program RealAtoDSafe
    Dim data1 as word
    Main:
    TrisB = %00000000
    TrisA = %00001000
    ADCON1 = %10000100
    while TRUE
    data1=Adc_Read(3)
    If data1 < 4 Then
    data1 = 4
    End If
    PortB = word(data1 >> 2)
    wend
    End.
    ‘***************************

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. first project, and yes, doesn`t work
    By bogdan in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 28th April 2009, 06:13
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. encoder wowes
    By wallaby in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 6th December 2005, 21:56
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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