6 Ekim 2013 Pazar

'12F675 otomatik şarj pbp dosyası
' Connect analog input to channel-3 (RA4)
 include "modedefs.bas"
'Define OSCCAL_1K 1 ' Calibrate internal oscillator
     DEFINE LOADER_USED 1
DEFINE  OSC     4
@ DEVICE pic12F675,xt_osc,mclr_off
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS


b0 Var GPIO.0 ' TX pin
role var gpio.1

raw    var  word  'ADC den okunan ham Digital değer.
VOLT   var  word '16 bit değişken tipi seçtik kullanacağımız değer 10 bit olacak.
Mvolt    var  byte


ADCON0.7 = 1 ' Right justify result
ANSEL = 000100 ' Set AN2 analog, rest digital
CMCON = 7 ' Analog comparators off

Pause 500 ' Wait .5 second for LCD to init

loop:
ADCIN 2, raw



'***************Bu 3 satır iyi durumda****************
'Volt=(Raw*/1250)/100
'MVolt=Volt//10 ' Mvolt = Volt mod 10
'Volt=Volt/10
'*************************************
 Volt=(Raw*/5000)/100
MVolt=Volt//10 ' Mvolt = Volt mod 10
Volt=Volt/10




'Serout b0, N2400, ["DC Volts= ", #volt,".", #mvolt,10,13]   'sayac olarak düzenli
  Serout b0, N2400, ["DC Volts= ", #volt,".", #mvolt,10,13]   'test halinde
Pause 100 ' Wait .1 second
 
   'if volt>=4 and mvolt>=2 then  'şimdilik iyi
   if volt>=4 and mvolt>=2     then
   low role
   else
   high role
   endif

 
    GoTo loop ' Do it forever

End

0 yorum:

Yorum Gönder