PDA

View Full Version : LCDOUT Implementation



afbecker
- 21st February 2006, 19:01
First I'll explain my hardware setup. I have a 16F628A as the front end to a LCD module with a typical HD44780 controller. I'm running a 4Mhz crystal using XT configuration. !MCLR is defined as input, power-up is enabled, WDT & LVP is disabled along with the rest.

I built this circuit originally to run an assembler program on a 16F84 that I programmed with it. After I tweaked it, the program worked really well. Recently I accidentally destroyed the PIC with the original program. Long and short of it is I can't get the assembler code to work any longer so I've been trying to implement PICBasic "LCDOUT" in such a way as to input serial on a single line to the 16F628A / LCD construct. This way the host PIC only needs to dedicate one line to the display function.

To state the obvious, I have thoroughly gone over the various aspects of inverted signal, baud rate and the whole serial specification business. I have settled on operating at 9600, N, 8, 1 in two line mode since the module is capable of it. I also understand the control and data codes to sent to the HD44780.

In my latest (unsuccessful) attempt, I have build my 16F628A program around the following concept. I use "DEBUGIN" to read the serial line, in this case PORTA.0 (Yes, comparators are set off). I assign the port read to a byte sized variable named DataA. I have then paused 1000us before using "LCDOUT" to write DataA directly to the LCD, the LCD defines having previously been set. This idea relies on the character being read and passed along to the LCD without a character buffer. As I mentioned, it doesn't work. There may be a timing problem here and I understand the LCD controller is probably the slowest component in the mix but I would still think that at 9600 baud there still should be a fair amount of time for each character to be picked up and passed along.

If anyone has tried this and can offer suggestions or flaws in my reasoning, please offer a comment.

Dave
- 21st February 2006, 21:32
afbecker, are you using 8 lines or 4 lines connected to the lcd display? It seems from your posting you are trying to build a serial "backpack" controller for your lcd display. I have done this before and it works quite well. I did however use 8 line connection to the lcd display as the data can be transmitted in 1 strobe rather than 2. Just remember that some of the commands for the lcd display require at least 5 Ms. to execute ie (clear lcd, and some of the cursor positioning commands.

Dave Purola,
N8NTA

afbecker
- 22nd February 2006, 14:46
Dave,

Yes, I am using all 8 lines and they are all hardwired from PortB.0 through .7 to the respective pads on the LCD module.

If you have a copy of the essential portion of the code, I could probably work out the details. If that isn't available perhaps a conceptual explanation along with mention of any quirks or pitfalls one might encounter.

Thanks,
Allan

picster
- 8th March 2006, 17:57
Can you grab one character at a time coming into the PIC, stick them together in an array one at a time (up to the length of the LCD display line), and then spit it all out at once with LCDOUT when you receive a <13> or something?

This worked well for me... at 2400 baud, mind you... As long as your text arrives with enough time between the <13> and the next line of stuff to send it all out to the LCD, it should work.

------------------Picster---------------

afbecker
- 9th March 2006, 15:48
I had thought conceptually about this approach and like yourself, could have probably got a string buffer to work.

Ultimately I took what I think was the easiest course of action and that used in most of the posts I found here. Instead of using DEBUGIN I used HSERIN on the input side and the LCDOUT on the output side at 2400 baud with a and 4 pin data bus to the module. The code illustrated in several posts just envolved a character for character transfer with the PIC just cycling through read, biding the time between characters. At 2400 this seemed to work fine.

This solution meant changing my circuit board so that the hardware RX pin was used for input. On the 16F628A this meant I could not use all 8 PortB pins for output to the module. I disconnected the wires from B0-B3 to the module and just used B4-B7. The whole board was designed for an assembler code by one Tom Coonan which is available on the WEB. I just couldn't get it ported over to the 16F628A and have it work right. After 3 weeks of messing with it I opted to use the PIC Basic solution.

In any case, I have the "Backpack" working again and at 2400 I have tested it with another PIC as the sender and aslo Hyperterminal on a PC. It works fine now!