![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() I use
and
recommend Firefox for the best internet browsing experience. Click below for your free copy today: CLICK
THE IMAGE:
Note:
I find it faster
and easier to use and it has great plugins. It even imports all your current browser settings! There's
no risk as your existing browser is not affected in any way - you can just choose which
one to use.
|
|
Useful For You. Readers
comments
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
A PIC Serial LCD project.An RS232
serial LCD interface
using a standard HD44780 LCD...
There are no 'odd' command sequences such as 0xef to define a command - you can type all commands at the terminal interface making it very easy to use It's also easy to test it out manually before driving it with a program. Once you have decided what you want to do a microcontroller can generate the same commands or you can send them from a PC program. If you want to use it as a debugging terminal for your PIC projects then it makes sense to remove the level translator and just use the 0-5V input otherwise you would end up having two level translators for no real reason! Note: Using it like this you will need to invert the RS232 output data so you either need an inverter chip if driven from the built in USART or you can drive it using a software USART (The transmitter part anyway) since you will have full control over the output signal. Serial LCD Specification
Serial LCD Project Details
You can program the PIC in circuit through the ICSP connector. For a tutorial on compiling these files click here. You can recompile the serial LCD files if you want examine code operation (using the built in simulator) or change the source code. Note the hex file is contained in the download. Serial LCD Command setAll commands are prefixed with the hash character '#'. In all cases except #X and #Y the single character following the '#' causes a command to execute. For #X and #Y the decimal digits following (up to 2 digits) specify a position on the display.Note: for #X and #Y the top left position is at 0,0. Serial LCD Command Set list (uses upper or lower case):
To clear the display you would type: #C To set the cursor to block mode type: #B X and Y commandsThere must be at least two digits following the #X or #Y command unless the following command is not a digit. All this means is that you can finish an X or Y commands by typing a letter - if you type a digit the parser won't know if it is a digit to display or a digit to specify the position.Here is a cursor positioning example command sequence:
You
can also use the longer command:
Text entryIf you enter any other ASCII text other than the '#' character then it is displayed on the LCD and the cursor is advanced to the right.Note: to display a '#' character enter it twice '##'. Serial LCD HardwareSerial
port lcd display (RS232 to LCD) circuit diagram
(click to open pdf) ![]() The circuit simply consists of a PIC micro, ICSP interface, an RS232 level translator and an HD44780 LCD. Serial LCD display SoftwareThe software is contained in two files: 16F877A-serial-lcd.c bit.h contains bit manipulation macros. Project Files 16F877A-serial-lcd.ppc Output files: 16F877A-serial-lcd.hex 16F877A-serial-lcd.cInitially a scrolling message is displayed using show_intro. When a serial input is detected the main program starts. All keys are now either text entry or commands. An infinite loop keeps checking for key input. If the key is a hash symbol then the command is fetched using: get_prefix_and_execute_command(&x,&y); Otherwise the key value is displayed on the LCD at the current cursor position. Note: the use of x and y addresses (&x,&y) to pass the variable address through to the called functions so that values of x and y in main() are updated (using pointers in the called functions). get_prefix_and_execute_command calls execute_command which gets another key from the USART (or waits for one). If it matches a valid command then the appropriate code is executed to control the LCD. If not then USART_unget_char is used to push the key back. The most interesting commands in execute_command are #X and #Y which use get_and_Set_X and get_and_Set_Y, again using pointers (this time the address & de-reference is not used as px is a pointer that returns its address when invoked). These functions both use get_2dig_num which gets more characters expecting digits - if it does not get them it pushes the key back again using USART_unget_char. USART_get_char, USART_unget_charThese complementary functions are used in parsers (this program is a very small parser) where you need to look at the next character of the input to see if you want to continue. If you don't i.e. its not the character you were expecting then you use unget_char to put the current character into memory. get_char always checks this memory first before getting a character from its normal input so the system works well - but you can only do one ungetchar at a time. For more you would need an array of unget storage etc. The routines let you avoid complicated look ahead algorithms or indexing - you can concentrate on the current character without knowing where an index is. For a bigger parser you work with complete words. Jump from Serial LCD to Best Microcontroller Projects Home Page. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||