Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

PIC Serial Backpack I - Make your own Serial LCD

Discussion about LCD's and other related hardware

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo, Fast351, hydrolisk1792

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

How are you programming the LCD? Did you set the fuses right?

J

cruzz
Posts: 19
Joined: March 16th, 2006, 11:27 am
Contact:

Post by cruzz »

it seems, that problem is in PIC, cos there doesn?t appear anythink except black blocks. I didn?t programm it myself, coz I don?t have programmer :( I gave it to my friend to programm it and I also gave him that guide I had downloaded from your site, so it seems to be ok. I?ll check the wiring and see what happen :)

cruzz
Posts: 19
Joined: March 16th, 2006, 11:27 am
Contact:

Post by cruzz »

ok, I checked it, but it seems to be wired well, so problem is in PIC :(
I will have to give it to my friend to reprogramm it, but it will take some time. Is it possible to see, that programming failes? He told me, that he had programmed it according that manual and at the end, there appeared that programming was OK, but it wasn?t :(

or, maybe that PIC is dead? Is it possible to check it somehow, that it is/isn?t dead? Thx

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

When he programs it he can verify the data written, most programming software has this option.

If it isn't dead than maybe he made some mistake selecting the fuses (checkboxes that set some PIC parameters while being programmed) especially internal oscillator should be selected on.
In the worst case the lcd isn't HD44780 compatible, have you tried it before connected to LPT?


Edit:
@_X7JAY7X_ I am playing right now with this setup, works like a charm! Few minor gliches: in winamp spectrum analyzer the first row characters in the upper part show a line in the transition from a full block to empty block and when LCDSmatie starts for a fraction of time appears a "Yen" symbol at first row first column. Still testing. Great work! I have been testing with HD44780 and KS0065 2x24, 2x16 and 1x16.

The backlight toggles on when smartie starts, you can turn it off but never turn on again, only by restarting smartie it turns on again. This is the same with Backlight 0/1/flash commands. Adjusting the brightness turns backlight on again. Any ideas?
BTW any news on the 877 code? :wink:
Last edited by caesar on April 1st, 2006, 9:11 pm, edited 1 time in total.

cruzz
Posts: 19
Joined: March 16th, 2006, 11:27 am
Contact:

Post by cruzz »

Ok, I?ll give it to him to reprogramm it, hope it helps. My display is HD44780 compatible, I tried LPT connection befor, and it worked.

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

Few minor gliches: in winamp spectrum analyzer the first row characters in the upper part show a line in the transition from a full block to empty block and when LCDSmatie starts for a fraction of time appears a "Yen" symbol at first row first column. Still testing. Great work! I have been testing with HD44780 and KS0065 2x24, 2x16 and 1x16.

The backlight toggles on when smartie starts, you can turn it off but never turn on again, only by restarting smartie it turns on again. This is the same with Backlight 0/1/flash commands.

Can you please maybe get a picture of the spectrum analyzer when it transitions to give me a better idea of what it is doing?

The "yen" symbol is most likely a misinterpreted command from Smartie. It only appears for a second at most when smartie first starts.

The backlight toggle is a known problem with that firmware. I havent tracked the problem down to exactly what is causing it yet. I believe that smartie is using different backlight commands for when smartie starts and when you use the toggle command. The next and most likely last release of the 16F628 code (version 2.X) will fix a few minor bugs and hopefully include a couple GPO's and maybe a button.

J

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

My implementation of the MO commands (very similar to X7JAY7X) does the same thing when Smartie starts - a couple of random characters are briefly displayed before the proper Smartie screen appears. I'm not sure if it's the same characters every time. I might have a look with an RS232 grabber/logger to check what Smartie sends as it starts up.

I have the backlight control on my version working properly, as far as I can tell. ON/OFF, Flash and brightness (no software contrast control) works properly in Smartie.

This is how my implementation does it: In my code, I preset the backlight PWM to 50% in the initialisation, but don't enable the PWM. MO command 66 turns the backlight ON at the current PWM setting (ie 50% unless it has been changed by Smartie). MO command 70 turns PWM off but doesn't change the duty cycle. MO commands 152 and 153 set the backlight PWM duty cycle AND enable the PWM output. I don't actually save the PWM value to EEPROM though (MO modules do this for the set-and-remember commands like 152). I don't have any provision for software contrast control (just a variable resistor in the circuit), so the contrast commands are simply ignored.

Matt.

Rafael
Plugin Author
Posts: 71
Joined: November 22nd, 2005, 7:12 pm
Location: Curitiba, Paran?, Brazil

Post by Rafael »

Is there a command list?

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

I got the command list from the Matrix Orbital datasheets for the MOS series. These are economy modules similar to the "backpacks" we're describing here - backlit alphanumeric LCD of 2x16 to 4x20 (mine doesn't support 4x40, I think Jay's does now), with serial input and optionally a few general purpose logic outputs (GPOs).

I based my backpack on the datasheet for the MOS-AL162A series (2x16 chars), although I now have it on a 4x20 display. Download it from the Matrix Orbital website.

My firmware implements only the basic commands necessary for controlling cursor position, writing characters, setting custom characters, initialising the display and controlling the backlight. Other commands are ignored (like setting up costom bargraphs, contrast control, auto line-wrap etc). I guess Jay's command set is similar.

From my source code:
Matrix Orbital Commands Supported:
66 - Backlight ON (at previously set level, or 50% at startup)
70 - Backlight OFF
71 - Set cursor pos (col, row)
72 - Send cursor home
74 - Underline cursor on
75 - Underline cursor off (any cursor off)
76 - Move cursor left 1 space (doesn't properly wrap between lines)
77 - Move cursor right 1 space (doesn't properly wrap between lines)
78 - Define custom char (addr, 8 bytes pattern)
83 - Block cursor on
84 - Block cursor off (any cursor off)
88 - Clear display
152 - Set backlight brightness (0-255) (NB doesn't store setting)
153 - Set backlight brightness (0-255 where 0=off, 255=max)
Other commands ignored

This set of commands is about all you need for LCDSmartie, unless you want to do fancy stuff like big characters.

Matt.

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

I did some testing to find out what Smartie sends when it starts up. Here's the list (command numbers in decimal):

Code: Select all

*turn off each GPO (8x command 86)
*turn off block cursor (84)
*clear display (88)
*underline cursor off (75)
*auto scroll off (82)
*autowrap off (68)
*auto transmit keypresses on (65)
*auto repeat keypress mode off (96)
*backlight on forever (66,0)
*contrast to {whatever you set in the MO control dialog} (80,x)
*backlight brightness to {whatever you set in the MO control dialog} (152,x)
*set custom char 1 to degrees symbol (78)
*set custom chars 2-4 to bargraph symbols (3x 78)
*set custom chars 3-8 to blank (4x 78)
then display appropriate screen.

I didn't know about commands 65 and 96, since I'd only looked at the datasheet for a module with no keypad support... so I added them to the list of ignored commands that have no parameter, and that stopped the stray characters appearing on the LCD when Smartie started up.

My firmware was trying to read and discard a parameter byte for those commands, which or course messed up the next couple of commands. That might be something to check in your code, Jay.

Matt.

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

It is probably the contrast command. Even if you have no code in there you should still have a case for if the commands. Just so the byte is read in where it should be read in. I will have to look at mine again and see if I did that.

Also for the backlight. I remember what I did. I think I just used the backlight brightness and backlight off command. That is why mine only turns on at startup. I will fix it this week and send out a new firmware. My backlight doesnt save it either, I can make it do it but smartie sends a backlight command every time you start the LCD. I didnt think its necessary unless you dont use the LCD with smartie.

I also plan on adding 2 GPOs for right now for the 628a version.


J

Rafael
Plugin Author
Posts: 71
Joined: November 22nd, 2005, 7:12 pm
Location: Curitiba, Paran?, Brazil

Post by Rafael »

a 628 for a 4x40 with all controls... it?s perfect!!! :D

cruzz
Posts: 19
Joined: March 16th, 2006, 11:27 am
Contact:

Post by cruzz »

Thx God and everyone here, it works :)
Problem was in PIC, my friend set different oscilaotr, but now it works :)

caesar
Forum Supporter
Posts: 734
Joined: October 15th, 2005, 10:39 am
Location: Romania
Contact:

Post by caesar »

Well done cruzz!

@Rafael: 628 can't do 4x40, not enough pins...

@_X7JAY7X_: my 2 cents: isn't it better to have at least 3 buttons rather than GPO's for the 628A version? I'll post in a few hours the pictures.

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

Its up to you guys, do you want GPOs or Buttons?

The 4x40 could be done on the 628, but it would have to be done in 4-bit. This takes twice as long to write to the LCD since you have to send the byte in two nibbles. I wonder how well it would work for such a large display.

J

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

Ok, fixed the random character at startup and the backlight functions properly now. Caesar, I sent it to you to test these two fixes. If anyone else want to test let me know.

J

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

I'd rather have buttons than GPOs, so you can switch between screens or themes, control winamp, etc. My display isn't mounted in the PC, so I probably would never use GPOs for fans or the like. A warning buzzer/beeper might be an idea though.

I'm planning to add 3 or 4 buttons to my implementation sometime (already have one that turns on the backlight). I could squeeze in 3 buttons and a single GPO, using all the I/O on the 628.

I also want to add a software FIFO buffer to the RS232 receive, since at the moment I'm relying on the PIC UART to do that, but it can only buffer 2 or 3 characters. It's quite possible (even at 9600baud, and particularly at 19200) that overflows will occur, though I haven't had a problem yet. I suspect Smartie spaces out the commands a bit to avoid such overflows.

It would take a bit longer to write to the LCD in 4-bit mode, but it's probably not much slower than 8-bit, since the LCD takes a while to process each character (typically around 40us), and longer for some commands (1.5ms), and it only takes a handful of microseconds to put two nibbles on the data bus.

I'm using 4-bit mode on mine. At the moment, my firmware simply waits in a loop for a bit more than the expected time required, since one LCD I'm using doesn't seem to properly do the "busy" flag (posible ESD damage?). The other LCD does it fine. That frees up the R/W line for GPO or whatever.

Matt.

Rafael
Plugin Author
Posts: 71
Joined: November 22nd, 2005, 7:12 pm
Location: Curitiba, Paran?, Brazil

Post by Rafael »

Using with a 628 in 4x40, we can produce a very low cost solution to this! But using 4bit mode, I think that is very necessary clock it @ 20Mhz... we can?t lost information on display with the processing delay... :shock:

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

Using the PIC at 20MHz means you need an external oscillator (crystal plus capacitors), which puts the cost/complexity up slightly. One drawback is that the crystal oscillator uses up two precious pins that are used for I/O in the internal osc mode.

By adding a few components (and some software complexity), you could multiplex several buttons with the LCD data lines. See Bob Blick's LCDterm for a really adventurous LCD terminal based on a humble 16F84 - 20 buttons, 4x20 LCD and 5 LEDs with serious multiplexing. This could be adapted for the 16F628. This is where I got the idea for my version from, before discovering LCDSmartie and that Jay had already done it...

I think the internal 4MHz oscillator is probably fast enough - the LCD is comparatively slow (the HD44780 is usually clocked at 270kHz!). For example, the minimum width for the E (enable) pulse is 250-500ns depending on LCD. Then you have to wait for the LCD to process the command or character (40us or 1.5ms). One PIC instruction cycle is 1000ns at 4MHz. Of course, it wouldn't hurt to run the PIC faster.

If you use a software FIFO buffer (interrupt-driven) on the RS232 receive, you're unlikely to lose any data, even at higher baud rates.

Matt.

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

We can get alot of I/O using I2C port expanders. Another option would be to use two 628a's. One to control just the lcd, and the other for I/O.


J

ch424
Posts: 30
Joined: March 21st, 2006, 6:43 pm
Location: Oxford, UK

Post by ch424 »

Can't you just use a PIC with more pins? Using the 18F2550 (28 pin), I have
PORTA: RA0=buzzer, RA1=unused, RA2-RA5=GPOs
PORTB dedicated to LCD (D0-D3,RS,RW,EN,backlight)
PORTC: RC0-RC2=buttons, RC3=unusable, RC4+RC5=USB, RC6-RC7=unused

I plan to use RC7 for a serial in from an IR remote, but otherwise there are two spare pins. If you get rid of the GPOs and use a PIC that lets you use RC3, that's 7 free pins, allowing for 12 buttons with simple multiplexing -- more than enough to be honest... and if you use an internal OSC, that's another two pins free, allowing 20 buttons or 12 buttons + 2 GPOs.

Don't worry about the low clock speed Matt: A 3.6MHz AVR can do 20x4 with eight buttons and 19200baud no problem.

ch424

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

We are trying to keep cost down. The 628a is probably the most cost effective PIC that can do what we need it to. Last time I checked mouser they were like $1.80 US each. We just need to magically make a few spare pins turn into alot of I/O.

J

Rafael
Plugin Author
Posts: 71
Joined: November 22nd, 2005, 7:12 pm
Location: Curitiba, Paran?, Brazil

Post by Rafael »

About the 628a...

Can all pins in PORTA used for d0-d7?

We can discard the MCLR and use as data output.. (MCLR=OFF)

We can discard the Xtal pins and use as data output.. (INTRC_IO)

And the PORTB for controls and receive data...

It?s possible?

ch424
Posts: 30
Joined: March 21st, 2006, 6:43 pm
Location: Oxford, UK

Post by ch424 »

J, looking at your schematic, you could put all the LCD stuff onto porta, leaving 7 pins free once RB1 has been used.

7=3+4 therefore you can have 3x4=12 buttons with normal multiplexing...

Or have two GPOs, leaving 5 pins free for eight buttons, like this:
Image

And just three external components save for the buttons.

Obviously that'd still work with your current pin assignment too.

ch424

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

PORT A can be used. Although I think one pin needs to be pulled high with a resistor. It isnt a normal output pin.

I will look into this. Multiplexing will work, I have done this before on another project, so its a matter of copying some of the code over and applying it.

J

Post Reply