PDA

View Full Version : Olympic timer Scroll Text



Patrick
- 14th December 2006, 13:44
I have programmed the pic and the timer is working fine
The problem is with the scrolling message at the beginning of the program
I use a 40 car LCD as the example is only 32
I asume it should make no difference
Im only getting black cursors and no scrolling text
Im trying to understand what Melanie have done but she is to clever for me
Any help will do

flotulopex
- 14th December 2006, 17:44
Hi Patrick,

Hope this helps. It is ment to work with a 16 digit display.


' Variable definition
CounterA var byte
CounterB var byte
CounterC var byte
DataA var byte

' String to be displayed
' 1 2 3 4
' 12345678901234567890123456789012345678901234
Data "Olympic Timer Powered by MeLabs PICBasic Pro" 'length = 44 charaters

' Start program
BANNER:
lcdout $FE, 1 'Clear LCD
pause 1000 'Time to initialise LCD

' This loop displays the first 16 characters of the string during 1 second = "Olympic Timer Po"
for countera = 0 to 15 'Setup a counter for 16 steps
read Countera, dataa 'Goto to memory location and read the character of the string
LCDOut DataA 'Display the current character
next
pause 1000 'Pause the first 16 characters to make them visible

' These two following loops make the text shift effect for 28 times (string is 44 character - 16 first characters already displayed = 28 characters to go)
' When CounterA is 0, we will display "lympic Timer Pow"
' When CounterA is 1, we will display "ympic Timer Powe"
' When CounterA is 2, we will display "mpic Timer Power"
' ....
For CounterA = 0 to 28 'This loop will shift the text for 28 times (44 - 16 = 28)
CounterC = CounterA + 15 'CounterC indicates the position of the first next character to be displayed
LCDOut $FE, $80 'Set the cursor Home (you can try "LCDOUT $FE, 1" or "LCDOUT $FE, 2" too)

' This loop reads the 16 characters to be displayed at that time
For CounterB = CounterA to CounterC 'CounterB will read 16 characters starting at character position "CounterC"
Read CounterB, DataA 'Goto to memory location and read the character of the string
LCDOut DataA 'Display the current character
Next

Pause 200 'Speed of display shift
Next

Pause 1000 'Keep the last 16 characters of the text ON during 1 second before restart

goto BANNER

end

Patrick
- 15th December 2006, 02:19
Thanks a mil
I will try to get it working

Patrick

Patrick
- 15th December 2006, 03:17
I have tried it an get similar behaviour to the orig program
Im using a bootloader,can his have influance as it might occupy the Data codespace
Im now more determant to get to the bottom of this
See include photo

mister_e
- 15th December 2006, 03:31
If you're using a Bootloader, be sure you place the following line at the top of your code

DEFINE LOADER_USED 1

if it doesn't work, post your whole code here, and tell us your PIC #, OSC speed, AND config fuses list you set when you loaded your bootloader firmware in your PIC.

One thing is sure, your LCD is not initialised properly.

Patrick
- 15th December 2006, 05:04
The code is as posted by flotulopex with the next as top of file:

@ DEVICE pic16F876, XT_OSC ' System Clock Options
@ DEVICE pic16F876, WDT_ON ' Watchdog Timer
@ DEVICE pic16F876, PWRT_ON ' Power-On Timer
@ DEVICE pic16F876, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F876, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F876, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F876, PROTECT_OFF
' Program Code Protection
@ DEVICE pic16F876, WRT_OFF ' Flash Memory Word Enable

DEFINE LOADER_USED 1 ' If using bootloader to program pic
DEFINE LCD_DREG PORTC 'Define PIC port used for LCD Data lines
DEFINE LCD_DBIT 0 'Define first pin of portc connected to LCD DC4
DEFINE LCD_RSREG PORTC 'Define PIC port used for RS line of LCD
DEFINE LCD_RSBIT 4 'Define Portc pin used for RS connection
DEFINE LCD_EREG PORTC 'Define PIC port used for E line of LCD
DEFINE LCD_EBIT 5 'Define PortC pin used for E connection
DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
DEFINE LCD_LINES 2 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.

sougata
- 16th December 2006, 12:33
Hi,

If you can get your lcd to respond atleast then please tryout the following code. You will be surprised.

I post a little program here and would like you guys to try it out U N-E D I T E D. Please use the LCD Defines as your config. You can use a 16/20 characters display if you wish. Steve would you mind explaining I am a little too drunk.



MAIN:
LCDOUT $FE,1
LCDOUT "MERRY CHRISTMAS AND HAPPY NEW YEAR 2007 "
LCDOUT $FE,$C0
LCDOUT "***FROM YOUR FRIEND SOUGATA IN INDIA****"
PAUSE 1000
LOOP:
LCDOUT $FE, $18
PAUSE 500
GOTO LOOP

flotulopex
- 16th December 2006, 12:52
Wow! Well done.

In the "LOOP:", let's go the other way: "LCDOUT $FE, $1C" - from the LEFT to the Right.

mister_e
- 16th December 2006, 13:03
LMAO! Well even drunk you got it ;) Take one of those...

http://www.mister-e.org/Pics/Beer_6pack.gif

Well explanation is easy, but i will make it simple and skip some information.

LCDOUT $FE,1
LCDOUT "MERRY CHRISTMAS AND HAPPY NEW YEAR 2007 "
LCDOUT $FE,$C0
LCDOUT "***FROM YOUR FRIEND SOUGATA IN INDIA****"

There you fill the LCD memory/buffer...plahplahplah

LOOP:
LCDOUT $FE, $18
PAUSE 500
GOTO LOOP

For this one, open a HD44780 LCD datasheet, and find the 'Cursor or display shift' Register. Now, read the S/C bit information. You don't like the way it move, set the R/L bit.

EDIT: Yup Flotulopex, you got it!