Proton Serial LCD
Published on 29th November 2016 16:04
LCD displays are an invaluable aid to programming, as well as offering ...
Graphic LCDs are not only great fun to use, they also offer a very professional finish to an end product. However, cost has always been a issue, as graphic LCDs are frequently many times more expensive than their alphanumeric counterparts. But thanks to the graphic LCDs that Crownhill supplies, this is now not an issue, as they offer both affordability and flexibility.
The SGLCD
This comprehensive development system will allow you to produce stunning displays using powerful commands via a serial interface to the LCD. This complete development system offers not only the Serial Interface board coupled to a high quality Graphics LCD panel, but also powerful utilities to download graphics to the Onboard memeory AND commented source code for the Serial Graphics LCD controller AND circuit diagrams. This development system is all that is required to both learn about and use Graphics LCD's.
Please Note: this is a complete development system. Our 128x64 Graphics LCD's are very affordable, and the PCB's for the serial interface are available separately, so after purchasing the development system, why not build your own serial interface and integrate a Graphics LCD into your next PIC® BASIC application!
See the Serial Graphics LCD in action, download these two 5MB QuickTime Movie files showing the SGLCD board running the sloppy dog screen images in real time !
There are two main problems when interfacing to graphic LCDs: board layout and controlling software. Board layout can be a problem because the LCD requires up to 20 pins to be wired. Controlling software can be a problem because of the complex nature of displaying anything of any use on the LCD. The Proton PIC® BASIC Development Suite (available separately) takes the hardship out of controlling an LCD with commands such as PRINT, PLOT, LINE, CIRCLE etc, and now the complex interface is not a problem thanks to the PROTON Graphic LCD Serial Development Board (shown below).
Using a simple RS232 serial interface, you can PRINT, SCROLL, PLOT, SAVE and LOAD screens, (plus much more) on the LCD. And not only that, but you can develop your own software then program the on-board PIC® microcontroller using either the Proton Development Suite's Bootloader, or a conventional Device programmer such as the EPIC®. These features coupled with full source code for the serial interface commands offers a truly enjoyable, educational and time saving development platform, as well as a finished product for your final There are two software source files and listings supplied with the development board, one for controlling it using the Proton Plus compiler’s Serial Terminal that uses standard ASCII text; which is ideal for testing and demonstrating some of its capabilities. And one that is intended to be controlled from another microcontroller using less cumbersome binary controls. We’ll take a look at the Serial Terminal controlled software to start with, as this is already loaded on the development board when supplied.
Supply 6 to 9 Volts of power to the board via its power socket, and a short splash screen will be displayed. While the splash screen is busy, open the serial terminal built into the compiler’s IDE, by clicking on VIEW->SERIAL TERMINAL (see below).
You will be greeted with a window looking something like the screenshot below.
Now the Com port and Baud rate requires setting up. Click on the open Com icon, and a small menu will appear (see below).
Choose the appropriate Com port, according to the setup of your PC. The illustration above shows Com1 being chosen. Note: that the Com port chosen should be the same as the Com port used to download the program to the Development Board (more details later). When the Com port is chosen, another window will appear that will allow the Baud rate to be set (see below).
Set the Baud rate to 9600 (as above), and we’re ready to send some commands to the graphic LCD.
Just as a starter, type the following text on the terminal all in UPPER CASE and in quick succession.
B3F1F1001
And displayed on the graphic LCD should be a square, as shown below. OK, so it’s not an exact square, but that’s because of the aspect ratio of the graphic LCD’s pixels. They are approx 1.5 times taller than they are wide.
If a square did not appear, then try again but type quicker, and don’t forget to type in UPPER CASE.
The collection of characters told the serial LCD to draw a square “B” at X position 3F (decimal 63) and Y position 1F (decimal 31), with a RADIUS of 10 (decimal 16), and SET the pixels “01”
Note that all the values are formatted as 2 character HEX values. This is true for all the commands that have parameters, and all future discussions will be based on Hexadecimal values unless otherwise stated.
PROTON Graphic LCD Serial Interface Commands
- DISPLAY TEXT
- CLEAR the LCD
- POSITION the CURSOR
- SET or CLEAR a SINGLE PIXEL
- DRAW a CIRCLE
- DRAW a SQUARE
- DRAW a LINE
- SCROLL the DISPLAY UP
- SCROLL the DISPLAY DOWN
- SMOOTH SCROLL the DISPLAY UP
- SMOOTH SCROLL the DISPLAY LEFT
- SMOOTH SCROLL the DISPLAY RIGHT
- SMOOTH ROTATE the DISPLAY UP
- SMOOTH ROTATE the DISPLAY DOWN
- SMOOTH ROTATE the DISPLAY LEFT
- SMOOTH ROTATE the DISPLAY RIGHT
- SMOOTH ROTATE PART of the DISPLAY LEFT
- SMOOTH ROTATE PART of the DISPLAY RIGHT
- SAVE a SCREEN to EEPROM MEMORY
- LOAD a SCREEN from EEPROM MEMORY
- UPLOAD a SCREEN
- DOWNLOAD a SCREEN
- LCD BACKLIGHT CONTROL
- ENABLE/DISABLE RESPONSE
- ADJUST BAUD RATE
SAVE a SCREEN to EEPROM MEMORY
Save the current LCD display to a particular portion of the I2C eeprom memory. Within a single 24LC256 serial eeprom, which contains 32 Kbytes of memory, Thirty two screens can be saved. If all 4 eeproms are fitted to the PROTON SGLCD board, then a huge 1Mbit of memory is available (128 Kbytes) which is capable of holding 128 screens. As you’ve probably gathered, a screen consists of 1 Kbytes (1024 bytes). Because of the delay required for writing to eeproms, a screen save may take a few seconds. The PROTON SGLCD board’s serial interface will acknowledge when a save is complete.
THELLO WORLD
In the example above, the LCD is first cleared (command C), and text is displayed (command T). Once the text has appeared on the LCD, the SAVE SCREEN command is issued (Z) with the location to save the screen. While the screen is being saved to eeprom memory, the PROTON SGLCD will not respond to any further commands. After a few seconds, an acknowledge character “A” will be transmitted from the PROTON SGLCD to signal the screen has been saved
LOAD a SCREEN from EEPROM MEMORY
Load a screen (saved earlier) from a particular portion of the I2C eeprom memory. Within a single 24LC256 serial eeprom, which contains 32 Kbytes of memory, Thirty two screens can be stored. If all 4 eeproms are fitted to the PROTON SGLCD board, then a huge 1Mbit of memory is available (128 Kbytes) which is capable of holding 128 screens. As you’ve probably gathered, a screen consists of 1 Kbytes (1024 bytes).
XLOCATION in MEMORY (00 to 7F)
The example above should be used after the SAVE to SCREEN example has been carried out. In the example, the LCD is first cleared (command C), and the LOAD SCREEN command is issued (X) with the location to load the screen from. The previously saved screen will then be loaded on to the LCD.
Example2:
The PROTON SGLCD’s eeprom is preloaded with several sample screens. Example2 will load the screen stored at location 01 and the display shown below should appear.
UPLOAD a SCREEN
Most complex images displayed on the LCD are usually created using the PC, so a means of uploading the images to the LCD is required. That’s what the UPLOAD SCREEN command is for. It accepts a list of HEX data; where each HEX byte represents a byte on the LCD working from top left of the LCD to bottom right. Once the image is displayed on the LCD, the SAVE SCREEN command can store it in eeprom memory.
In order to demonstrate uploading an image to the LCD, a small executable program has been created that will load an image from the PC, and upload the image to the LCD via the serial port.
The Program IMAGE_UPLOAD.EXE is found on the CDROM supplied with the SGLCD.
Choose the com port that the PROTON SGLD is attached to
In the screen shot shown (below), com port 1 was chosen. Leave the baud rate as it is for now, because it defaults to 9600, which is the default baud rate of the PROTON SGLCD. Once the com port is chosen, the UPLOAD button will be enabled.
Click on FILE, and load one of the pictures located in the same folder as the executable. The screen shot below shows the picture DOG1.BMP.
An image will be produced on the PROTON SGLCD’s display, scanning from top left to bottom right. Once this has completed, close the IMAGE UPLOADER, and save the screen to eeprom memory using the SAVE SCREEN command. Remember where you placed it, as we’ll use this in the next command’s example.