Tip varijable za preciznost 0,1

Rasprava o AVR mikrokontrolerima, AVR projekti i drugo vezano za AVR...

Moderators: pedja089, stojke369, trax, InTheStillOfTheNight

User avatar
bob4
Stariji član
Stariji član
Posts: 2572
Joined: 31-01-2010, 16:12
Location: Kutina

Re: Tip varijable za preciznost 0,1

Post by bob4 »

Evo dijelovi programa za termostat, pa se snađi: (ps. ne dozvoljava mi cijeli program staviti :azdaja: )

Code: Select all

   Config 1wire = P1.0
   Config Lcd = 16 * 2
   Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6 = P1.6 , Db7 = P1.7 , E = P1.3 , Rs = P1.2
   Declare Sub Citaj1820

   Dim Temperatura As String * 6 , Temperatura_alarm As String * 6

   Dim Bd(9) As Byte
   Dim T As Single , T1 As Single , Tmp As Byte , Cc As Bit
   Dim Pali As Single , His As Single , Plus As Single
   Dim Broj_rada As Byte , Rad As Bit


   S1 Alias P3.2
   S2 Alias P3.3
   S3 Alias P3.4
   Pali = 23
   His = 0.1
   Plus = 0.2
   P1.1 = 0
   Cc = 0
   Rad = 0
   Broj_rada = 0
'-------------------------------------------------------
 

'--------------------------------------------------
Do
   Call Citaj1820
   Temperatura = Fusing(t , ###.#)
   Temperatura_alarm = Fusing(pali , ###.#)

      Cls
      Upperline
      Lcd Temperatura_alarm ; Chr(0)
      Locate 1 , 10
      Lcd Chr(3) ; " " ; Temperatura ; Chr(0)
       Lowerline
       If Cc = 1 Then
       Lcd "Noc"
       End If

       Locate 2 , 15
       Lcd Broj_rada
      Debounce S1 , 0 , Noc , Sub
      Debounce S2 , 0 , Dodaj , Sub
      Debounce S3 , 0 , Oduzmi , Sub

 Loop

 '--------------------------------------------------
 Sub Citaj1820
         1wwrite &HCC : 1wwrite &H44 : Waitms 250 : Waitms 250 : 1wreset
   1wwrite &HCC : 1wwrite &HBE
   Bd(1) = 1wread(9) : 1wreset
            Tmp = Bd(1) And 1
         If Tmp = 1 Then
         Decr Bd(1)
         End If
   T = Makeint(bd(1) , Bd(2))
   T = T * 50
   T = T - 25
   T1 = Bd(8) - Bd(7)
   T1 = T1 * 100
   T1 = T1 / Bd(8)
   T = T + T1
   T = T / 100

' palenje bojlera

'----------------------------------------------------------
 Dodaj:
 Do
 Pali = Pali + Plus
 Gosub Prikaz
 If S2 = 1 Then                                               'ako je tipka otpuštena
  Return                                                      ' izađi iz sub
  End If
 Loop
Return
'----------------------------------------------------------
 Oduzmi:
 Pali = Pali - Plus
 Gosub Prikaz
  If S3 = 0 Then
 Gosub Oduzmi
  End If
 Return

'----------------------------------------------------------
 Prikaz:
       Temperatura_alarm = Fusing(pali , ###.#)
       Cls
      Upperline
      Lcd "Namjestanje temp"
       Lowerline
       Lcd "Radi od " ; Temperatura_alarm ; Chr(0)
       Wait 1

 Return
STIPA
Penjem se :)
Penjem se :)
Posts: 75
Joined: 22-03-2006, 15:58

Re: Tip varijable za preciznost 0,1

Post by STIPA »

Hvala svima na pomoći i trudu, shvatio sam što me zanimalo i naučio nešto novo.
Post Reply