LCD Data on portA and portB


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by EDWARD
    i...my last problem, i hope, is that i didnt realize my lcd is 5x8 pixel not 5x7. soooo.... i need to figure out how to initialize the lcd to 5x8 character size? my lcd wont auto init so i have a sub that does it. but the link below doesnt say how init for a 5x8 character.
    This shouldn't be much of a problam as 5x8 Matrix is standard.
    See Datasheet example for reference.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  2. #2
    hansknec's Avatar
    hansknec Guest


    Did you find this post helpful? Yes | No

    Default Poking around the ports

    I just resubscribed to this forum after a 10 year hiatus. I have a very similar issue with an LCD that needs to cross ports on the databus. I found that the DEFINE statement was quite nice when I wanted to move away from the stock pins and ports assigned by PBP, but I wondered if I could take it a little further. Looking at the code below:


    '*** LCD defines and initialization **************************
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 3 'LCD enable on PORTB.3
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 2 'LCD RS on PORTB.2
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4 '4 BIT REGISTER ON UPPER 4 BITS OF PORTB
    '************************************************* **

    My initial thought was just to make a fake "aliased" port called PORTQ and then use it in the definition of LCD_DREG. I thought I could make it as follows:

    PORTQ VAR WORD
    PORTQ.0 VAR PORTB.1
    PORTQ.1 VAR PORTA.3
    ..... You get the picture. But I was sorry to find out that this is not possible. (it was sort of dumb to think it would) The second problem with my idea is the fact that even if I make a fake port, it is not recognized by the PBP compiler as a valid port to which LCD_DREG could be assigned.

    Now as Steve Irwin the Crock hunter would say..."I probably shouldn't be doing this...." but I decided to poke around in the actual PBPPIC14.LIB and see how this LCD stuff is done. Now I'm not that good with assembly, but I can see a trend happening in the code. There appears within the code a section called "Fake Port settings" where the PORTA AND PORTB are modified if the compiler is calling a 12C67X or 14C000 part. This leads me to believe that an intelligent person could indeed make a fake PORTQ which could be aliased. Now I'm not about to try to modify the actual PBPPIC14.LIB myself, but I would do it if I knew it would work. (Hey, I paid for it so I can screw it up if I want to!) If a port could not be faked because these are hardware calls, then at the very least the actual LCD write section of the library could be modified to address the specific pins instead of banging the whole port.

    I'm sure that MEL doesn't like us poking around with the file and I don't even know if the compliler would accept a modified file, but this approach seems easier than actually modifying hardware, especially if your talking about quantities of 1000.

    I guess if we are truly looking for the highest efficiency then passing the data to be written to an assembly subroutine would be best, and it would keep people from screaming about modifying the PBP libraries. I'll be on the lookout for such a routine that can be added as an include file.

    -John

  3. #3
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default Solved

    it seems like people might be trying to use this as a reference so im gonna post the custom sub i made to compensate for my pins not being in the right order. you can put any port\pin in place of the ones i have

    for more info see:
    http://www.geocities.com/SiliconVall...d/commands.htm

    ----- lcd type and setup.
    4 bit mode
    left to right
    no cursor no blink
    2 line
    8 character
    ------


    lcde var PORTC.1 '<---- LCD Enable
    lcdrs var PORTC.0'<---- LCD R/S
    lcd7 var PORTA.0 '<---- LCD DATA 7
    lcd6 var PORTA.1 '<---- LCD DATA 6
    lcd5 var PORTA.2 '<---- LCD DATA 5
    lcd4 var PORTB.3 '<---- LCD DATA 4 *notice this is one portB*
    B1 var byte '<---- HOLDS LCD CHARACTER ASCII DATA BYTES


    LCD3: 'lcd subroutine
    lcdrS = 1 'ascii mode
    FOR X = 0 TO 7 ' Count from 0 to 7 (8 character per line on lcd)
    LOOKUP X,["EYE DLY "],B1 ' Get character number B0 from string to variable B1

    lcd7 = B1.7 'puts top half of ascii data on pins 7-4
    lcd6 = B1.6
    lcd5 = B1.5
    lcd4 = B1.4
    gosub lcdtog 'toggle the e line
    lcd7 = B1.3 'puts bottom half of ascii data on pins 7-4
    lcd6 = B1.2
    lcd5 = B1.1
    lcd4 = B1.0
    gosub lcdtog 'toggle the e line

    NEXT X ' Do next character
    Return


    lcdtog:
    pause 1
    High Lcde 'set lcd enable line high
    pause 1
    Low Lcde 'set lcd enable line low
    pause 1
    Return


    lcdinit:
    '-----------------------
    Pause 35 'wait at least 35ms
    lcdrS = 0 'instruction mode

    pause 50
    lcd7 = 0
    lcd6 = 0
    lcd5 = 1
    lcd4 = 0 'initialize the lcd
    gosub lcdtog 'Toggle E line

    '---------------------------
    FOR X = 0 TO 4 ' Count from 0 to 4 (5 commands to be sent)
    LOOKUP X,[$28,$0C,$0C,$06,$01],B1 ' Get character number B0 from string to variable B1

    lcd7 = B1.7
    lcd6 = B1.6
    lcd5 = B1.5
    lcd4 = B1.4
    gosub lcdtog
    lcd7 = B1.3
    lcd6 = B1.2
    lcd5 = B1.1
    lcd4 = B1.0
    gosub lcdtog
    pause 30
    NEXT X ' Do next character
    '----------------------------
    Return

  4. #4
    hansknec's Avatar
    hansknec Guest


    Did you find this post helpful? Yes | No

    Default Hansknec

    Thanks Edward, but there is still something that seems unclear to me. You are calling this a subroutine, but there seems to be no method of passing a variable into it. It looks like it will print "EYE DLY " when called. Could you elaborate a little about passing a string into the subroutine? I've gotten pretty lazy over the years and I'm very much used to setting up some human terminology in my lcd calls like this:
    *************
    Line1 CON 128
    Line2 CON $c0
    clr CON 1
    I CON $FE
    *************

    I then pass the values out in simple human language terms as follows:
    ***************
    lcdout I,clr 'clear the LCD
    lcdout I,Line1, "Ion current"
    lcdout I,Line2,#valu dig 2,".",#valu dig 1,#valu dig 0,"e-0",#scale 'scientific notation display of current reading.

    ***************
    I realize that you are no longer using lcdout, but your own routine instead but I'm still missing something.

    Thanks,
    John.
    (your web site is awesome by the way and I really need to spend more time studying all your info)

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hansknec
    ...I realize that you are no longer using lcdout, but your own routine instead but I'm still missing something.
    John,
    sorry for joining here,
    but if you want the full power of PBPs LCDOUT

    there is quite some work to do.

    I doubt EDWARD is going to do it for you.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  6. #6
    Join Date
    Dec 2003
    Location
    Wichita KS
    Posts
    511


    Did you find this post helpful? Yes | No

    Default

    Hello Hansknec,

    H>Thanks Edward, but there is still something that seems unclear to me. You are calling this a subroutine, but there seems to be no method of passing a variable into it<<

    In PBP, you do not pass variables to subroutines...It is not like C and C++, or Variable passing in 3rd and 4th generation langauges. they are basically all global... Take a look at the LookUp command in the PBP manual:

    http://www.microengineeringlabs.com/...ces/pbpmanual/

    You can simulate much of LCDout command manually, but that means keeping track of Commands and Data Writes. (which is easily done).
    Other than that... using manual LCD control (without LCDout) is not done that often, except by folks who need to so such things, and those who like to re-invent the wheel... ;-}

    Dwayne
    Ability to Fly:
    Hurling yourself towards the ground, and missing.

    Engineers that Contribute to flying:
    Both optimists and pessimists contribute to the society. The optimist invents the aeroplane, the pessimist the parachute

    Pilots that are Flying:
    Those who know their limitations, and respect the green side of the grass...

  7. #7
    hansknec's Avatar
    hansknec Guest


    Did you find this post helpful? Yes | No

    Default Hansknec

    Sorry,

    I keep jumping back and forth between PBP and CCS C, so I confuse my terminology, but the end effect of the LCDout command is very similar to passing a string variable into the unseen code that the compiler grabs from the bowels of the PBP directory at compile time. I felt that the code presented by Edward was pretty close to what the original intent of the thread was trying to solve. I was just hoping that there was something more to be gained (and shared). I don't know how many PBP users are out there using LCD's, but it sort of blows when you find out that the hardware serial port pin happens to be in the middle of your LCD data bus. I know..I know.. poor planning on my part right? I didn't originally think I needed the hardware serial port, but I have become fond of its interrupt capabilities. My problem can be solved by rewriting my code in C, but I'm kind of fond of PBP and have used it for numerous projects over the years.
    -John

Similar Threads

  1. Matrix Keypad routine
    By mister_e in forum Code Examples
    Replies: 134
    Last Post: - 18th September 2022, 20:30
  2. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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