Using Nokia LCD


Closed Thread
Results 1 to 40 of 301

Thread: Using Nokia LCD

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Here is an include file that has been modified from many peoples code in this thread, and Darrel's PrintStr function, for the nokia-3310. It allows for very simple printing to the LCD.

    You can also print different things on the same line, by using the x, and y, positions.

    example:
    Code:
    DEFINE OSC 48
    
    include "modedefs.bas"
    include "LCD_3310.pbp"
    start:
    
    @ PrintStr  0,0, "I love being"
    @ PrintStr  0,1, "able to print "
    @ PrintStr  0,2, "so easily!"
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Very nice! Now printing to Nokia LCD is definitely easier.
    Thank You and Darrel!

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Hi again !
    Based on the schematic from post #119 I wrote the code from the thermostat ; but nothing happening when I push button on pin 7, or 8, or 9. I know that something is wrong, but I need help...Thanks in advance for every reply !
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Hello fratello,

    Can you tell us if there are any parts that do work? It is always easier to trouble shoot if you know where to start.

    Like:
    Can it blink an LED, or are we unsure if it is even starting up?
    Does it print to the LCD, and just not give you the temperature, or is the LCD blank?

  5. #5
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thanks for reply !
    The display show like in picture from post #116. But pushing the buttons '+' , '-' or 'Mode' has no effect.

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Hello Fratello,

    I have been looking over your code for a while now. I have not found anything obvious to me, although there may be something obvious to others.

    One thing I did notice, is that your MainLoop will cycle through modes 0, 1, and 2, even without any buttons being pressed. This is fine, but one thing you are doing in mode 2, and after mode 2, is writing to the eeprom. At 4 mhz, you will reach that 1,000,000 write cycles quicker than you think (have not calculated it, but if this is really going to be a thermostat, I assume it is going to be running for a while). A better way to do it would be to only write the targettemp, etc to the eeprom when targettemp is different than the eeprom value for targettemp (ie, it has been adjusted).

    Seems like the next step is to see if the 16f628a even knows if the buttons have been pressed. Why not make a simple light an LED line inside some of your if then statements to verify the chip knows a button has been pressed? This could help point to the source of the problem.

    Walter

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    The code works PERFECT with LCD 2x16...I just try to insert the parts for Nokia display...(and removing, of course, the parts for other display). I think the problems are generated by wrong 'substitution'. Thanks anyway for reply !

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi fratello, Do you have pullup resistors on those switches ? You do not have WPU enabled, so you need them, or change the Option_Reg, to enable them.
    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.

  9. #9


    Did you find this post helpful? Yes | No

    Default speedoometer+code lock with 3310 lcd

    I want make digital code lock + speedometer with pic and 3310 lcd
    Plz help me for code in picbasic
    On the meter then first code lock on if code don then speedometer on
    And distance save in pic internal eeprom


    Tahir maqsood

  10. #10
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default ?

    Based on code that I post at #155, it is possible to use BIG fonts like in this example : http://users.picbasic.org/Howto/PPRI...t%20update.pdf ? Of course, just display the temperature, with big font, without others graphical elements... The commands are in Proton+ ,but it's possible to use with PBP ? What are You thinking ? Thanks in advance for every repply !

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default bitmap fonts

    It looks possible. You would have to create custom characters for the 3310. Some helper bitmap font editors are available, like http://www.crystalfontz.com/forum/showthread.php?t=3619 to help you write the code for each character. How big are you wanting to go?. The link I showed goes to 10 x 14. But a font like this 10x14 (just look at fonts on this link) is bolder http://www.ageta.hu/pdf/gw64x16C-K610a-03.pdf. But perhaps you want even larger?
    Last edited by ScaleRobotics; - 5th April 2010 at 16:56.

  12. #12
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Please take a look at this ideea :
    -in picture I figure how increase the size of characters ;
    -in the code I try to explain how I see the problem.
    Suggestions ? Thanks !
    Code:
    ' So I define the normal characters : 
                       DATA @10,$3E,$51,$49,$45,$3E,_       ';// 0                
                                $00,$42,$7F,$40,$00,_       ';// 1    
                                $42,$61,$51,$49,$46,_       ';// 2    
                                $21,$41,$45,$4B,$31,_       ';// 3    
                                $18,$14,$12,$7F,$10,_       ';// 4    
                                $27,$45,$45,$45,$39,_       ';// 5    
                                $3C,$4A,$49,$49,$30,_       ';// 6    
                                $01,$71,$09,$05,$03,_       ';// 7    
                                $36,$49,$49,$49,$36,_       ';// 8    
                                $06,$49,$49,$29,$1E,_       ';// 9    
                                $08,$08,$3E,$08,$08,_       ';// +    
                                $08,$08,$08,$08,$08,_       ';// -    
    ' and display the temperature :
    '================= setting cursor for display the temperature 
                    LcdReg  =  %10100000 + 22       ' cursor  X
                    call    PrintCtrlLcd
                    LcdReg  =  %01000010            ' cursor  Y
                    call    PrintCtrlLcd
    '================= now display temperature                  
                    Char = (temperature dig 3)            
                    call    PrintChar
                    Char = (temperature dig 2)           
                    call    PrintChar
                    Char = 14                       ' this is decimal point           
                    call    PrintChar
                    Char = (temperature dig 1)      
                    Call    PrintChar 
    '
    'here I try to display with BIG font :
    '===============================================
    ' try to define BIG zero :
                       DATA @10,$1F,$1F,$66,$66,$61,_       ';// the 1/4 left-down  part of zero
                                $7C,$7C,$03,$03,$43,_       ';// the 1/4 left-up    part of zero
                                $43,$33,$33,$7C,$7C,_       ';// the 1/4 right-up   part of zero
                                $61,$60,$60,$1F,$1F,_       ';// the 1/4 right-down part of zero
                                
    ' and display the temperature :
    '================= setting cursor for display the temperature 
                    LcdReg  =  %10100000 + 22       ' cursor  X
                    call    PrintCtrlLcd
                    LcdReg  =  %01000010            ' cursor  Y
                    call    PrintCtrlLcd
    '================= now display temperature                    
                    Char = ??????????           
                    call    PrintChar
                    Char = ??????????       
                    call    PrintChar
                    Char = ??????????                       ' redefine of decimal point           
                    call    PrintChar
                    Char = ??????????    
                    Call    PrintChar
    Attached Images Attached Images  

  13. #13
    Join Date
    Apr 2008
    Location
    Lisbon-Portugal
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Increase the size of characters

    Have you see the code of the post #82?

  14. #14
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default Great job, indeed !

    ... but, please, on my code for simple thermometer, can You tell me how re-define the characters and how to display ? Just with BIG characters ! Thanks in advance, even for a little clue ...
    Code:
    '*********************************************
    '               Thermometer 
    '          with Nokia 3310 display
    @ DEVICE pic16F628A, XT_OSC, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF       
    
    DEFINE  NO_CLRWDT 1
    DEFINE  OSC 4                            
    
            TRISB = %00001110        'portB configuration  ; 0=out 1=in
            TRISA = %10100010        'portA configuration
    
            PortA = %11100010        
            CMCON = 7                
            VRCON = 0                
            INTCON = 0              
            OPTION_REG = %00000111   '
                        
    RST         var  PortA.4         'pin 3   Output   reset display
    SDIN        var  PortA.3         'pin 2   Output   master data out        
    SCK         var  PortA.2         'pin 1   Output   Spi clock
    DQ          var  PortA.1         'pin 18  I/O      DQ DS18b20    
    D_C         var  PortB.0         'pin 6   Output   command/data sel. register
    
                
                temperature     var  Word	
                tref            var  word
                TempC           var  Byte
                Float           var  Byte
                Dummy           var  Byte
                Flag            var  Byte          
                SignBit         var  Flag.0
                Minus           var  Byte                   
                LcdReg          var  Byte        
                x               var  Byte
                y               var  Byte
                Offset          var  Byte
                Char            var  Byte
                a               var  Byte
                PosX            var  Byte
                PosY            var  Byte
                Chr             var  Byte
                LcdData         var  Byte
                V               var  Word		 
                Sign            var  Byte
                Busy            VAR  BIT         ' Busy Status-Bit
    
    DS18B20_12bit 	CON %01111111                  ' 750ms,   0.0625°C  
    
    
    '====================================================================           
                    
         DATA @10,$7E,$91,$89,$85,$7E,_       ';// 0        
                  $00,$82,$FF,$80,$00,_       ';// 1    
                  $82,$C1,$A1,$91,$8E,_       ';// 2     
                  $42,$81,$89,$89,$76,_       ';// 3    
                  $18,$14,$12,$FF,$10,_       ';// 4    
                  $4F,$89,$89,$89,$71,_       ';// 5    
                  $7E,$89,$89,$89,$72,_       ';// 6    
                  $01,$E1,$11,$09,$07,_       ';// 7    
                  $76,$89,$89,$89,$76,_       ';// 8    
                  $46,$89,$89,$89,$7E,_       ';// 9 
                  $08,$08,$3E,$08,$08,_       ';// +   10
                  $08,$08,$08,$08,$08,_       ';// -   11
                  $00,$C0,$C0,$00,$00         ';// .   12
    
    '====================================================================           
                  pause 100
                  RST = 1
                  PortB = 0                      
                  LcdReg  =  %00100001        'LCD Extended Commands.
                  call    PrintCtrlLcd
                  LcdReg  =  $C8              'Set LCD Vop (Contrast)
                  call    PrintCtrlLcd
                  LcdReg  =  %00000110        'Set Temp coefficent.
                  call    PrintCtrlLcd
                  LcdReg  =  %00010011        'LCD bias mode 1:48.
                  call    PrintCtrlLcd
                  LcdReg  =  %00100000        'LCD Standard Commands, Horizontal addressing mode.
                  call    PrintCtrlLcd
                  LcdReg  =  $0C              'LCD in normal mode.  $0D inverse
    
    Call  PrintCtrlLcd                 
    Call 	CursorHome               
    Gosub LCD_Clear
    
    '====================================================================
    
    OWOut DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
     Output DQ             			            ' Make Pin Output
     DQ=0					                          ' OneWire line Low
     PauseUs 480                            ' Keep down for 480 µS  
     Input DQ                               ' Make Pin Input
     PauseUs 70                             ' Wait 70 µS
    
    OPTION_REG.7=1
    TMR0=0
    INTCON.2=0
    
    
    W1: 
        OWIN DQ,4,[busy]                     'Check for still busy converting
        IF busy = 0 THEN W1                  'Still busy?, then loop
    
    
    CALL BorderLine
    
    
    '====================================================================
    
    Main:  
    ClockLoop: IF INTCON.2=0 THEN ClockLoop
    INTCON.2=0
    CALL BorderLine
    
    
     OWOut DQ, 1, [$CC, $44] 
     OWOut DQ, 1, [$CC, $BE]
     OWIn DQ, 2, [temperature.byte0, temperature.byte1]         
                    SignBit = 0
                    if  temperature.15 then  
                        temperature  = ~ temperature + 1 
                        SignBit = 1 
                    endif  
                    
    Dummy = 625 * Temperature
    TempC = DIV32 10
    TempC = (Temperature & $7FF) >> 4
    Float = ((Temperature.Lowbyte & $0F ) * 25 )>>2
    Temperature=TempC*100 + Float         
     	If SignBit then
      		V= 10000 - Temperature   	' 25'C=12500  0'C=10000  -10'C=9000 
      		SignBit = 0
     	   else
      		V= 10000 + Temperature
     	EndIf
     
    	If V >= 10000 then             	' Above 0 C.      
      		Temperature=V-10000                   
     	   else                                   
      		Temperature=10000-V      	' Below 0 C. 
     	EndIf
     
     GoSub SelectSign                    	' +/blank/- Sign 
    
    '================= setting cursor for display the temperature 
         LcdReg  =  %10001000                 ' cursor  X
            call    PrintCtrlLcd
         LcdReg  =  %01000010 + 1             ' cursor  Y
            call    PrintCtrlLcd
    '================= now display temperature 
                        if Tempc > 99 then 
                            Char = 3                
                            call    PrintChar
                        else    
                            Char = 12                        ' + plus
                            if SignBit = 1 then Char = 13    ' - minus
                            call    PrintChar
                        endif                  
                    
                    Char = (temperature dig 3) + 2            
                    call    PrintChar
                    Char = (temperature dig 2) + 2           
                    call    PrintChar
                    Char = 14                       
                    call    PrintChar
                    Char = (temperature dig 1) + 2      
                    Call    PrintChar 
                    Char = (temperature dig 0) + 2      
                    Call    PrintChar
    
    goto Main
    
    
    '================== S U B R O U T I N E S ===========================   
               
    '========================== L C D ===================================             
    
    CursorHome:     LcdReg  =  %10000000      ' cursor Home
                    call    PrintCtrlLcd
                    LcdReg  =  %01000000      ' cursor Home
                    call    PrintCtrlLcd
                    return
    
    PrintChar:   offset = Char * 5          
                 
                    for a = 1 to 5                
                        read offset, LcdReg
                        call  PrintDataLcd
                        offset = offset + 1
                    next a
                    LcdReg = 0
                    call    PrintDataLcd
                    return
                                        
    PrintCtrlLcd:   D_C = 0                             
    
    PrintDataLcd:   for x = 1 to 8                
                        SDIN = LcdReg.7              
                        SCK = 1
                        LcdReg = LcdReg << 1
                        SCK = 0
                    next x               
                    D_C = 1
                    return               
                    
    LCD_Clear:
      PosX=0:PosY=0:GOSUB LCD_GotoXY
      HIGH D_C
      FOR Chr=1 TO 252
          LcdData=0:GOSUB LCD_ByteOut
          LcdData=0:GOSUB LCD_ByteOut
      NEXT Chr
    RETURN
    
    LCD_GotoXY:
      LOW D_C
      LcdData=%01000000 | PosY :GOSUB LCD_ByteOut
      LcdData=%10000000 | PosX :GOSUB LCD_ByteOut
    RETURN
    
    LCD_ByteOut:
      SHIFTOUT SDIN,SCK,1,[LcdData]
    RETURN         
    
    '====================================================================
    SelectSign:
     If v = 10000 then                      	' Temperature = 0 C.
      	Sign=" " 				      ' No sign
         Else 
      		If v < 10000 then             ' <> 0
       			Sign="-"			    ' Temperature below 0 C.	
      		    Else
       			Sign="+"			    ' Temperature above 0 C.
      		EndIf
     EndIf
    Return
    
    
    BorderLine: 
    ' Raw 0
    ' Raw 1             
    ' no space for post code here 
    Return                          
    
    '=================================== 
    End        'of program

  15. #15
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    You might try something like this. The characters you show as an example could be simplified to fit into half the space, but this allows you to smooth the characters if you like. I did not smooth them, just kept to your example font, so hopefully you can see what I am trying to do. Each hex data point of the character is basically a binary image of the column. It starts at the base of the character, but since our character is going to take 4 character positions, our zero starts at half of the 16 pixels high. So the left column of the top of the zero is 11111100 (or $FC) all the 1's are black. As you can see, it takes a long time to make the characters. There may be a tool out there somewhere to make this easier for you. Hopefully you just need numbers!

    The building of the characters are shown on the data sheet for the display on pages 8-9, and 22-23.
    Code:
    FA VAR BYTE[5] 'upper left of character
    FB VAR BYTE[5] 'upper right of character
    FC VAR BYTE[5] 'lower left of character
    FD VAR BYTE[5] 'lower right of character
    
    '-------------------------------------------------------------------------------    
    ' This part demonstrates how to write to LCD
    Lcd_SendChar:
        lookdown Lcd_data,[" !\#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"],CharNum
        Lcd_data = CharNum +32
        
        SELECT CASE lcd_data
    
        Case 48 ' a zero                   
        	FA(0)=$FC:FA(1)=$FC:FA(2)=$3:FA(3)=$3:FA(4)=$C3 ' // 0
        	FB(0)=$C3:FB(1)=$33:FB(2)=$33:FB(3)=$FC:FB(4)=$FC ' // 0  
        	FC(0)=$0F:FC(1)=$0F:FC(2)=$33:FC(3)=$33:FC(4)=$30 ' // 0
        	FD(0)=$30:FD(1)=$30:FD(2)=$30:FD(3)=$0F:FD(4)=$0F ' // 0  
        Case 49 ' a one                  
    
        
        end SELECT
    Write_LCD:
        High Lcd_DC
        SHiftOUT Lcd_SDO , Lcd_CLK , MSBFIRST, [ FA(0),FA(1),FA(2),FA(3),FA(4)] 'upper left
    'need to point to next position here
        SHiftOUT Lcd_SDO , Lcd_CLK , MSBFIRST, [ FB(0),FB(1),FB(2),FB(3),FB(4),$00,$00] 'upper right
    'need to add code to change location to lower left position for bottom of character here!
        SHiftOUT Lcd_SDO , Lcd_CLK , MSBFIRST, [ FC(0),FC(1),FC(2),FC(3),FC(4)] 'lower left
    'need to add code to change to next position
        SHiftOUT Lcd_SDO , Lcd_CLK , MSBFIRST, [ FD(0),FD(1),FD(2),FD(3),FD(4),$00,$00] 'lower right
    'need to add code to move back to upper level (and shift right) for beginning of next character
        Low Lcd_DC
        Return
    Attached Images Attached Images  
    Last edited by ScaleRobotics; - 7th April 2010 at 03:05.

  16. #16
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Hey Bill,

    I think this might be a version issue for Mpasm, or PBP, but really not sure. I get a nicely compiled result at 2312 words for your version of include file.

    I can fit 96 more bytes in RAM, so there is a bit more left, but as you can see, my program is small.

    Name:  3310-size.PNG
Views: 7121
Size:  62.7 KB
    Last edited by ScaleRobotics; - 12th July 2010 at 06:39.

  17. #17


    Did you find this post helpful? Yes | No

    Default 3310_lcd_code_lock

    i am new in pbp i want this schematic code in pbp
    and step by step detail this code for learning purpose
    plz any body help me

    Thanks
    Attached Images Attached Images  

  18. #18
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default If you really want to learn...

    Quote Originally Posted by tahirmaqsood View Post
    i am new in pbp i want this schematic code in pbp
    and step by step detail this code for learning purpose
    plz any body help me

    Thanks
    Here you go....

    Step 1: Don't ask people to write all your code for you and expect to learn a thing from it.
    Step 2: Read the manual.
    Step 3: If the project is over your head, start with something you can do, with some work.
    Step 4: Blink some LED's to start off, then try progressing to bigger projects.
    Step 5: Take a look at http://www.picbasic.co.uk/forum/showthread.php?t=12677 for inspiration. Someone working hard and learning fast.

    With time and effort, you will be able to return to the project you are yearning for.

    Walter
    http://www.scalerobotics.com

  19. #19
    Join Date
    Oct 2010
    Posts
    413


    Did you find this post helpful? Yes | No

    Default Re: If you really want to learn...

    hello all,

    i'm trying to compile a program based on 16f628a and nokia LCD 3310.

    I'm trying to right a simple program just to print a HELLO WORLD on the nokia LCD but no luck.

    My problem is that when i try to INCLUDE "LCD_3310v4.inc" i get an error that cannot open the inc file.

    Also when i open the file in the microcode studio (the LCD_3310v4.inc file) i get the error "Symbol not previously defined EEADRH"

    Do you have any suggestion please?

    many thanks for your help in advance.

  20. #20
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default Re: Using Nokia LCD

    This is causing your EEADRH problem.
    Code:
    Readcode Addr, Char
    Easiest way to go forward is comment or remove following parts of the code:
    Code:
    @ printstr macro function from Darrel and edited to work for this lcd
    'format should look like this: @ PrintStr x,y, "your text string goes here"
    Meaning StringOut and ASM-part above it.
    This is disabling string printing function, so you should figure out other ways to put stuff on LCD.

    Those who know better why READCODE doesn't work with 628A could answer to you.
    Even better if some workaround is available.

    BR,
    -Gusse-
    Last edited by Gusse; - 2nd June 2011 at 22:52. Reason: Just editing

Similar Threads

  1. Nokia COLOR LCD PicBasicPro 2.50a example code
    By skimask in forum Code Examples
    Replies: 49
    Last Post: - 28th September 2011, 01:43
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts