LCD Data on portA and portB


Closed Thread
Results 1 to 32 of 32
  1. #1
    EDWARD's Avatar
    EDWARD Guest

    Default LCD Data on portA and portB

    I am ICSP programming a board with a 16f73 and 14 pin lcd among other devices. For some weird reason the developer of the board,whom i do not know, has put D7, D6, D5, D4 of the LCD to PINS PORTA.0, PORTA.1, PORTA.2, PORTB.3 on the 16f73 repectivley. yes i said PORTB.3 not PORTA.3. Its seems that the pins for the LCD are connected in reverse and not all on the same port.
    the last bit of information you should know is that there is a 256 eeprom chip connected serially to PORTB.1 AND PORTB.2.

    thus far LCDOUT has been unsucessful
    i have read tons of forums before posting



    CAN ANY OF you invision a work around?

    things to consider.

    i would like to use the LCDOUT command

    will using the eeprom to drive the LCD be an option? i.e load bytes from eeprom to the ports registers

    can i somehow make portB.3 do exactly what portA.3 does?

    '----------------------------------------the hardware\defs i have
    E is portC.1
    rs is portC.0
    R/W is grounded (write mode)
    Data0 to Data3 is not used
    I am in HS mode
    14 pin 2x8 lcd

    define LCD_DREG PORTA
    define LCD_DBIT 0
    define LCD_RSREG PORTC
    define LCD_RSBIT 0
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 1
    define LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50

    'holla

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


    Did you find this post helpful? Yes | No

    Default

    EDWARD,

    I would modify the hardware to make it compatible with LCDOUT.

    You could cut the copper traces on the and re-wire them
    or build some adapter cable between the board and the LCD.

    Coud you post a schematic and Layout of your board?
    regards

    Ralph

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



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


    Did you find this post helpful? Yes | No

    Default

    You can also manually control the LCD.. .with out using LCDout.

    http://www.geocities.com/SiliconVall...d/commands.htm

    YOu would send a
    hex 13 to turn on the LCD,
    Hex 01 to clear
    and everything else will be close to the same as a LCDout.

    You would send it in 4 bit mode, thus I can't remember if you send the MSB or LSB first...This may seem like a lot of work, but in reality, it is fairly simple.

    You can assign the whole PortB.0- PortB.3, then assign A.3 to Port b.3 and trigger your clock.

    Psuedo code:

    Turn your LCD into 4 bit mode:
    send Hex 13 to turn it on.

    // one way to do it:
    routine:
    Portb.0 - POrtb.3=MSB
    Porta.3=Portb.3
    toggle clock

    // another way to do it.
    Portb.0 - Portb.2=LSB
    Porta.3=Bit...(whatever it is)
    toggle clock
    Return


    Yeah, you are sending in 4 bit mode, but it will work. But you are not using LCDout. You will also have to put your own pauses in, so that the data will not be sent too fast. (similiar to Character spacing command in LCDout)
    Last edited by Dwayne; - 4th May 2005 at 17:06.
    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...

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dwayne
    You can also manually control the LCD.. .with out using LCDout.
    Of course you could,
    even without using a PIC
    by simply having some DIP-Switches on the Data Lines and a PushButton on the Clock Line.

    (Dwayne, you remember my very first PROMmer)

    If you would like to use the Power of PBP's LCDOUT
    (like all the Modifiers etc.)
    you would have to write your own LCD Routines

    I feel cutting some traces on the PCB and soldering some wires or building an adapter cable will be less time consuming.

    BTW
    the "Dwayne Method" will only work if there is nothing connected to PortB.3
    (Means you are wasting one PortBit)
    regards

    Ralph

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



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


    Did you find this post helpful? Yes | No

    Default

    Hello Ralph,


    Ralph>>Of course you could, even without using a PIC
    by simply having some DIP-Switches on the Data Lines and a PushButton on the Clock Line. (Dwayne, you remember my very first PROMmer)<<

    <chuckle> Yes I do...


    Ralph >>If you would like to use the Power of PBP's LCDOUT
    (like all the Modifiers etc.)
    you would have to write your own LCD Routines <<

    that is correct... And this is what I did... Granted the wheel has already been invented, but sometimes that wheel has to be made oblong to make something work a little bit better for other situations.

    Ralph >>I feel cutting some traces on the PCB and soldering some wires or building an adapter cable will be less time consuming.<<

    Yes...I agree...But I don't know what limitations our gent has... Would that be allowable for him???

    Ralph >>BTW
    the "Dwayne Method" will only work if there is nothing connected to PortB.3
    (Means you are wasting one PortBit)<<

    I showed two ways... One using a MSB / LSB the other is more of a Bit shift for the first 3 bits, and the 4th bit assigned to Porta. Lengthy...Yes...but sometimes skinning the cat can't be done the way we want it done...

    Thus I offered another solution, if the cat is not allowed to be skinned that way...Whether it helps or not...oh well... it is a option.
    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...

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


    Did you find this post helpful? Yes | No

    Default

    ...Granted the wheel has already been invented, but sometimes that wheel has to be made oblong to make something work a little bit better for other situations.
    OK, if you want to prevent the wheel from turning, you could make it rectangular, but then I wouldn't call it a wheel any longer. (The proven best shape for a wheel is round)

    ...But I don't know what limitations our gent has... Would that be allowable for him???
    This is exactly why we should stop guessing and wait for EDWARD to come back with some more detailed information
    regards

    Ralph

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



  7. #7
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default lcd data on port a and portb

    yo thanks for the help guys. modifing the hardware is not an option because i am planning on upgrading a whole bunch of these boards with new code (1000+ boards)

    dwayne- i think your on the right track as to what i need. i think that i should be able either:

    2. to use four 1 byte variables (one byte for each data line on lcd) and output serially each byte at the same time

    or

    1. pick what bit holder in a byte to output on a specifed port.



    i drew a picture of what my idea is. the main question is how the data should be strucuted. the data a drew is not exact its just to give you an idea of the structure.

    remember that there is a 256byte eeprom on the board as well. this is only additional memory correct? my pic has built in memory. my best guess is that the eeprom was added to the design to hold the LCD data.
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    My suggestion, use LCD.BAS from Melabs. It's made to work with PBC and you can modify it for your special need
    download it here
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    well, i should read carefully the first post... i'll agree with the Ralph's suggestion. But for a thousand board... could be interesting to make a DIP adapter that change the OLD PIC pin to the new PIC pin configuration.

    Well just an idea.
    Last edited by mister_e; - 5th May 2005 at 05:25.
    Steve

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

  10. #10
    uuq1's Avatar
    uuq1 Guest


    Did you find this post helpful? Yes | No

    Lightbulb

    Below is the code I had developed to write data to LCD without using the LCDout command.
    thought may be of help:

    '************************************************* ***************
    '* Name : LCD 8Bit.BAS *
    '* Author : uuq1 *
    '* Notice : Copyright (c) 2005 [set under view...options] *
    '* : All Rights Reserved *
    '* Date : 4/25/2005 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************
    'VARIABLES DECLARATION
    CHARCNT VAR BYTE
    CHAR1 VAR BYTE
    TOTAL CON 20 ' A CONSTANT FOR NO OF CHARS ON ONE LINE OF LCD

    'Pin Assignments
    LCD_RS VAR PORTA.0
    LCD_EN VAR PORTA.1

    Start:
    Pause 150
    TRISA=2
    TRISB=0
    PORTA=0
    PORTB=0

    PORTB=%00110000 ' FUNCTION 8 BITS, LCD INITILIZATION REQUIRE THIS COMMAND TO BE SENT 3 TIMES.
    GOSUB LCDINS
    PORTB=%00110000 ' FUNCTION 8 BITS
    GOSUB LCDINS
    PORTB=%00110000 ' FUNCTION 8 BITS
    GOSUB LCDINS
    PORTB=%00111000 ' fUNCTION 8 BITS, 2 LINES, FONT #1
    GOSUB LCDINS
    PORTB=%00001100 ' DISPLAY ON, CURSOR OFF, BLINK OFF
    GOSUB LCDINS
    PORTB=%00000001 ' CLEAR THE DISPLAY
    GOSUB LCDINS
    PORTB=%00000110 ' CLEAR THE DISPLAY
    GOSUB LCDINS
    CHARCNT=0

    PRINC:
    IF CHARCNT <= TOTAL THEN
    CHAR1="A"
    ELSE
    CHAR1="B"
    ENDIF

    IF CHARCNT=TOTAL+1 THEN
    PORTB=$C0 'GOTO 2ND LINE FIRST POSITION
    GOSUB LCDINS
    ENDIF

    IF CHARCNT >= (TOTAL * 2)+1 THEN
    PORTB=1 'CLEAR THE DISPLAY
    GOSUB LCDINS
    PORTB=$80 'GOTO 1ST LINE FIRST POSITION
    GOSUB LCDINS
    CHARCNT=0
    ENDIF

    'PRINT THE CHAR ON LCD
    PORTB=CHAR1
    GOSUB LCDDATA
    PAUSE 100

    'INCREMENT THE CHARCNT
    CHARCNT=CHARCNT + 1
    GOTO PRINC

    LCDDATA:
    PAUSEUS 25
    HIGH LCD_RS
    PAUSEUS 25
    HIGH LCD_EN
    PAUSEUS 25
    LOW LCD_EN
    RETURN

    LCDINS:
    PAUSEUS 25
    LOW LCD_RS
    PAUSEUS 25
    HIGH LCD_EN
    PAUSEUS 25
    LOW LCD_EN
    RETURN

  11. #11
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default lcd data on 2 ports

    thanks for all the help so far.

    >>"Of course you could, even without using a PIC by simply having some DIP-Switches on the Data Lines and a PushButton on the Clock Line."

    would it work for only 4 dips for data(d7,d6,d5,d4) plus 1 "clock" button?
    is the clock the E or R/S?

    how many times would the "clock" have to cycle to get a
    command? because only 4 DIPS would mean only 16 combinations.

    or

    does it(lcd) recive a byte of data through a means of 4 bits on 1 clock and the next 4 bits on the second clock?

    if the second is true then i think i can manage a work around.


    yes i agree that the lcdout command would be the best method. unfortunatly im not sure if the original code for this board was written in c or assembly er somthing which may not even matter how it is interfaced.

    '-------


    i know i could design a board to make this eaiser to code, but the whole idea behind this project is to utilize what has already been manufactured and improve on its functionality. in short... No Hardware Mods i really do appreciate all the help i have recived. and i am doing a lot of research before posting.

  12. #12
    G8RPI's Avatar
    G8RPI Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Edward,
    I don't know what type of data you are sending to the LCD, but you need to consider the amount of memory you have available and the time to send it to the display. Your LCD routine will have you convert your byte data into two 4 bit nibbles, and then set the 4 individual output pins to correspond to the correct bits in sequence. This will take time and code space.
    The customer will not pay you more for all this effort. I'd tell him that he should upgrade to a "better" processor, then put a SOIC package 16F876 (or even '877) on an adaptor board (like a Stamp or the Pic 10F "hobby kit") with the pin swap incorporated. You can impress the customer with the "latest surface mount technology" and save yourself a lot of trouble. At 1000 off quantities the board cost should not be bad. You could even include ICSP for field upgrades.

    Robert G8RPI.

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


    Did you find this post helpful? Yes | No

    Default

    Hello Edward,

    Edward>>2. to use four 1 byte variables (one byte for each data line on lcd) and output serially each byte at the same time

    or

    1. pick what bit holder in a byte to output on a specifed port.
    <<

    You can load up those 4 bits... and they will not affact your LCD, until you trigger the clock on the chip... Which refers to your #2. Since you already have 4 lines going to your LCD anyhow...this could be a nice software option. Personally I like Ralphs idea of cut a and paste a wire... (nice and slick).

    #1 in conjunction with number 2 would work slick as snot. My only question would be, when assigning the output to the port, will it affect the ports that are not supposed to be LCD controllers? Only you know that.

    For example... PortB.3 is not used as a LCD data pin... what is it used for? would changing its value by using a quick byte assignment affect your outcome? or is it better to Assign Bits 0-2, separately with a shift, and assign port A.3 separately to ensure proper operation of the circuit.

    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...

  14. #14
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default lcd on both ports

    thanks for the update guys. wow this is a great forum!

    g8rpi- yes a simple HW change would do but thats not and option also, in case you forgot there is a 256 byte eeprom on board along side of the pic16f73, which my best gues was that they store the lcd data in that and call it serially.

    dwayne - i am interested in how many clock cycles does it take to send a single command to the lcd. i have saved the hd44780 commands page that someone gave me.

    could i do this for example:

    'on the lcd
    1. make pin D7,D6,D5,D4 be a number %0000 to %1111 (0 to 15)
    2. send a clock signal from the pic
    3. make pin D7,D6,D5,D4 be a number %0000 to %1111 (0 to 15)
    4. send another clock signal from the pic
    5. and the screen whould diplay something?

    i know that R/W is grounded to make it only in write mode.

    im not sure on the E and r/s bit.
    R/S lets the LCD know if its ascii data or a command it is receiving, right?
    1.should E (enable) be high all the time, since i want my lcd on all the time?
    2.WHERE DO I SEND THE CLOCK PULSE TOO?? (Enable ?)
    3. Is the data ascii? if so do i send the upper half or lower half of the byte first?

    when you made your switch controlled lcd did you have to initialize it?
    Last edited by EDWARD; - 6th May 2005 at 06:07.

  15. #15
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default answer your own questions

    well it sure is embarssing when you answer your own questions.

    1. E is the "Clock" line
    2. R/S tell the LCD whether the incomming data is intruction data or diplay data.
    3. all display data is in ascii format.

    A. initalization sequence before using the lcd.

    B. i send the upper half (4 bits), make E go from high to low to high, send the lower half (4 bits), make the E go from high to low to high.



    If any of these statements are wrong then please correct me. this is what i have gathered and not 100% on it all.

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


    Did you find this post helpful? Yes | No

    Default

    Hello Edward,

    Edward>>If any of these statements are wrong then please correct me. this is what i have gathered and not 100% on it all.<<

    I do it to myself all the time.... <g> Looking good.

    Hey BRIAN!!!!! I have been working with you on the LCD via Email, can you send me that LCD routine? So that I have it at work?? I think Edward could use it.

    Edward... I am at work, and I logon to this forum at work. I do not have equipment to test or anything like that, so I have to go my memory. Brian is working on a LCD routine that is "Manual" almost exactly like what we are talking about... I uploaded him a copy of my routine... It is very simple, and acts almost exactly like the LCDout. I hope he will post it here if he sees it.

    It is something like this:

    Loop:
    Serin porta.0 Data

    if Data<>254 then
    (assign the pins of your LCD)
    (Toggle the Clock)
    LCDcommand=0
    endif

    if Data==254 then
    LCDcommand=1 'Hey! lets input a command like clear screen!
    endif
    goto loop

    If you look at this, if a $FE is sent, your program will turn on the command part of your LCD, and the following character will be your command...like
    $FE $01 Clear the screen...just like the LCDout.
    after the clear screen, the LCDcommand toggle is automatically turned back to DATA input, not command input.

    The difference is, a 4 bit machine will have to have 2 sets of 4 bits sent... not one large 8 bit of data.

    Now about the speed.. the speed *can*actually be MUCH faster than LCDout... you can control the speed to your LCD...You do this by the pause command. You can adjust a pause, to where it will printout on the LCD correctly. And if you make the pause to short, the data will not completely be displayed on the LCD. What I did on my project, was start with a long pause, and slowly made the pause shorter and shorter, until my display data was incorrect. the data zips across the LCD now <g>. No flashing, waiting, or scrolling... It appears out of nowhere <g>. You may want to set your pause to a safer level, especially since you have 1000+ LCD's that make work better at different speeds.

    Dwayne
    Last edited by Dwayne; - 6th May 2005 at 16:26.
    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...

  17. #17
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default thanks dwayne

    i think i got the data sturcture of the lcd all figured out and i have made my own routins to control the lcd. 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.

    dwayne i havent used external memory before but i think it shouldnt be too hard. i know that i will most likely have to and i actually want to, i think
    yes please let me check that code out that ur buds working on sometime, sounds like ti could be very useful.




    just to update i have a tempory solotuon to my problem and i suggest this method if your hardware isnt designed well. meaning the d4-d7 data lines on the lcd are connected to random port pins.

    as im sure it says above somewhere, i am using 4 bit mode to control my hd44780 compatible LCD. it is a 2 line 8 character diplay with each characters resolutin at 5x8. my data pins are as follows:

    D7 = PORTA.0
    D6 = PORTA.1
    D5 = PORTA.2
    D4 = PORTB.3 (YES PORTB)
    RS = PORTC.0
    E = PORTC.1

    I should note just for clarity that the hd44780 lcd works on a byte by byte basis. meaning that you send it one byte at a time parallely(is that a word), in parallel. But if you are in 4 bit mode, which is recommended becuase you can free up 4 I/O lines, you need to send the same byte size command in 2 steps. firts send the upper half of the byte, clock the lcd, then send the second half, clock the lcd. then it will have recived 1 full command.

    in 8 bit mode i can send %01000001 to pins D0-D7 repectivly. clock E and that is 1 byte so the lcd will update.

    in 4 bit mode i would:
    send %0100 to pins D4-D7 respectivly (upper half)
    clock E
    send %0001 to pins D4-D7 respectivly (lower half)
    clock E
    and it should update.

    so basically just till i get creative with some formulas, im going to stick with the "brute force" method. which is as follow:

    'i want to send an A to the lcd

    lcd7 VAR PORTA.0 'DEClirations MAKES addressing the pins easier.
    lcd6 VAR PORTA.1
    lcd5 VAR PORTA.2 'the variabls should be self expl.
    lcd4 VAR PORTB.3
    lcdrs VAR PORTC.0
    lcde VAR PORTC.1
    '-------------------------------

    GOSUB lcdinit

    lcdrs = 1 'data mode
    pause 10

    lcd4=0
    lcd5=1
    lcd6=0 'upper half %0100
    lcd7=0
    GOSUB lcdtog

    lcd4=0
    lcd5=0 'lower half %0001
    lcd6=0
    lcd7=1
    GOSUB lcdtog

    END

    lcdtog:
    pause 5 ' added pauses to make sure i get the rise i need, i know its too slow
    lcde = 1
    pause 5 'set lcd enable line high
    lcde = 0 'set lcd enable line low
    pause 5
    Return




    lcdinit:
    'the lcd needs to be initialized once, usually early in your program. there a lots of different hardware set ups so youll need to figure thisout. goto:
    http://www.geocities.com/SiliconVall.../lcd/intro.htm
    read the intro section.
    then the command section.
    then get yourself an ascii table.
    and try to use the lcd simulator ( really cool!)
    Last edited by EDWARD; - 7th May 2005 at 08:31.

  18. #18
    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 ...
    _______________________________________________



  19. #19
    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

  20. #20
    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

  21. #21
    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)

  22. #22
    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 ...
    _______________________________________________



  23. #23
    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...

  24. #24
    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

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


    Did you find this post helpful? Yes | No

    Default

    Hello John,

    John>>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.<<

    Yes the PBP is close to the passing of variables... not quite like C...you don't have function variables that are only addressable via that function. (non-global Variables).

    John >> 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).<<

    Are you attemping to do your own LCD routines? If so, that is fine. I do my own LCD routines...I do not use LCDout, unless I absolutely have to. I don't feel like using 4 or 8 bits of a chip for LCD's, and I built my own backpack for serial communication. I just make my routines similar to LCDout, and plug away...

    Earlier in this thread, I gave a example of making the commands similar to a a LCDout.



    I thought about purchasing a C compiler (I program professionally with C/C++, using Borland compilers.) I thought it would be nice to have a C compiler, and I would understand its "terminology" and aspects of the language much better than PBP. I prefer (just because I am used to it) functions that pass variables, syntex that uses "{" and "}". Stuff like that.


    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...

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


    Did you find this post helpful? Yes | No

    Default

    @Dwayne

    how about this:

    This is a qoute
    Code:
    ' This is no working code!
      Line 1   'not working
      Line 2   'not working
    
    'etc . . .
    regards

    Ralph

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



  27. #27
    hansknec's Avatar
    hansknec Guest


    Did you find this post helpful? Yes | No

    Default

    Dwayne,

    You reminded me of another possibility. I too have built my own LCD backpack in the past... just to see if I could do it. Commands were identical to LCDout except I would serout instead. Doesn't add too much to the cost of an assembly and is certainly cheaper than buying a serial LCD. Still its the thought thats nagging me that we should be able to cross the port boundary with the data pins on LCDout. Guess it needs to go in the wish-list column.
    -John

  28. #28
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default yo

    that webpage is good but it isnt mine.

    -not sure what exactly your problem is but are you just asking how to get a changing variable on the LCD?

    the subs i made probly wont be that good for that but can be done. youd need to make a routine to turn a byte (or word) sized variables decimal value into ascii format. your gonna need to generate 3 ascii character from a byte sized var.

    example: we have b1 a byte siezed variable.if we need b1 on the lcd we know that the variable is 0-255. that means we need 3 characters reserved for this variable XXX. if b1 =1 then show "001" on lcd. if b1=35 then show "035". if b1=244 then shoe "244".

    i may end up doing something like this if it doesnt require a lot of room and ill post it if i do it.

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


    Did you find this post helpful? Yes | No

    Default

    Hello Hancksnec,

    Still its the thought thats nagging me that we should be able to cross the port boundary with the data pins on LCDout. Guess it needs to go in the wish-list column.
    Which will probably mean more overhead and less space for your code. Everything has a drawback... Maybe they could call it LCDoutX ? For those who do not want to have the extra overhead.

    How do you like your C compiler?

    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...

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


    Did you find this post helpful? Yes | No

    Default

    Hello Ralph,

    @Dwayne

    how about this:
    Code:
    LCDout Portb,2400T,"Old habits are TOUGH to break ;-}"
    Thanks bud!

    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...

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dwayne
    Thanks bud!
    You are welcome!
    regards

    Ralph

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



  32. #32
    hansknec's Avatar
    hansknec Guest


    Did you find this post helpful? Yes | No

    Default

    Do I like my C compiler? Well it has its advantages in many situations, but I still love PBP.
    Try doing this in basic:
    Code:
    /////////////////////////////////////////////////////////////////////////
    ////                 Polarization analysis.C                         ////
    ////                                                                 ////
    ////  This program shows input, output and standard operations with  ////
    ////  floating piont numbers.  I/O is RS232.                         ////
    ////  The equation is applied to the numbers entered and the result  ////
    ////  is printed to the screen.               hansknecht 5/12/04     ////
    /////////////////////////////////////////////////////////////////////////
    
    #include <16F877.h>
    #fuses HS,NOWDT,NOPROTECT,NOLVP
    #use delay(clock=20000000)
    #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
    #include <stdlib.h>
    #include <input.c>
    #include <math.h>
    
    void main()
    {
     float a, b, pol_res;
    
     do {
            printf("\r\nEnter first number: ");  //prompt user for number
            a=get_float();                       // bring number in
    
            printf("\r\nEnter second number: ");  // prompt for second number
            b=get_float();
    
            pol_res = (2*(SQRT (a*b))/(a+b))* 100;  // perform calculation
    
            printf("\r\nPolarization = ",pol_res, " %"); // display result
    
        } while (TRUE);
    
    }
    I also like the wizard associated with the CCS C compiler. When you start a new project it asks you questions like "Do you want to use the on-board ADC?" or "Do you want to use the Capture-Compare?". Based on your answer it automatically inserts the necessary code for initialization.

    All this comes at a $$$ price. PBP is a great affordable compiler for 90% of my projects.

    -John

Similar Threads

  1. Matrix Keypad routine
    By mister_e in forum Code Examples
    Replies: 134
    Last Post: - 18th September 2022, 21: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, 20:52
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 15:50
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 21:10
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 6th May 2005, 00:29

Members who have read this thread : 1

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