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

USB LCD (MO LK204-25 emulating)

Discussion about LCD's and other related hardware

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

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

USB LCD (MO LK204-25 emulating)

Post by ch424 »

Hi people,

I've just finished my AS electonics project, an LK204-25 emulator.

It emulates these instructions:

Position: 254 71 [col] [row]
Home: 254 72
Underline on: 254 74
Underline off: 254 75
Blink on: 254 83
Blink off: 254 84
Define custom: 254 78 [c] [8Bytes]
Clear display: 254 88
Backlight on: 254 66 [mins] (mins is discarded)
Backlight off: 254 70
GP output on: 254 86 [gpo#]
GP output off: 254 87 [gpo#]

Enough on that, time for pictures! (Click for big)

Image
The whole system

It has four GPOs for fans, capable of delivering 65W at 12V and the buzzer acts as the 5th GPO. The rotary encoder sends A to the computer when rotated one way, B when rotated the other way, and S when pushed in. This works with LCD smartie. My firmware doesn't support polling mode, because you don't need it for smartie ;) Oh yeah, forgot to say it's USB! The molex is to the fans. The PIC and the LCD take power off USB.

Image
Closeup of my LCD. It's made by Batron, and I got it from Farnell for ?30.

Image
Closeup of the PCB.

What do you think?

ch424
limbo
Plugin Author
Posts: 1604
Joined: February 13th, 2005, 7:38 pm
Location: Athens - Greece
Contact:

Post by limbo »

ch424 nice work :lol:
Are you going to publish your work?
ch424
Posts: 30
Joined: March 21st, 2006, 6:43 pm
Location: Oxford, UK

Post by ch424 »

Thanks!

Yes, the schematic, pcb and PIC hex file will be posted sometime in the near future. I don't think I'll release the code yet, as it's not easy to understand (read "badly commented") and I don't want people asking me about modifying it. I also want to add PWM backlight control (easy but a matter of getting round to it).

I'm currently working on a better PCB: you can see I forgot the pull-up resistors for the rotary encoder, and the terminal pins for it on the PCB are a bit close together :oops:. I also want to use a floppy power connector rather than that molex.

The PIC is an 18F2550, which you can get from Sparkfun, Farnell or Microchip Direct... Apparently there's quite a long delevery wait though. (Farnell and Microchip both said a few weeks.)

To work! :smt024

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

Post by _X7JAY7X_ »

Good work, what displays does it support? What did you program it in?

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

Post by ch424 »

Thanks _X7JAY7X_

It supports a 20x4 HD44780/KS0066U by default. I wrote it on top of Microchip's free (as in speech) USB CDC firmware, so I had to use the student (free as in beer) edition of their C18 compiler.

For my GCSE project, I made this, which used AVR assembly, but it was waaay more complicated in terms of component count, and didn't have the fan controller, backlight control, or buzzer.

My friend wants a 20x2 version of this new one, so I guess that could be easily changed by having a different compile of the firmware. However, that would mean multiple firmware which is lame considering few people can program the 18f2550. Your device is pretty much the same thing, (but with cleaner code ;)), right? How do you recommend doing display size detection? I don't want to use a jumper, as my uC only has three spare pins, and I plan to use one for contrast control and one for IR for a remote, leaving just one for something else...

I guess 40x4 and larger support would be cool too, and that's what I'd use the last pin for. However, I don't have a 40x4 to test with :(

So what would you do?

Cheers,

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

Post by _X7JAY7X_ »

I guess there is a few options. Mine can use either 2xXX or 4x20 without any firmware change. Check the addressing of the 2 line LCD vs the 4 Line LCD. If I remember right, the first 2 lines of both use the same addressing.

The 40x4 is alot different and requires a complete firmware change as far as how the PIC writes to the LCD. You would have 2 enables lines (2 controllers) and would have to toggle between each controller depending on the write position. You also have to keep track of which LCD to write to after a position change.

Another option would be to make a program (in visual basic or whatever) that can change values in the EEPROM. Depending on this value, the PIC would know what LCD routines it is supposed to use.

Did you write the LCD routines yourself?

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

Post by ch424 »

_X7JAY7X_ wrote:I guess there is a few options. Mine can use either 2xXX or 4x20 without any firmware change. Check the addressing of the 2 line LCD vs the 4 Line LCD. If I remember right, the first 2 lines of both use the same addressing.
Are you saying it works by default? I was worried that the goto [col][row] function wouldn't line up, but if it just works anyway, that's cool. Just solder and play!
_X7JAY7X_ wrote:The 40x4 is alot different and requires a complete firmware change as far as how the PIC writes to the LCD. You would have 2 enables lines (2 controllers) and would have to toggle between each controller depending on the write position. You also have to kesayi write to after a position change.
I won't bother then.
_X7JAY7X_ wrote:Another option would be to make a program (in visual basic or whatever) that can change values in the EEPROM. Depending on this value, the PIC would know what LCD routines it is supposed to use.
Guess I won't need to if it works by default.
_X7JAY7X_ wrote:Did you write the LCD routines yourself?
I tried using the XLCD library provided by Microchip. I spent a fruitless week trying to get it to work. I then thought never mind I might as well write my own, and it only took an afternoon to get data, commands and BF reading all working from scratch in 4bit mode. So easy to waste time looking at other people's code, hey!?

I then had to make them all non-blocking as the USB firmware isn't interrupt based, and likes to get enough CPU time. Time sharing isn't really a problem at 48MHz though! I have TMR0 triggering a buttons check routine though, which queues a keypress to be sent from the main time-shared loop. I plan to add the backlight PWM updater to this ISR.

I wrote them myself for the AVR thing as well, from the datasheet on the milinst.com website. Re-writing for the PIC wasn't too tricky as I could copy the procedures I'd already used before. I also worked from the LK-204-25 datasheet.

I've posted in the General Forum asking about some FanSpeed function that seems to be dead... I'm hoping the LCDSmartie developers are going to make it implement some kind of PWM for the GPOs! As the PIC can sustain 128kbaud with the computer, PWM for fans should be no problem! If they don't I may have to request/write a plugin...

Thanks for the info!

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

Post by Rafael »

Hi...

Is there some wiring schem? I have 4x40 for test it...

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

Post by ch424 »

Hang on on the schematics people, I'm going away for a week, so I'll post them when I get back...

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

Post by _X7JAY7X_ »

CH as I was thinking about it more. I think another option would allow, lets say 3 secs or so right when the microcontroller powers up to make settings. Here is how it would work. Lets say port b is defined as inputs at powerup, reading in these pins you could set a bit in the EEPROM to decide which LCD routines you could use. After the 3 secs or so is up, then all the ports are redefined as inputs or outputs as needed to run the MO emulation firmware.

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

Post by caesar »

Hi ch424!

You really got my interest!
I own several lcd's and want to get on usb

Maybe if you can spare some time to make us happy please add support for 4x40... i could test your code!

Please post the schematics and firmware soon!

Thanx!
Caesar

Edit: just got some 18F2550 so i'm open for testing :wink: :D
_474_

Re: USB LCD (MO LK204-25 emulating)

Post by _474_ »

Is it possible to connect an old laptop screen, maybe by using a controller card from:
cgi(dot)ebay(dot)com(slash)ws slash eBayISAPI.dll?ViewItem&item=111080462687
Post Reply