LCD serial backpacks


Closed Thread
Results 1 to 40 of 68

Hybrid View

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

    Default LCD serial backpacks

    Hi Everyone,
    It seems as if, . . . the LCD serial backpack device must be the
    Crown Jewels, of PICdome as I have been unable to wrestle suitable
    code out of the internet. Posted below is a modified version of some code
    I found somewhere, probably for a BS1, anyway I tweaked it some and it works after a fashion, but I think it needs something in the way of a buffer
    and some code to make changes on the fly, like does the cursor blink or not
    etc. . . I think it would be way cool to fashion a workable public domain
    serial unit, so newbies and non-newbies have access without forking up $35 bucks for a serial LCD.

    Anyone up to the challange? As I have been coding PIC micros only since 08/06, My coding skills are not there yet, but thanks to you all I am learning.
    Joe


    Code:
    @ DEVICE pic16F628A, HS_OSC
     
    @ DEVICE pic16F628A, WDT_ON
    ' Watchdog Timer
     
    @ DEVICE pic16F628A, PWRT_ON
    ' Power-On Timer
     
    @ DEVICE pic16F628A, MCLR_ON 
    ' Master Clear Options (Internal)
     
    @ DEVICE pic16F628A, BOD_OFF
    ' Brown-Out Detect
     
    @ DEVICE pic16F628A, LVP_OFF
    ' Low-Voltage Programming
     
    @ DEVICE pic16F628A, CPD_OFF
    ' Data Memory Code Protect
    ' Set to CPD_OFF for Development Copy
    ' Set to CPD_ON for Release Copy
     
    @ DEVICE pic16F628A, PROTECT_OFF
    ' Program Code Protection
    ' Set to PROTECT_OFF for Development Copy
    ' Set to PROTECT_ON for Release Copy
     
    trisb = %00000001
    trisA = %11110011
    include "modedefs.bas"
    ' Define LCD registers and bits
    Define LCD_DREG PORTB
    Define LCD_DBIT 4
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 2
    Define LCD_EREG PORTB
    Define LCD_EBIT 3
     
    DEFINE LCD_LINES 4         'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000    'Define delay time between sending LCD commands
    DEFINE LCD_DATAUS 50     'Define delay time between data sent.
    DEFINE OSC 20
     
    char Var byte ' Storage for serial character
     
     
     
    CMCON = 7 ' PORTA is digital
     
    Pause 100 ' Wait for LCD to startup
    high PortA.2 ' power for backlight
    low PortA.3 ' backlight ground
     
    main:
     
    Lcdout $FE, 1 ' Initialize and clear display
    LCDOUT $FE, $0C
     
    LCDOUT "My Flash Text" 
    pause 800
    Lcdout $FE, 1,$FE, 2
     
    goto loop
     
     
    loop: Serin PORTB.1,N9600,char ' Get a char from serial input
    Lcdout char ' Send char to display
     
    Goto loop ' Do it all over again
     
    End
    Last edited by ScaleRobotics; - 30th May 2010 at 01:24.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Default

    Hi Joe,

    Howzit?

    Could you give some more details?

    I am not sure what you want to have is?


    -------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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

    Exclamation Serial in LCD out

    Sayzer,
    Greetings !
    Here is the Rub:
    every time I or tons of others out there need a serial display, we have to stop what we are doing and order a preprogrammed chip, a kit, or an already assembled serial display at significant cost. A year from now I will likely be able to write enough code to handle this, for now NO. sometimes it is just better to connect the display via a serial connection, for instance, you homebrew a burgular alarm, you keep the alarm chip safely inside, and display can live outdoors. Nowhere have I been able to find code already written and available to home roll a suitable serial display and it really is agrivating to have to stop and order and wait for one when you need it. This seems to be the only PIC related everyday item where near zero code is in the public domain
    The code I posted seems to work with a 2 X 16 display but I doubt it is suitable as is to use as a general purpose serial LCD adapter, I think it needs USART support to provide a data buffer so data doesn't get lost. Additionally
    the LCDOUT routine is great for a finished project, but these push in wire type breadboards are so clumbsy as to make you waste too much time fiddling with connections, whereas a serial lcd is more convienent. I have seen in books authors who use shift registers to do this, curiously enough they were books about PICs * * * * So what I am looking for is a serial backpack device common to all who use this forum that we all get familiar with using so your code or Darrels, or Bruces, ETC does not have to be modified to work on as it seems every serial backpack out there uses different initialization routiens, and you still have to wait for and pay for every time you want one.
    Thanks
    Joe

  4. #4
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352

    Smile

    Hi Joe S.

    I really am trying to figure out how to offer some help to you. I too have had a problem using serial LCD's in the past. I have one from SEETRON, a 2x16 that has served me well in the past few years. I don't understand why it should take a "special" type of serial adaptor for every type of project though. The only difference between setups is the baud rate that I can see. You use either 2400 or 9600. The difference is on the PIC side. If you are going to do any serial data out, you really should use an external crystal or resonator. This is because the PIC's internal clock isn't always accurate for the higher baud rates. This fact has been stated many times in the past on the various forums here. Your PIC only needs the statement: "SEROUT GPIO.0,6,[72,72,58,77,77] 'Display HH:MM", for example, to get data to the display. Obviously, the PIC must be configured for the baud rate. (I took the statement from Paul Borgmeier's Easy Clock program). There is far less setup and PIC pin usage with a serial display than with a parallel display so I think that's why they are shown more than the parallel displays. As for someone specifying certain types of backpacks, it shouldn't matter. All you are doing is sending serial data out at a certain rate. Most backpacks have jumper selectable baud rates.

    You should be able to buy a couple of backpacks, keep them in a parts drawer, then when you need one, plug in the LCD and away you go. I just bought 4 from a place called Wulfeden for a reasonable price and I have them available when I need them. I have been mostly been using 4 x 20 VFDs on a few larger projects. I bought a dozen of Melanie's Blue 2 x 16 LCDs last year and they are great for adding the backpack to. You don't need to solder the backpack to the LCD. Just use plugable headers. So If you go from parallel to serial you just plug in the backpack and away you go.

    I hope this helps.

    BobK

  5. #5
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    I've made serial to parallel LCD backpacks before. When I did it the LCD, or in this case VFD, had an odd protocol and I was trying to standardize it. I located a serial protocol from another manufacturer as my model. (matrix orbital or crystal fontz) While it did work well I ended up not completing the code because the VFD got damaged.

    The two commands I used were HSERIN (serial in), and LCDOut. Most of the code was taken up with a Select Case routine to convert incoming command codes to something the VFD could understand. The process was listen for serial commands, buffer incoming serial data, parse command codes, and send data to LCD/VFD. You already have a start on this with your code, now you need to add in the additional commands (see either another serial protocol or use the LCDOut information).

    All that being said, if all you want is an inexpensive backpack or you want an idea of what a pic based on looks like try this:
    http://www.sparkfun.com/commerce/pro...roducts_id=258
    Last edited by DynamoBen; - 6th November 2006 at 14:57.

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

    Default Still Going . . .

    Hi All,
    The serial adapter I currently use can be found at a reasonable price really, from
    http://phanderson.com/lcd106/lcd107.html, 2.95 each in 100 qty, having said that, I still do not want to us them as I do not have confidence in any device I have not seen the code for, especially when it comes to embedding operations code into my applications for products I wish to sell to a manufacturer, additionally I do not care to have his test routine or splash screen on my application. For a gadget to use around the house, then sure, I will use them. I have seen 1 or 2 out there written in assembler or C, C++, I suppose I will continue to hammer on the listed code until I am satisfied it works as expected every time and always. Right now I waiting for an order of 4x20 displays from China.
    JS

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

    Default Fine print . .

    Quote Originally Posted by BobK
    As for someone specifying certain types of backpacks, it shouldn't matter.

    BobK
    Ahh not so . . the hitachi chip does display data the same regardless of who's backpack drives it, assuming the data doesnt get filtered first. The problem here is everyone who sells one of these has his/her own little initialization routines and that's what will trip me up, if I code for Anderson's unit and my customer finds a better deal on Seetron's display, now I get a nasty phone call. .I always try to put the fire out before it is lit. The best way to do that is control the code.
    Thank You for your input (everyone!) and anyone who wants to ring in an opinion on this, I think that would be super. Im trying to get around the 8 track / vs cassette , vhs vs beta, why won't my Chevy wheels fit a Ford Scenerio. I can go buy basicly anybodys video card and put in my Computer p/c or mac, so I think the way to workable standards is through the public domain. My Opinion, for better or worse.
    JS

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

    Smile Ok Here it is

    Ok enough of my whining, here is some workable code, thanks to Darrel Taylor, well mostly about 99 percent. He wrote it for something else, I added a monkey wrench and a screwdriver and it works for my needs, could it be better? Well you can judge for your self, it works good enough for my application as is
    Thanks Once again Darrel for the post I extracated this code from.

    Code:
    @ DEVICE pic16F628A, HS_OSC
    
    @ DEVICE pic16F628A, WDT_OFF
    ' Watchdog Timer
    
    @ DEVICE pic16F628A, PWRT_ON
    ' Power-On Timer
    
    @ DEVICE pic16F628A, MCLR_ON 
    ' Master Clear Options (Internal)
    
    @ DEVICE pic16F628A, BOD_OFF
    ' Brown-Out Detect
    
    @ DEVICE pic16F628A, LVP_OFF
    ' Low-Voltage Programming
    
    @ DEVICE pic16F628A, CPD_OFF
    ' Data Memory Code Protect
    ' Set to CPD_OFF for Development Copy
    ' Set to CPD_ON for Release Copy
    
    @ DEVICE pic16F628A, PROTECT_OFF
    ' Program Code Protection
    ' Set to PROTECT_OFF for Development Copy
    ' Set to PROTECT_ON for Release Copy
    
    trisb = %00000010
    trisA = %11110011
    include "modedefs.bas"
    ' Define LCD registers and bits
    Define  LCD_DREG        PORTB
    Define  LCD_DBIT        4
    Define  LCD_RSREG       PORTA
    Define  LCD_RSBIT       0
    Define  LCD_EREG        PORTA
    Define  LCD_EBIT        1
    
    DEFINE LCD_LINES 4             'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000     'Define delay time between sending LCD commands
    DEFINE LCD_DATAUS 50         'Define delay time between data sent.
    DEFINE OSC 20
    
    DEFINE HSER_RCSTA 90h        ' Enable serial port & continuous receive
    DEFINE HSER_TXSTA 20h        ' Enable transmit, BRGH = 0
    DEFINE HSER_SPBRG 32         ' FOR 20MHZ 129 = 2400, 32=9600,25 @ 4 for 2400
    DEFINE HSER_CLROERR 1        ' Clear overflow automatically
    
            RCIF VAR PIR1.5      ' Receive  interrupt flag (1=full , 0=empty)
            TXIF VAR PIR1.4      ' Transmit interrupt flag (1=empty, 0=full)
    LED VAR PORTA.4
    
    OERR    VAR    RCSTA.1             ' Alias OERR (USART Overrun Error Flag)
    CREN    VAR    RCSTA.4             ' Alias CREN (USART Continuous Receive Enable)
    buffer_size    CON    64             ' Sets the size of the ring buffer, set up from 32
    buffer    VAR    BYTE[buffer_size]' Array variable for holding received characters
    index_in    VAR    BYTE          ' Pointer - next empty location in buffer
    index_out    VAR    BYTE         ' Pointer - location of oldest character in buffer
    bufchar    VAR    BYTE             ' Stores the character retrieved from the buffer
    i        VAR    BYTE             ' loop counter 
    Col        VAR    BYTE             ' Stores location on LCD for text wrapping
    errflag    VAR    BYTE             ' Holds error flags
    index_in = 0
    index_out = 0
    i = 0
    col = 1
    
                                    'RxData var byte        
            CMCON = 7               ' PORTA is digital
            Pause 100               ' Wait for LCD to startup
            high PortA.2            ' power for backlight
            low  PortA.3            ' backlight ground
    INTCON = %11000000                ' Enable interrupts
    ON INTERRUPT GoTo serialin        ' Declare interrupt handler routine
    PIE1.5 = 1                        ' Enable interrupt on USART
    pause 1500
    lcdout $FE,1
    lcdout $FE,2
    LCDOUT "Your Text Goes Here"
    PAUSE 2000
    
    ' * * * * * * * * * * * * *   Main program starts here - blink an LED at 1Hz
    ' I removed some code here, it seems to require what's left
    loop:  
            For i = 0 to 10     ' Delay for .02 seconds (10*2mS)
                Pause 2           ' Use a short pause within a loop
            Next i                ' instead of one long pause
            
            For i = 0 to 10     ' Delay for .02 seconds (10*2mS)
                Pause 2           ' Use a short pause within a loop
            Next i                ' instead of one long pause
    
    
    display:                          ' dump the buffer to the LCD
            IF errflag Then error    ' Handle error if needed
            IF index_in = index_out Then loop    ' loop if nothing in buffer
    
            GoSub getbuf            ' Get a character from buffer    
            LCDOut bufchar            ' Send the character to LCD
            
            
            IF col > 20 Then        ' Check for end of line
                col = 1                ' Reset LCD location
                LCDOut $fe,$c0,REP " "\20    ' Clear line-2 of LCD
                LCDOut $FE,2        ' Tell LCD to return home
            EndIF
    
    GoTo display            ' Check for more characters in buffer
    
    
    
                            ' Subroutines
    
    Disable                    ' Don't check for interrupts in this section
    
    getbuf:                    ' move the next character in buffer to bufchar
        index_out = (index_out + 1)            ' Increment index_out pointer (0 to 63)
                                            ' Reset pointer if outside of buffer
        IF index_out > (buffer_size-1) Then index_out = 0    
        bufchar = buffer[index_out]            ' Read buffer location
    Return
    
    
    error:                              ' Display error message if buffer has overrun
        IF errflag.1 Then              ' Determine the error
            LCDOut $FE,$c0,"Clearing Display    Buffer"    ' Display buffer error on
                                                        ' line-2 and 3 Buff overrun
        Else
            LCDOut $FE,$D4,"USART Overrun"    ' Display usart error on line-4
        EndIF
        
        LCDOut $fe,2                    ' Send the LCD cursor back to line-1 home
        For i = 2 to col                ' Loop for each column beyond 1
            LCDOut $fe,$14                ' Move the cursor right to the right column
        Next i                          ' $14 = 20 DEC.
        
        errflag = 0            ' Reset the error flag
        CREN = 0            ' Disable continuous receive to clear overrun flag
        CREN = 1            ' Enable continuous receive
    
        GoTo display        ' Errors cleared, time to work.
        
        
    ' * * * * * * * * * * * * * * *  Interrupt handler
    
    serialin:                        ' Buffer the character received
        IF OERR Then usart_error    ' Check for USART errors
        index_in = (index_in + 1)    ' Increment index_in pointer (0 to 63)
        IF index_in > (buffer_size-1) Then index_in = 0    'Reset pointer if outside of buffer
        IF index_in = index_out Then buffer_error    ' Check for buffer overrun
        HSerin [buffer[index_in]]    ' Read USART and store character to next empty location
        IF RCIF Then serialin        ' Check for another character while we're here
        
    Resume                            ' Return to program
    
    buffer_error:
        errflag.1 = 1        ' Set the error flag for software
    ' Move pointer back to avoid corrupting the buffer. MIN insures that it ends up within the buffer.    
        index_in = (index_in - 1) MIN (buffer_size - 1)    
        HSerin [buffer[index_in]]    ' Overwrite the last character stored (resets the interrupt flag)
    usart_error:
        errflag.0 = 1        ' Set the error flag for hardware
        
    Resume                    ' Return to program
    
    
    End
    As I gain coding experience I will revisit this code unless someone else does so first ;-)
    JS

    Oh, what I really like about this is you use the standard formatting commands as used with LCDOUT, no funky commands.
    Last edited by ScaleRobotics; - 21st May 2010 at 15:42. Reason: added code tags

  9. #9
    Join Date
    Aug 2009
    Posts
    33

    Default Parallel LCD to Serial.

    I am new on this forum and also on programming PICs. I was looking for a program that helps me turn my parallel LCD into a serial. That’s what Mr. Darrel Taylor’s program does on “LCD Serial backpacks post #16. I wonder first if I could use his program on a 16F628 because the compiler doesn’t like it as is. Second, on what pin of which port should I connect the serial input on that 16F628 that will drive the parallel LCD. Sorry for these silly questions but I really would like to learn how to do that. Thanks.

  10. #10
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    Quote Originally Posted by timseven View Post
    I am new on this forum and also on programming PICs. I was looking for a program that helps me turn my parallel LCD into a serial. That’s what Mr. Darrel Taylor’s program does on “LCD Serial backpacks post #16. I wonder first if I could use his program on a 16F628 because the compiler doesn’t like it as is. Second, on what pin of which port should I connect the serial input on that 16F628 that will drive the parallel LCD. Sorry for these silly questions but I really would like to learn how to do that. Thanks.
    It'll work on a 628.
    Check out this thread

    Instant Interrupts - Revisited
    http://www.picbasic.co.uk/forum/showthread.php?t=3251

    The first post shows where to get the files.
    And the rest of the thread will answer many questions.

    hth,
    DT

  11. #11
    Join Date
    Aug 2009
    Posts
    33

    Default Thanks.

    Thank you sir.

  12. #12
    Join Date
    Aug 2009
    Posts
    33

    Default

    Well, after I read a group of posts I started to understand what your interest of introducing these new interrupts was. I am not very familiar with interrupts but I want to take advantage of this new approach. First I did was to try to play with your Blink program and at compilation time (16F628) I got an error: “Variable wsave3 position request 416 beyond Ram_End 335” I have look every where for an explanation of this error with no luck. Please, advice.

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    There is a section in the DT_INTS-14.bas file that has to be adjusted for the chip you are compiling for.
    I wish I could make it automatic, but there's no way to do that.

    For a 16F628, it doesn't have any General Purpose RAM in BANK3. So you have to comment out the wsave3 variable in this section.
    Code:
    wsave       var byte    $20     SYSTEM      ' location for W if in bank0
    ;wsave       var byte    $70     SYSTEM     ' alternate save location for W 
                                                ' if using $70, comment out wsave1-3
    
    ' --- IF any of these three lines cause an error ?? ---------------------------- 
    '       Comment them out to fix the problem ----
    ' -- It depends on which Chip you are using, as to which variables are needed --
    wsave1      var byte    $A0     SYSTEM      ' location for W if in bank1
    wsave2      var byte    $120    SYSTEM      ' location for W if in bank2
    ;wsave3      var byte    $1A0    SYSTEM      ' location for W if in bank3
    ' ------------------------------------------------------------------------------
    The 628 also has Access RAM at address $70 which can be accessed from any bank.
    So commenting everything and uncommenting the $70 variable will work too.
    Either way will work ... take your pick.
    Code:
    ;wsave       var byte    $20     SYSTEM      ' location for W if in bank0
    wsave       var byte    $70     SYSTEM     ' alternate save location for W 
                                                ' if using $70, comment out wsave1-3
    
    ' --- IF any of these three lines cause an error ?? ---------------------------- 
    '       Comment them out to fix the problem ----
    ' -- It depends on which Chip you are using, as to which variables are needed --
    ;wsave1      var byte    $A0     SYSTEM      ' location for W if in bank1
    ;wsave2      var byte    $120    SYSTEM      ' location for W if in bank2
    ;wsave3      var byte    $1A0    SYSTEM      ' location for W if in bank3
    ' ------------------------------------------------------------------------------
    DT

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. Please help with EDE702 - Serial to LCD interface
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th October 2008, 02:48
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Serial LCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th November 2007, 08:31
  5. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07

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