Selamat datang di ForSa! Forum diskusi seputar sains, teknologi dan pendidikan Indonesia.

Welcome to Forum Sains Indonesia. Please login or sign up.

April 23, 2024, 09:14:34 PM

Login with username, password and session length

Topik Baru

Artikel Sains

Anggota
Stats
  • Total Tulisan: 139,653
  • Total Topik: 10,405
  • Online today: 167
  • Online ever: 1,582
  • (Desember 22, 2022, 06:39:12 AM)
Pengguna Online
Users: 0
Guests: 115
Total: 115

Aku Cinta ForSa

ForSa on FB ForSa on Twitter

nilai adc ngacak karena noce

Dimulai oleh ompewe, Oktober 15, 2012, 10:46:08 PM

« sebelumnya - berikutnya »

0 Anggota dan 1 Pengunjung sedang melihat topik ini.

ompewe

newbia gan numpang gabung, bawa masalah ;D
saya punya program buat voltage monitoring dengan atmega 16 pake program bascom masalahnya hasil output yg ditampilkan di adc ngacak sepertinya karena ada noise, nah ane bingung perintah ngilangin noisenya. tolong dibantu ya gan, nie sourcenya sapa tau bisa benerin





$regfile = "m16def.dat"
$crystal = 8000000
Config Portc = Output
Config Portb = Input
Config Portd = Output
Config Portb = 1
Portb.0 = 1
Portb.1 = 1
Portb.2 = 1
Portb.3 = 1
Portb.4 = 1
Portd.0 = 0
Portd.1 = 0
Porta.0 = 0
Porta.1 = 0
Porta.2 = 0

Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5
Db6 = Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0 
Config Lcd = 20 * 2                                         
Cls                                                         
Cursor Off
Waitms 100
Config Adc = Single , Prescaler = Auto , Reference = Avcc   
Start Adc
Dim R As Word
dim S As Word
Dim T As Word
Dim Bat_fact As Single
Dim Bat_voltr As Single

Dim Bat_volts As Single
Dim Bat_voltt As Single
    Bat_fact = 300 / 1023
Do
   R = Getadc(0)
   S = Getadc(1)
   T = Getadc(2)                                           
   Bat_voltr = R * Bat_fact
   Bat_volts = S * Bat_fact
   Bat_voltt = T * Bat_fact
       Locate 1 , 1
        Lcd "R="
       Lcd Fusing(bat_voltr , "##.##") ; "V"
       Locate 1 , 12
      Lcd "S="
      Lcd Fusing(bat_volts , "##.##") ; "V"
      Locate 2 , 1
      Lcd "T="
      Lcd Fusing(bat_voltt , "##.##") ; "V"
        Waitms 50
   If Pinb.0 = 0 And Bat_voltr < 224.4 And Bat_volts < 224.4 And Bat_voltt < 224.4 And Bat_voltr > 215.6 And Bat_volts > 215.6 And Bat_voltt > 215.6 Then
   Portd.0 = 1
   Else
   Portd.0 = 0
   If Pinb.1 = 0 And Bat_voltr < 231 And Bat_volts < 231 And Bat_voltt < 231 And Bat_voltr > 209 And Bat_volts > 209 And Bat_voltt > 209 Then
   Portd.0 = 1
   Else
   Portd.0 = 0
   If Pinb.2 = 0 And Bat_voltr < 235.4 And Bat_volts < 235.4 And Bat_voltt < 235.4 And Bat_voltr > 204.6 And Bat_volts > 204.6 And Bat_voltt > 204.6 Then
   Portd.0 = 1
   Else
   Portd.0 = 0
   If Pinb.3 = 0 And Bat_voltr < 242 And Bat_volts < 242 And Bat_voltt < 242 And Bat_voltr > 198 And Bat_volts > 198 And Bat_voltt > 198 Then
   Portd.0 = 1
   Else
   Portd.0 = 0
   If Pinb.4 = 0 And Bat_voltr < 250 And Bat_volts < 250 And Bat_voltt < 250 And Bat_voltr > 180 And Bat_volts > 180 And Bat_voltt > 180 Then
   Portd.0 = 1
   Else
   Portd.0 = 0

   End If
   End If
   End If
   End If
   End If

   If Portd.0 = 1 Then
   Locate 2 , 12
   Lcd "NORML"
   Waitms 500
   Portd.1 = 0
   Else
   Locate 2 , 12
   Lcd "ALARM"
   Waitms 500
   Portd.1 = 1
   End If
Loop
End