LCDcam
        Interfacing an HD44780-compatible LCD to the web.


Why:

      
Why not? I was bored, had this LCD laying around and decided to see if I can do it (interface it to the web). It turned out to be more of a software headache than I expected, but it was fun. It needs some fine tuning software wise, like if I decide to write a dedicated Java App to control it locally, instead of VB. Also this is something of a precursor to robotics; which I hope to dabble with in the future.

Hardware part:


        OK, here's how it works. You gotta put together the LCD interface, HD44780 chipset,and connect it to a parallel port. I won't explain that here. Connect it to the parallel port, if you're making this REMEMBER TO GROUND THE INTERFACE!!! Connect pin ~20 to 0v (ground/earth). But here are some pretty pictures of my setup:

1) The impromptu 5volt power supply (with 0-9v regulator! wow!):

*UPDATE* - I changed the power-supply to a USB cable. It provides something like 5.02V or 5.09V. Great source and if I ever decide to put this thing together for something useful (like PC status module) I can use the Parallel Port for the LCD and a short USB cable for power. Most people use a Molex connector for 5V to power the LCD, I'm really not into that. And I have lots of open USB ports. (Ok, here's where I lied. I'm actually using a PS/2 cable that I ripped off an old Keyboard that I threw away. Then I used a PS/2->USB adapter, and thats how it REALLY works. Pin-outs are simple as can be, red for +V and black for GROUND/0V)



2) The completed breadboard (before I tidied up the wiring, made it prettier):


3) Final pic of the messy wiring (hey, it works).



Software part:

And then there's the really complicated (more complicated than it should be) software part: here's the quick and less detailed explanation (more detailed at bottom of page)


1) This form/webcam interface accepts any text you put in it. It takes the input and sends it to a perl script which later outputs a text file containing the message:



Here is the LCD.pl perl script, nothing fancy, accepts the POST method from the above form and outputs the text to LCD.txt:





2) This little shelll script takes the TXT file from the above webpage's output and saves it locally (this is an intermediate step that COULD be skipped, if I had more time, my webhosting company uses VIRTUAL hosting and my VB code doesn't like that, so I had to use a shell).
It stores the text file as LCD.txt locally (on the shell locally). It loops infinitely and checks every five seconds,  uses wget to grab the file ONLY if the file is changed (thank you wget coders!). So in a way, this is good...I wouldn't want to try to code this in VB.

 


3) This little VB program that I coded grabs the LCD.txt from the above website and stores it locally on the hard-drive.




4) Finally, LCD Smartie 5.2 reads the local LCD.txt file and outputs it to the LCD through the parallel port.




5) OH, finally WebcamXP outputs the stream showing the LCD on the web (see step 1).





Detailed explanation:

        So, in the end, this little complicated experiment took me 3 days to complete (my weekend). Started by interfacing the HD44780 Hitachi chipset-compatible 16x1 LCD screen, hooked it up to a breadboard and to the parallel port of my WinXP machine. Then I decided I want to remotely edit the text...and thats when it all started to go wrong....so many little problems with incompatibilities in code and interfacing...I forgot how to do webforms...then PHP didn't work ( I REALLY wanted to use PHP), then my perl scripts weren't working untill I remembered mod_perl needs the "-w" flag in the script (UGH!). THEN my VB (yes VB, don't say anything) was going screwey and adding weird characters...But in the end (3am on sunday morning to be exact) everything worked.

        So after I wrote the HTML interface and perl script, I had to have a way of grabbing the output of the perl script (LCD.txt) from the website. LCD Smartie does NOT have that option (too bad, it CAN get the weather info online though..). So I had to code something to do that. I noticed that LCD Smartie can read a local text file and updates the LCD as soon as the file is saved. This was GOOD! So I wrote a little VB program to rip the LCD.txt from the first website and store it locally. Problem. It seems my webhost's virtual hosting is a BITCH with custom socket code (winsock+VB). So I thouhgt it over for a LONG while and decided that I would use my shell to do the HTML form stuff. WRONG! Php did NOT work at all, and same went for PERL. UGH! BUT my little VB program was able to grab the LCD.txt from the shell....so what was I to do? Use my first website and write middle-man interface! I wrote a little shell script to grab the LCD.txt from the first website (hosted website that now has the HTML interface and webcam interface), and store it locally on the shell. Then I pointed my little VB app to the shell's LCD.txt copy and it all worked smooth as butter! The webcam part is pretty straight-forward. Just a cheap Veo webcam hooked up to USB with "WebcamXP" serving the page (this is a REALLY awesome program, VERY customizable). After I got the webcam portion set up I was pretty much finished.

SO, it all goes like this:

1) 1st Machine: http://LCDcam.mozy.org/ has the submission form and webcam interface. It takes the input and sends the POST method data to LCD.pl perl script, which stores the data as LCD.txt.

2) 2nd Machine: The Shell runs camserve.sh script to check every 5 seconds whether or not 1st Machine's LCD.txt has changed, if so, it grabs it with wget and stores it locally also as LCD.txt. Does this infinitely.

3) 3rd Machine: HTMLGrab (VB code) runs in the forground and every 5 seconds grabs 2nd Machine's LCD.txt file (whether it changed or not) and stores it locally again as LCD.txt

4) 3rd Machine: LCD Smartie reads the local LCD.txt file and pipes it off to the LCD through the parallel port.

5) 3rd Machine: WebcamXP streams the LCD's image onto the web onto 1st Machine's webcam interface.

6) Rinse and repeat steps 1 through 5.


Timeline:
Started - Septermber 10, 2004 - 11am
Finished - September 12,2004 - 9pm (this page).

Created by Mozy