PIC 12F629 - DS1820 - NOKIA LCD

Rasprava o PIC mikrokontrolerima, PIC projekti i drugo vezano za PIC-eve...

Moderators: pedja089, stojke369, [eDo], trax

Post Reply
flash005
Posts: 16
Joined: 30-12-2008, 21:28

PIC 12F629 - DS1820 - NOKIA LCD

Post by flash005 »

Pozdrav svima,
Napravio sam pločicu za Nokia LCD Termometar od Ivana Novakovića, Sve radi perfektno osim jedne male sitnice koja je meni početniku veliki problem :D.
Ovaj program je koliko sam ja skonto pisan za temperaturni senzor DS18B20 koji koristi 12 bita za očitavanje temperatute, a ja imam DS1820 koji radi sa 9 bita. Sad bi trebao prepraviti program da koristi 9 bita za očitavanje temperature. Da ne ispadne da se nimalo nisam potrudio, napisao sam u mikroC-u program koji radi bez problema ali je prevelik za ovaj pic zato sam odlučio iskorisitti kod od novkivića ali ne razumim baš picBasic pa ako netko može da mi objasni kako da mi ovo proradi.

Code: Select all

'****************************************************************
'*  Name    : Nokia LCD Termometar                              *
'*  Author  : Novakovic Ivica                                   *
'*  Notice  : Copyright (c) 2004 [Elektronika Kifo]             *
'*          : All Rights Reserved                               *
'*  Date    : 9.10.2004                                         *
'*  Version : 1.0                                               *
'*  Notes   : Pic12F629 , Nokia3310 Lcd & DS18B20               *
'*  e-mail  : ivica.novakovic@vz.t-com.hr                       *
'*  url     : http://fr*e-vz.t-com.hr/Ivica-Novakovic/          *
'****************************************************************

            Define    NO_CLRWDT 1
                                                  
            D_C      var     GPIO.0
            rst      var     GPIO.1            
            DQ       var     GPIO.2
            Mode     var     GPIO.3
            SDIN     var     GPIO.4
            SCK      var     GPIO.5
            
            temperature     Var     Word            
            TempHigh        var  temperature.highbyte
            count_remain    Var  Byte            
            count_per_c     Var     Byte            
            TempH           var  byte
            TempL           var  byte
            Bitovi          var  byte
            Predznak        var  Bitovi.0
            Skala           var  byte[4]
            Minus           var  Byte
                    
            LcdReg          var  byte        
            x               var  byte
            y               var  byte
            z               var  byte
            Offset          var  byte
            Char            var  byte
            a               var  byte
            
'-------------------------------------------------------------------------------            
                CMCON = 7
                TrisIO = 0
                GPIO = 0
'-------------------------------------------------------------------------------            
                
                    DATA @0,$3E,$51,$49,$45,$3E,_       ';// 0                   Podaci zapisani u EEPROM
                            $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,_       ';// -
                            $00,$60,$60,$00,$00         ';// .


                   data @65,$FF,$01,$01,$E1,$11,$89,$49,$49,$C9,$49,$09,$C9,$49,$49,$09,$09,_         'prvi dio slike
                            $09,$09,$11,$E1,$01,$19,$19,$19,$F9,$F9,$F9,$19,$19,$19,$81,$C1,_
                            $E1,$21,$E1,$E1,$C1,$01,$E1,$E1,$E1,$41,$E1,$E1,$C1,$61,$E1,$E1,_
                            $C1,$01,$E1,$E1,$E1,$41,$E1,$E1,$C1,$01,$01,$01,$01,$01,$01

'-------------------------------------------------------------------------------            
                 
                 
           
                RST = 1
                            
                LcdReg  =  %00100001          'LCD Extended Commands.
                call    PrintCtrlLcd
                LcdReg  =  %10101001          '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
                
                call CursorHome
                Call TableTemp

Main:                
                LcdReg  =  %00001100                            'LCD in normal mode.  -    ovisi o položaju jumpera
                if Mode = 1 then  LcdReg  =  %00001101          'LCD in inverse mode.
                call    PrintCtrlLcd
                
     
                OWOut DQ, 1, [$CC, $BE]           ' pročitaj temperaturu iz DS18B20
                OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c]
                Predznak = 0
                if  TempHigh.7 = 1 then  temperature  =  (~ temperature) + 1 : Predznak = 1 
                TempH = temperature >> 4
                Templ = temperature.lowbyte & $0f
                Temperature = templ * 625
                
      
                OWOut DQ, 1, [$CC, $44]         ' Start konverzije temperature   ( 12 bit.- trajanje oko 700ms )
                
                LcdReg  =  %10000000 + 12       ' cursor  X
                call    PrintCtrlLcd
                LcdReg  =  %01000011            ' cursor  Y
                call    PrintCtrlLcd

                if TempH > 99 then             ' ako je temp. veca od 99'C, umjesto plusa napisi "1"
                        Char = 1                ' stotice
                        call    PrintChar
                else    
                        Char = 10                       ' + plus
                        if Predznak = 1 then Char = 11  ' - minus
                        call    PrintChar
                endif
                        
                Char = (temph dig 1)            ' desetice
                call    PrintChar
                Char = (temph dig 0)            ' jedinice
                call    PrintChar

                Char = 12                       ' točka
                call    PrintChar

                Char = (temperature dig 3)      ' prva decimala
                Call    PrintChar
                
                call MinusNaSkali               ' ako je temperatura " minus " , nacrtaj minuse na skali
                    
                    skala[0] = $ff
                    skala[1] = $ff
                    skala[2] = $ff
                    skala[3] = $ff
                
                 if temph > 32 then goto PrintSkala
                 temph = 32 - temph
                    
                    
                    for y = 1 to temph 
                     skala[0] =  skala[0] << 1
                    next y
                    for y = 9 to temph
                     skala[1] =  skala[1] << 1
                    next y
                    for y = 17 to temph
                     skala[2] =  skala[2] << 1
                    next y
                    for y = 25 to temph
                     skala[3] =  skala[3] << 1
                    next y
                        
PrintSkala:                
                for y = 0 to 3
                    call SetCursor
                        LcdReg  = skala[y]
                        call    PrintDataLcd
                next y
                
                
                nap 6                           ' sleep 1,152 sec.
                Goto main
                        

SetCursor:      LcdReg  =  %10000000 + 76       ' cursor  X
                call    PrintCtrlLcd
                LcdReg  =  %01000001 + y        ' cursor  Y
                call    PrintCtrlLcd
                return
                
                
'-------------------------------------------------------------------------------
MinusNaSkali:   minus = 0 
                if predznak = 1 then Minus = $04
                LcdReg  =  %10000000 + 63       ' cursor  X
                call    PrintCtrlLcd
                LcdReg  =  %01000000 + 3        ' cursor  Y        minus ispred 10
                call    PrintCtrlLcd
                
                LcdReg = Minus
                call  PrintDataLcd
                LcdReg = Minus
                call  PrintDataLcd
                
                
                if predznak = 1 then Minus = $01
                LcdReg  =  %10000000 + 61       ' cursor  X         minus ispred 20
                call    PrintCtrlLcd
                LcdReg  =  %01000000 + 2        ' cursor  Y
                call    PrintCtrlLcd
                
                LcdReg = Minus
                call  PrintDataLcd
                LcdReg = Minus
                call  PrintDataLcd
                
                Minus = $01
                if predznak = 1 then Minus = $41
                LcdReg  =  %10000000 + 61       ' cursor  X           minus ispred 30
                call    PrintCtrlLcd
                LcdReg  =  %01000000 + 0        ' cursor  Y
                call    PrintCtrlLcd
                
                LcdReg = Minus
                call  PrintDataLcd
                LcdReg = Minus
                call  PrintDataLcd
                
                return
'-------------------------------------------------------------------------------                

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
                                    

@ org 0x21C
TableTemp: 
                 for y = 65 to 127
                    read y, LcdReg
                    call  PrintDataLcd
                 next y
                 
                 for y = 0 to 194     ' drugi dio slike
                      
                  LOokup y, [$01,$A1,$11,$51,$A1,$01,$E1,$11,$11,$E1,$01,$81,$41,$41,$41,$81,$01,_      
                                $01,$01,$01,$FF,$FF,$00,$00,$FF,$00,$21,$20,$3C,$23,$06,$39,$60,_
                                $80,$A3,$BD,$2B,$2D,$33,$80,$FF,$00,$00,$00,$00,$0F,$0F,$0F,$00,_
                                $00,$00,$03,$07,$0F,$0D,$0D,$0D,$05,$00,$0F,$0F,$0F,$00,$0F,$0F,_
                                $0F,$00,$0F,$0F,$0F,$00,$3F,$3F,$3F,$04,$0F,$0F,$07,$00,$0C,$0C,_
                                $00,$00,$00,$04,$84,$45,$45,$84,$04,$84,$45,$45,$84,$00,$FF,$00,_
                                $00,$00,$FF,$00,$84,$04,$00,$FF,$FF,$00,$00,$00,$E1,$F2,$12,$12,_
                                $12,$12,$12,$12,$12,$12,$12,$12,$12,$13,$13,$13,$10,$10,$08,$04,_
                                $02,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,$01,_
                                $01,$01,$01,$01,$01,$01,$81,$81,$81,$01,$01,$01,$01,$01,$01,$01,_
                                $01,$01,$01,$FE,$00,$00,$00,$10,$14,$16,$15,$14,$10,$13,$14,$14,_
                                $13,$00,$FF,$00,$00,$00,$FF,$00,$10,$10,$00,$FF,$FF,$00,$00,$00,_
                                $FF,$FF] ,LcdReg
                     call  PrintDataLcd
                next y
                
                
                      LcdReg = 0      
                  for y = 1 to 40
                      call  PrintDataLcd
                  next y
                   
                  for y = 0 to 205     ' treci dio slike
                  
                  LOokup y, [$03,$02,$03,$00,$00,$3E,_
                            $41,$41,$41,$23,$00,$00,$00,$FF,$00,$00,$00,$40,$40,$40,$41,$5F,_
                            $40,$4E,$51,$51,$4E,$00,$FF,$00,$00,$00,$FF,$00,$42,$40,$00,$FF,_
                            $FF,$00,$40,$C0,$47,$47,$46,$86,$06,$06,$06,$06,$06,$86,$C6,$06,_
                            $86,$46,$46,$86,$06,$46,$C6,$46,$46,$86,$06,$86,$46,$46,$86,$06,_
                            $86,$46,$46,$86,$06,$06,$06,$86,$46,$86,$06,$06,$06,$06,$06,$46,_
                            $C6,$46,$46,$86,$06,$46,$06,$06,$06,$06,$02,$01,$80,$C0,$00,$80,_
                            $40,$40,$80,$00,$40,$C0,$40,$40,$C0,$00,$FF,$00,$00,$00,$FF,$00,_
                            $08,$00,$00,$FF,$FF,$80,$90,$9F,$90,$90,$90,$8F,$80,$92,$95,$89,_
                            $80,$80,$9F,$80,$8D,$92,$92,$8D,$80,$90,$9F,$92,$92,$8D,$80,$98,_
                            $94,$92,$99,$80,$8F,$90,$90,$8F,$80,$80,$80,$8E,$91,$92,$8D,$93,_
                            $80,$80,$80,$90,$9F,$92,$82,$81,$80,$9F,$80,$8E,$91,$91,$8A,$80,_
                            $80,$9F,$80,$98,$94,$92,$99,$80,$90,$9F,$92,$82,$80,$9E,$BF,$BF,_
                            $BF,$BF,$BF,$9E,$81,$81,$80,$FF] ,LcdReg
                   call    PrintDataLcd
                    next y
                    return
 
PrintCtrlLcd:   D_C = 0                             
PrintDataLcd:   for x = 1 to 8                ' ispis na Lcd 
                    SDIN = LcdReg.7              
                    LcdReg = LcdReg << 1
                    SCK = 1
                    SCK = 0
                next x               
                D_C = 1
                return
               
                
                end         
Kifo
Posts: 3
Joined: 30-09-2010, 09:11

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by Kifo »

Pozdrav,
u attachu imas hex file za DS1820, mozes isprogramirati PIC12F629 ili PIC12F675 sa ovim fajlom...kad nadjem vremena stavit ću i na svoju stranicu ove fajlove...
pozz
Attachments
TempLcd12F675-Ds1820.zip
(2.25 KiB) Downloaded 287 times
http://www.ivica-novakovic.from.hr/" onclick="window.open(this.href);return false;
flash005
Posts: 16
Joined: 30-12-2008, 21:28

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by flash005 »

Neradi ni ovaj hex sa mojim ds1820, pokazje mi temp +0.00 C.
Kifo
Posts: 3
Joined: 30-09-2010, 09:11

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by Kifo »

Pokusaj zamijeniti otpornik R1 sa 4K7.....a mozda ti je neispravan Ds...
http://www.ivica-novakovic.from.hr/" onclick="window.open(this.href);return false;
flash005
Posts: 16
Joined: 30-12-2008, 21:28

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by flash005 »

http://webspace.webring.com/people/fd/d ... 0schem.JPG" onclick="window.open(this.href);return false; evo shemu koju koristim, znači ovdje su umjesto 4.7 uF stavljeni kondenzatori od 10uF tako je i u mene, i radi mi sve normalno kada koristim pic 16f877A i čak sa pic 12f84, al nikako da proradi na 12f629, za ove piceve imam kod u mikro c-u koji mi radi bez problema al je problem kad ga kompajliram za pic 12f629 prevelik je a neznam ga smanjit :D.
flash005
Posts: 16
Joined: 30-12-2008, 21:28

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by flash005 »

Evo konačno sam našao malo vremena u napravio pločicu, i radi mi perfektno , al mi nikako nije jasno zašto temp senzor ds1820 neradi kada uređaj testiram na easy pic 4. Dali mi netko to može objasnit. hvala
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by pedja089 »

Premalo informacija da bi ti bilo ko dao konkretan odgovor, osim ili nesto nisi spojio kako treba ili nisi podesio jumpere i prekidace na ploci, ili softverska greska, ili ko zna sta...
flash005
Posts: 16
Joined: 30-12-2008, 21:28

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by flash005 »

Gore sam sve naveo, naime testiro sam temperaturni senzor na easy pic 4:
1. spoijo sam prema shemi koju sam gore posao, lcd od nokie 3310 na easy pic 4, isprogramiro pic 12f629, temperaturni senzor se već nalazi na ploči, ali je spojen na pinove ra5 ili re2 pa sam ga samo presvičo kablićem na pin koji meni treba (prema kifinoj shemi tj gp2), NEZNAM GDJE SAM POGRIJEŠIO. LCD JE RADIO BEZ PROBLEMA TJ PRIKAŽE MI SAMO SLIKU, A ZA TEMPERATURU POKAZUJE 0.05 STUPNJEVA ČINI MI SE
2. al kad sam testiro na uređaju radi bez problema. :S
User avatar
pedja089
Administrator sajta
Administrator sajta
Posts: 7876
Joined: 20-02-2007, 14:50
Location: Beočin -Srbija

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by pedja089 »

Moguce da na tim linijama postoji jos kojesta zakaceno, pa pull up ne moze da izgura dovoljno visok napon...
Opet ko nema easypic4 tesko da ti sta moze reci. Uzmi instrument u ruke pa to premeri sve kako valja i spada, pa ces onda znati...
buco-1
Napredujem
Napredujem
Posts: 105
Joined: 24-10-2010, 21:22

Re: PIC 12F629 - DS1820 - NOKIA LCD

Post by buco-1 »

flash005 wrote:...temperaturni senzor DS18B20 koji koristi 12 bita za očitavanje temperatute, a ja imam DS1820 koji radi sa 9 bita.
Koliko znam taj 12 bitni može učitavati i samo 9 bita, tj podešavaš rezoluciju softwareom. Moj ti je savijet da uzmeš dokumentaciju z taj IC, tmp. sensor, tamo ti je sve pojašnjeno i na osnovu toga napišeš driver za rezoluciju kaj ti treba i uživaš u svom termometru.
Obično demo programi ne sadržavaju kompletne mogućnosti sklopa već počesto samo jednu do dvije opcije.

Ja sam si napravio sličan uređaj, nokia LCD (3310), DS1820 (12 bitni) ali za ATm8. Trebao mi je za upravljanje s termo peći, s podesivom rezolucojom i kompletnom obradom znakova kao i posebno dizajniranih znakova i još nekih grafičkih dodataka.
Uzmeš nolikin Logo manager, napraviš sliku i transate-aš dobiveni kod na prihvatljiv 8 bitnom microračunalu pa dobiješ grafiku kakvu poželiš. Postaviš timere, više njih, razne upravljače funkcije da uređaj dobije neki smisao, upotrebljivost.
Pozdrav
Post Reply