Hmm, a search came up with this on the Arduino forum.
http://www.arduino.cc/cgi-bin/yabb2/...num=1245352653
Shows what can be done using just a few segments. I really need to study this one though to use the LCD.
Hmm, a search came up with this on the Arduino forum.
http://www.arduino.cc/cgi-bin/yabb2/...num=1245352653
Shows what can be done using just a few segments. I really need to study this one though to use the LCD.
Does the datasheet for your LCD mention custom characters?
As far as I remember, you need a graphic LCD to do that. A character LCD only prints characters, unless it has a custom character feature.
Robert
Most character LCD's allow up to 8 custom characters. I have a 2x8 display on my kids aquariums showing water temp and you have to be very close to read it, this would be a neat way to make the characters larger.
Shawn
I thought about implementing this idea some time ago, but them I got discouraged when I read somewhere that these LCD displays only allow a few custom characters like spcw1234 mentioned above. However, looking at the arduino link above it looks like it can be done.
Robert
"No one is completely worthless. They can always serve as a bad example."
Anonymous
Darrel did it a long time back, I re posted his code here:http://www.picbasic.co.uk/forum/show...hlight=bignums
search for bignums to see other threads.
BTW Darrel gives credit to Scott Edwards . . .
http://www.picbasic.co.uk/forum/showthread.php?p=26736
http://www.picbasic.co.uk/forum/showthread.php?t=9736
Last edited by Archangel; - 8th January 2012 at 10:33.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
This is what I came up with using DT_INTS-18 timer routine. This is with a 2x16 display.
Code:'**************************************************************** '* Name : BigDigitTimer.BAS * '* Author : Shawn Newswanger * '* Notice : Copyright (c) 2012 * '* : All Rights Reserved * '* Date : 1/8/2012 * '* Version : 1.0 * '* Notes : PIC18F2221 with internal OSC * '**************************************************************** OSCCON=110000 'SET TO 8 MHZ define OSC 08 '8MHz oscilator define LCD_COMMANDUS 1500 'set command delay in us define LCD_DATAUS 50 'set data delay in us define LCD_DREG PORTC 'set LCD data port define LCD_DBIT 4 'set LCD starting data bit define LCD_RSREG PORTC 'define RS port define LCD_RSBIT 2 'define RS bit define LCD_EREG PORTC 'set LCD ENABLE port define LCD_EBIT 3 'set LCD ENABLE bit define LCD_BITS 4 'set LCD bits 4 or 8 define LCD_LINES 2 'set # of LCD rows 2 or 4 clear ADCON1 = 15 'all digital CMCON = 7 'turns off comparators trisc=0 trisb=0 trisa=0 nPos var byte nDig var byte 'CONFIGURE DISPLAY pause 100 ln1 con $80 ln2 con $C0 CS con 1 pause 500 LCDOUT $FE,1 'Set up the digits (http://www.darreltaylor.com/files/CustChar.htm) LCDOUT $FE,$40,$1F,$1F,$1F,$00,$00,$1F,$1F,$1F ' Cust Char #0 LCDOUT $FE,$48,$1F,$1F,$1F,$00,$00,$00,$00,$00 ' Cust Char #1 LCDOUT $FE,$50,$00,$00,$00,$00,$00,$1F,$1F,$1F ' Cust Char #2 LCDOUT $FE,$58,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F ' Cust Char #3 LCDOUT $FE,$60,$00,$0E,$0A,$0E,$00,$00,$00,$00 ' Cust Char #4 LCDOUT $FE,$68,$00,$00,$0E,$0A,$0A,$0E,$00,$00 ' Cust Char #5 LCDOUT $FE,$70,$00,$00,$04,$0A,$0A,$04,$00,$00 ' Cust Char #6 LCDOUT $FE,$78,$00,$00,$00,$00,$00,$00,$00,$00 ' Cust Char #7 'ELAPSED TIMER INCLUDE "DT_INTS-18.bas" INCLUDE "ReEnterPBP-18.bas" INCLUDE "Elapsed_INT-18.bas" ; Elapsed Timer Routines ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ClockCount, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts GOSUB ResetTime ' Reset Time to 0d-00:00:00.00 GOSUB StartTimer ' Start the Elapsed Timer lcdout $fe, CS ' Clear screen MAIN: 'Display time IF secondsChanged = 1 THEN secondsChanged = 0 nDig=minutes dig 1 : nPos=0 : gosub displaydigit ndig=minutes dig 0 : npos=4 : gosub displaydigit npos=7 : gosub colon ndig=seconds dig 1 : npos=8 : gosub displaydigit ndig=seconds dig 0 : npos=12 : gosub displaydigit ENDIF goto main displaydigit: if ndig=0 then gosub zero if ndig=1 then gosub one if ndig=2 then gosub two if ndig=3 then gosub three if ndig=4 then gosub four if ndig=5 then gosub five if ndig=6 then gosub six if ndig=7 then gosub seven if ndig=8 then gosub eight if ndig=9 then gosub nine return Zero: LCDOUT $FE,$80+nPos,3,1,3 LCDOUT $FE,$C0+nPos,3,2,3 return One: LCDOUT $FE,$80+nPos,1,3,7 LCDOUT $FE,$C0+nPos,2,3,2 return Two: LCDOUT $FE,$80+nPos,0,0,3 LCDOUT $FE,$C0+nPos,3,2,2 return Three: LCDOUT $FE,$80+nPos,1,0,3 LCDOUT $FE,$C0+nPos,2,2,3 return Four: LCDOUT $FE,$80+nPos,3,2,3 LCDOUT $FE,$C0+nPos,7,7,3 return Five: LCDOUT $FE,$80+nPos,3,0,0 LCDOUT $FE,$C0+nPos,2,2,3 return Six: LCDOUT $FE,$80+nPos,3,0,0 LCDOUT $FE,$C0+nPos,3,2,3 return Seven: LCDOUT $FE,$80+nPos,1,1,3 LCDOUT $FE,$C0+nPos,7,3,7 return Eight: LCDOUT $FE,$80+nPos,3,0,3 LCDOUT $FE,$C0+nPos,3,2,3 return Nine: LCDOUT $FE,$80+nPos,3,0,3 LCDOUT $FE,$C0+nPos,7,7,3 return colon: lcdout $fe,$80+nPos,5 lcdout $FE,$C0+nPos,5 return end![]()
Shawn
That looks great Shawn for my future projects but not for my timer.
I was incorrect about my display, I used a 2x16 as well but I need to display say, 123.45 so the thinner dual height figures are just what I want. I believe i can't use them anyway.
Melanies code is quite 'timing' critical as it should be, so I think adding the character code lookup would cause it's timing to be incorrect. I need to study it all again when I get time as I made this a year ago. I do believe there's an 'offset' in the code I can use to bring it back to correct timing I just need to experiment.
This is Melanies slightly modified code for seconds and hundreths, this uses a 16f628
Code:' Show Jumping Timer 2011 based on Olympic Timer by Melanie Newman ' 05/Aug/2004 ' Topical Program demonstrates use of Interrupt ' Driven Background TIMER, to time events down to ' one one-hundredth of a Second (1/100 Sec). ' ' Bonus CALIBRATION Feature allows simple adjustments ' in 360mS steps per hour. This calibration adjustment ' range is limited to +/- 36 seconds per Hour. ' ' This program is for 4MHz clock (1uS Timer Ticks). ' ' PIC Defines ' =========== ' ' Change these defines to suit your chosen PIC ' @ DEVICE pic16F628, XT_OSC ' System Clock Options @ DEVICE pic16F628, WDT_ON ' Watchdog Timer @ DEVICE pic16F628, PWRT_ON ' Power-On Timer @ DEVICE pic16F628, BOD_ON ' Brown-Out Detect @ DEVICE pic16F628, LVP_OFF ' Low-Voltage Programming @ DEVICE pic16F628, CPD_OFF ' Data Memory Code Protect @ DEVICE pic16F628, PROTECT_OFF ' Program Code Protection @ DEVICE pic16F628, WRT_OFF ' Flash Memory Word Enable ' ' Hardware Defines ' ================ ' ' LCD Display ' ----------- ' Adjust these to suit your chosen LCD pinout ' Define LCD_DREG PORTB ' Port for LCD Data Define LCD_DBIT 4 ' Use upper 4 bits of Port Define LCD_RSREG PORTB ' Port for RegisterSelect (RS) bit Define LCD_RSBIT 3 ' Port Pin for RS bit Define LCD_EREG PORTB ' Port for Enable (E) bit Define LCD_EBIT 1 ' Port Pin for E bit Define LCB_BITS 4 ' Using 4-bit bus Define LCD_LINES 2 ' Using 2 line Display Define LCD_COMMANDUS 2000 ' Command Delay (uS) Define LCD_DATAUS 50 ' Data Delay (uS) ' ' Control Buttons/Lines ' --------------------- ButStart var PortA.0 ' Take this pin low momentarily to START timing ButStop var PortA.1 ' Take this pin low momentarily to STOP timing ButReset var PortA.2 ' Take this pin low momentarily to RESET clock ' ' Hold the RESET Button pressed for at least FIVE seconds ' to jump into CALIBRATION Mode ' ' Software Defines ' ---------------- BannerOffset var BYTE ' Variable holding start address of Banner Display CounterA var BYTE ' Just a Counter CounterB var BYTE ' Just a Counter CounterC var BYTE DataA var BYTE 'Hours var BYTE Hundredths var BYTE 'Minutes var BYTE OverflowError var BIT RunningFlag var BIT Seconds var BYTE SetupTimeOut var WORD ' Timeout counter for Calibration/Set-Up Mode TMR1Cal var BYTE ' Calibration Value TMR1CalAR var Byte ' Calibration 0=ADVANCE, 1=RETARD TMR1RunOn var WORD ' variable holding TMR1 Run-On value ' ' EEPROM Presets ' -------------- Data @0,0 ' Advance/Retard Indicator Data 0 ' Calibration Value Data "Show Jumping Seconds Timer - Robert Lane 2011" ' ' Software Constants ' ------------------ TMR1CalMax con 100 ' Maximum adjustment (+/-100uS per 10mS interrupt) TMR1Preset con $D910 ' 10mS Timer Reload value, offset by 20uS ' to allow for TMR1 Setting Calculations ' ' Start Program ' ============= ' ' Initialise Processor ' -------------------- TRISA=000000 TRISB=000111 'TRISC=000000 ADCON0=000000 ADCON1=000111 OPTION_REG.7=0 ' Enable Pull-Up's RunningFlag=0 ' Disable actual Interrupt Time-Keeping Pause 1000 ' Pause for LCD to initialise ' ' Silly Intro Banner just for Fun ' ------------------------------- LCDOut $FE,1 ' Clear LCD BannerOffset=2:Gosub DisplayBanner Pause 2000 For CounterA=0 to 30 BannerOffset=2+CounterA Gosub DisplayBanner Pause 150 Next CounterA Pause 1000 ' ' Initialise TMR1 Interrupts ' -------------------------- Gosub SetTimer ' Set the Timer for next 10mS Interrupt On Interrupt goto TickCount PIE1.0=1 ' Enable TMR1 Interrupts INTCON.6=1 ' Enable all unmasked Interrupts INTCON.7=1 ' Enable Global Interrupts ' ' ----------------------------------------------------- ' Following the above "On Interrupt", no Basic Command ' is allowed that takes more than 10mS to execute ' otherwise the 10mS Interrupt interval is compromised. ' ----------------------------------------------------- ' ' Reset Timer Variables for Start ' ------------------------------- DisplayReset: LCDOut $FE,1 ' Clear LCD Read 0,TMR1CalAR ' Read Calibration Advance/Retard Indicator Read 1,TMR1Cal ' Read Calibration Value Hundredths=0 ' Reset Timer Counter variables Seconds=0 'Minutes=0 'Hours=0 OverflowError=0 ' ' Main Program Loop ' ================= Enable DisplayLoop: If ButStart=0 then RunningFlag=1 If ButStop=0 then RunningFlag=0 ' LCDOut $FE,$80,DEC2 Hours,":",DEC2 Minutes,":",DEC2 Seconds,".",DEC2 Hundredths LCDOut $FE,$80,DEC2 Seconds,".",DEC2 Hundredths If OverflowError=1 then If Seconds.0=1 then LCDOut $FE,$8C,"ERR" else LCDOut $FE,$8C," " endif endif If RunningFlag=1 then goto DisplayLoop If ButReset=1 then goto DisplayLoop Disable ' ' Reset Clock ' =========== ' Momentarily Press the Reset Button for RESET action. ' Continue holding the Reset Button for MORE than 5 seconds ' to jump into Calibration/Set-Up Mode ' ResetClock: LCDOut $FE,1,"Reset OK" Pause 1000 Seconds=1 While Seconds < 5 Pause 1000 If ButReset=1 then goto DisplayReset Seconds=Seconds+1 Wend ' ' Calibration Adjustment ' ====================== ' If No Button is Pressed for 20 Seconds, then the program ' will automatically exit Calibration/Set-Up Mode WITHOUT saving ' any new values. ' SetUpTimeout=0 Calibration: LCDOut $FE,1,"Calibrate: " While ButReset=0:Wend ' Wait for User to release finger CalibrationLoop: LCDOut $FE,$8B If TMR1Cal=0 then LCDOut " " else If TMR1CalAR=0 then LCDOut "+" else LCDOut "-" endif endif LCDOut #TMR1Cal," " ' ---------------------------------------------------------- ' Press Start Button to ADVANCE (speed-up) Clock ' Press STOP Button to RETARD (slow-down) Clock ' Press RESET Button to SAVE new Calibration Setting ' ---------------------------------------------------------- ' Remember each Calibration 'tick' will advance or ' retard the Timing by 1uS in every 10mS period - that's ' 360mS/Hour per setting. Example: A setting of +8 will ' SPEED-UP the Timer by 2.88 Seconds (8 x 360mS) in an Hour. ' ---------------------------------------------------------- If TMR1CalAR=0 then If ButStart=0 then Gosub CalAdvance If ButStop=0 then Gosub CalRetard else If ButStart=0 then Gosub CalRetard If ButStop=0 then Gosub CalAdvance endif If ButReset=0 then Write 0,TMR1CalAR Write 1,TMR1Cal LCDOut $FE,1,"Bye Rob" Pause 1000 Goto DisplayReset endif SetupTimeout=SetupTimeout+1 If SetupTimeout>200 then goto DisplayReset Pause 100 Goto CalibrationLoop ' ' Subroutine Increments Calibration Value ' --------------------------------------- CalAdvance: SetupTimeout=0 If TMR1Cal=>TMR1CalMax then TMR1Cal=TMR1cALmAX TMR1CalAR=TMR1CalAR^1 else TMR1Cal=TMR1Cal+1 endif Return ' ' Subroutine Decrements Calibration Value ' --------------------------------------- CalRetard: SetupTimeout=0 If TMR1Cal=0 then TMR1Cal=1 TMR1CalAR=TMR1CalAR^1 else TMR1Cal=TMR1Cal-1 endif Return ' ' Subroutine Displays Banner Intro ' -------------------------------- DisplayBanner: CounterC=BannerOffset+15 LCDOut $FE,$80 For CounterB=BannerOffset to CounterC Read CounterB,DataA LCDOut DataA Next CounterB Return ' ' Subroutine Loads TMR1 values ' ============================ SetTimer: T1CON.0=0 ' Stop the Clock TMR1RunOn.Highbyte=TMR1H ' Load the Run-On (Over-Run) value (if any) TMR1RunOn.Lowbyte=TMR1L TMR1RunOn=TMR1Preset+TMR1RunOn ' Calculate the New (adjusted) value for TMR1 If TMR1CalAR=0 then ' Calibration ADVANCE (add) or RETARD (subtract) TMR1RunOn=TMR1RunOn+TMR1Cal else TMR1RunOn=TMR1RunOn-TMR1Cal endif TMR1H=TMR1RunOn.Highbyte ' Save new values to TMR1 TMR1L=TMR1RunOn.Lowbyte T1CON.0=1 ' Restart the Clock PIR1.0=0 ' Reset TMR1's Interupt Flag Return ' ' Timer Interrupt Handler ' ======================= TickCount: Gosub SetTimer ' Set the Timer for next 10mS Interrupt If RunningFlag=1 then ' If timing actually enabled... then... Hundredths=Hundredths+1 ' Increment 10mS Seconds Counter If Hundredths>99 then Hundredths=0 Seconds=Seconds+1 ' Increment the Seconds -- Show Jumping to 500 If Seconds>500 then Seconds=0 endif ' Increment the Seconds ' If Seconds>59 then ' Seconds=0 ' Minutes=Minutes+1 ' Increment the Minutes ' If Minutes>59 then ' Minutes=0 ' Hours=Hours+1 ' Increment the Hours ' If Hours>99 then ' Handle any Overflow ' Hours=0 ' OverFlowError=1 ' endif ' endif ' endif endif endif Resume End
Bookmarks