Hi Joe,
Howzit?
Could you give some more details?
I am not sure what you want to have is?
-------------------------------
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
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
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
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.
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
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.Originally Posted by BobK
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
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.
As I gain coding experience I will revisit this code unless someone else does so first ;-)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
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
Hi Joe,
Glad you got it working!
That must have been a really old one.
It doesn't look familiar at all.
DT
That's what i thought when i saw...
Code:ON INTERRUPT GoTo ....![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hmmmmm, it must have been the screwdriver . . .Originally Posted by Darrel Taylor
JS
Originally Posted by Joe S.
I must've missed something in the translation here....
I've been basically working on the same type of thing for a couple of weeks now, and I think I might be shooting myself in the foot or something trying to figure this out...
How are you passing the lcdout 'commands'? i.e. lcdout $fe, 01 to clear the display and things like that?
If my guess is right, like me, you are basically replacing 'lcdout' with 'serout' on the main board, and this code is to read everything coming the serial port, and sending it out, character by character using a single 'lcdout'.
And if I'm reading this right, PBPro knows that if you send an '$FE', the next character down the line, whether it's in the same statement or not, will be an lcd 'command'.
Maybe that's where I'm tripping myself up. I'm trying to split data and commands apart at the lcd end of things...
Why did MeLabs pick $FE as the 'command' character anyways? Why not $FF or $CD or whatever?
Hi Jeremy,
You got it.And if I'm reading this right, PBPro knows that if you send an '$FE', the next character down the line, whether it's in the same statement or not, will be an lcd 'command'.
When PBP see's a $FE, it sets FLAGS.0 (LCDCDFLAG).
Which means that the next character is a command. And then when sending the next char, it sets the RS pin LOW.
And, while of no use but an example, if you were to do this...It would do a Clear Screen.Code:FLAGS.0 = 1 LCDOUT 1
For the HD44780's Character Table, The last 2 characters $FE and $FF are "all pixels OFF" and "all pixels ON" respectively. And, since "all pixels OFF" is the same thing as a Space, it's likely to assume that $FE will never be used to display a character. So it's available to initiate the Command sequence.Why did MeLabs pick $FE as the 'command' character anyways? Why not $FF or $CD or whatever?
So all you really need to do for a backpack is, make sure that you don't miss any incomming data, and pass it all on to the LCDOUT command.
But, there can be some advantage to separating the Clear Screen and Home commands, like you've been doing.
They take the longest to execute (1.6-4.5ms) depending on the display. But LCD_COMMANDUS delays the same amount no matter which command is supplied. Commands like moving the cursor to a new location may only take between 40-120us (same as LCD_DATAUS), but LCDOUT will still wait the full LCD_COMMANDUS time (usually 2000us).
For a backpack, if you reduce the LCD_COMMANDUS time, and detect the Clear Screen and Home to add a longer pause. It can increase the speed to a point where you don't even need to buffer the data up to 9600 baud.
DT
Hi Skimask,Originally Posted by skimask
That was the whole point of the endever, to use the standard commands common to lcdout, so as not to have several different codes to control how the lcd prints to screen. It seems most makers of these things have their own little routines, I started with:
I saw the core code in a post of Darrel's using HserinCode:serin N2400.PortB.7,char lcdout char
and knew it would work so I started cutting and sewing,
Darrel took it and added his instant interrupts, i snipped
out some more of the unneeded stuff and am still working
on all the bells and whistles. I like it better than all the
others I've seen, because it uses unmolested, lcdout type code.
JS
Bookmarks