12 Kasım 2013 Salı

Pic Basic Pro ile derlenmiş Pic 16F676 micro controller chip ile yapılmış
30 volta kadar ölçüm yapabilen,  3 digit 7 segment Led display voltmetre
BAS ve Hex dosyaları altta alabilirsiniz.

Mutlaka 7 segment led displayi ortak anod olması gerekiyor. Ortak katod olanı alırsanız devre şemasına ters düşer, led display çalışmaz.Çünkü besleme kaynağı +5V olarak ortak bağlantı yapılmıştır.

Pic16F676 ile Voltmetre Bas Dosyası  :

 device 16f676  
   xtal = 4
   Config CPD_OFF,CP_OFF,BODEN,MCLRE_OFF,PWRTE_ON,WDT_OFF,INTRC_OSC_NOCLKOUT,
   Declare  ADIN_RES  10       ' Set number of bits in result
   Declare ADIN_STIME 100
   DECLARE ADIN_TAD FRC
   DECLARE VCFG = 0 ' VREF is set to VDD of PICmicro
   DECLARE ADFM = 1 ' Right justify the ADC result
' Declare variables
Dim Adval as Word ' Create adval to store result
        'Delayms 500       ' Wait .5 second
        CMCON = 000111           ' disable comparators
        trisc = 0000
        CMCON = 7                   ' Turns off comparators
        ANSEL = 000001
        ADCON0 = %10010001          ' Set analogue input on PORTA.0   and right justify result
        ADCON1 = 001000          ' use porta.0
        trisa = $000001              
              ' Wait .5 second
        porta=0101
        PORTc=%111111
        delayms 500
     
begin: Adcin 0, Adval ' Read channel 0 to adval (0-1023)
        Adval = (Adval */ 500) >> 2 ' equates to: (adval * 500)/1024
        If adval<=100 Then gosub num1        'the thresholds for the different digits
        If adval<=100 Then gosub num2        ' 1 volts shows 1 on 7 Segment
        If adval<=200 Then GoTo num3        ' 2 volts shows 2  on 7 Segment
        If adval<=300 Then GoTo num4        ' 3 volts shows  3    on 7 Segment
        If adval<=320 Then GoTo num5
        If adval<=350 Then GoTo num6
        If adval<=375  Then GoTo num7
        If adval<=400 Then GoTo num88
        If adval<=420 Then Gosub num9
     
        goto begin

num1:
     porta=0001
     PORTc=%110000
     GoTo begin
num2:
     porta=0101
     portc=%011101
     GoTo begin
num3:
     porta=0101
     portc=%111100
     GoTo begin
num4:
     porta=0001
     PORTc=%110110
     GoTo begin
num5:
     porta=0101
     PORTc=%101110
     GoTo begin
num6:
     porta=0101
     PORTc=1110
     GoTo begin  
num7:
     porta=0001
     PORTc=1110
     GoTo begin
num88:
     porta=0101
     PORTc=%111111
        delayms 500
        porta=0001
        PORTc=0000
        delayms 500
     GoTo begin
num9:
     porta=0101
     PORTc=%111110
     GoTo begin
num0:
     porta=0101
     PORTc=%111110
     GoTo begin                
       
     End


Pic16F676 ile Voltmetre HEX Dosyası : 



:1000000000308A003C280000831A0A28A000030E52
:10001000A1000F288312A000030EA100A1140A085A
:10002000A8008A018313A00E0408A2005708A300A9
:100030005808A4005908A5005A08A6005B08A700A4
:1000400083128C308400001C27280C1858282208A2
:1000500084002308D7002408D8002508D9002608E2
:10006000DA002708DB0028088A00210E83008312AB
:10007000200EA11883160900FF238316900000307C
:100080008A00222A0A108A100A1182074034573443
:100090002234063415340C34083456340034043415
:1000A000FF340A108A100A11820702340134043422
:1000B000EC308F009A308E00273085003F3087006B
:1000C000000000002C08023C031CAC0129302C0766
:1000D00084000008870029302C078400000840397C
:1000E000D7000310570CD2002C085120073A5204B5
:1000F0008500AC0A0C108A11272807309900831656
:10010000050803308312D700D70B842819088C11F7
:100110001F1300300838831691001F129F161F17F7
:1001200083129F171F1418308316850027308312FF
:100130008500831687013730831287008530900051
:10014000EC308F009A308E00C0308B0483160C1474
:100150008312332A3330840000080319BE2801308B
:10016000D800D701D70BB228D80BB1284A30D70016
:10017000D70BB82800000000800BAF280034D7014F
:10018000D801D901DA01CB01CC01CD01CE014A0859
:100190004904480447040319FD282030CF00031008
:1001A000C30DC40DC50DC60DCB0DCC0DCD0DCE0DA3
:1001B0004A084E02031DE62849084D02031DE628A1
:1001C00048084C02031DE62847084B02031CF72889
:1001D0004708CB024808031C480FCC024908031CFF
:1001E000490FCD024A08031C4A0FCE020314D70D53
:1001F000D80DD90DDA0DCF0BCF2800004B3084007D
:1002000000342030CB00C701C801C901CA0142082F
:10021000DA004108D9004008D8003F08D700031091
:10022000571C20294308C70744080318440FC80770
:1002300045080318450FC90746080318460FCA07A3
:10024000CA0CC90CC80CC70CDA0CD90CD80CD70CCA
:10025000CB0B0F290034C201C101C0011E30BF0009
:100260003A08C6003908C5003808C4003708C3007A
:1002700001215A08C2005908C1005808C000570897
:10028000BF005A08C6005908C5005808C4005708DE
:10029000C300CA01C9012730C800F630C700BF201B
:1002A0005A08C3005908C2005808C1005708C000C6
:1002B0004220D800A9002908403C031D6129FF30D5
:1002C000A900C201C101C0011E30BF003A08C6002A
:1002D0003908C5003808C4003708C30001215A088E
:1002E000C2005908C1005808C0005708BF005A088A
:1002F000C6005908C5005808C4005708C300CA0101
:10030000C9012730C800F630C700BF200008BB0075
:10031000840A0008BC00840A0008BD00840A0008A2
:10032000BE00C201C101C0010A30BF003E08C600C4
:100330003D08C5003C08C4003B08C30001215A0821
:10034000C2005908C1005808C0005708BF005A0829
:10035000C6005908C5005808C4005708C300CA01A0
:10036000C9012730C800F630C700BF205A08C300B3
:100370005908C2005808C1005708C0004220D800E0
:10038000AA00C201C101C0010A30BF003E08C60078
:100390003D08C5003C08C4003B08C30001215A08C1
:1003A000C2005908C1005808C0005708BF005A08C9
:1003B000C6005908C5005808C4005708C300CA0140
:1003C000C9012730C800F630C700BF200008BB00B5
:1003D000840A0008BC00840A0008BD00840A0008E2
:1003E000BE00C201C101C0010A30BF003E08C60004
:1003F0003D08C5003C08C4003B08C30001215A0861
:10040000C2005908C1005808C0005708BF005A0868
:10041000C6005908C5005808C4005708C300CA01DF
:10042000C9012730C800F630C700BF205A08C300F2
:100430005908C2005808C1005708C0004220D8001F
:10044000AB00792A84011F3083051F130030073861
:1004500083169100073083129F007F30A900AA0005
:10046000AB00AC017D28B101B001AF01AE01B2011A
:100470003208133C031C5A2A0C30D8001F08C33919
:1004800058049F000130B300AA209F149F18462AE9
:1004900083161E088312AE071E0803181E0FAF072F
:1004A000003003180130B007003003180130B107E5
:1004B000B20A382A3108C6003008C5002F08C40027
:1004C0002E08C300CA01C901C8011430C700BF20EB
:1004D0005A08B6005908B5005808B4005708B300C8
:1004E0005A08BA005908B9005808B8005708B700A8
:0C04F0002B29C830B300AA20332A630077
:0207FE00443481
:02400E00C43FAD
:00000001FF
;PIC16F676

0 yorum:

Yorum Gönder