merhaba arkadaşlar. Umarım dijital pot uygulamasını kullanarak yeni projeler üretirsiiniz. Maksadım bu uygulamaya bir örnek daha sunmak...sonuçta değişik entegreler ile değişik uygulamalaıda mevcut... Size en kolay olanı secmeniz adına bir seçenek daha sunuyorum..
['****************************************************************
'* Name : mcp41010.BAS *
'* Author : [ergunbt] *
'* Notice : Copyright (c) 2015 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 22.08.2015 *
'* Version : 1.0 *
'* Notes : mcp41010 dijital pot uygalaması *
'* : *
'****************************************************************
Device=16F877A
XTAL = 4
TRISA=%111111
ALL_DIGITAL = True
Symbol YUKARI= PORTA.0
Symbol ASAGI= PORTA.1
Symbol MODE= PORTA.2
Symbol CS10 = PORTB.3 ' CHIP SEÇ SECTİGİNİZ ENTGRENİN CS PİNİNE BAĞLA
Symbol CS20 = PORTB.4 ' CHIP SEÇ
Symbol CS30 = PORTB.5 ' CHIP SEÇ
Symbol CS40 = PORTB.6 ' CHIP SEÇ
Output CS10 ' CS10 ÇIKISINI AYARLA
Output CS20 ' CS20 ÇIKISINI AYARLA
Output CS30 ' CS30 ÇIKISINI AYARLA
Output CS40 ' CS40 ÇIKISINI AYARLA
Symbol SCK = PORTC.3 ' CLOCK PINI SCK PİNİ VE SI PİNİ 4 ENTEGREDE DE ORTAK
Symbol SI = PORTC.4 ' DATA IN PINI
Symbol SO = PORTC.5 ' DATA OUT PINI
Dim POT1 As Byte
Dim POT2 As Byte
Dim POT3 As Byte
Dim POT4 As Byte
Dim MOD As Byte
MOD=0
LOOP:
If MODE=0 Then
While MODE=0 :Wend
MOD=MOD+1
If MOD=4 Then MOD=0
EndIf
If MOD=0 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
POT1=POT1+10
If POT1>255 Then POT1=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
POT1=POT1-10
If POT1<5 Then POT1=0
EndIf
EndIf
If MOD=1 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
POT2=POT2+10
If POT2>255 Then POT2=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
POT2=POT2-10
If POT2<5 Then POT2=0
EndIf
EndIf
If MOD=2 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
POT3=POT3+10
If POT3>255 Then POT3=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
POT3=POT3-10
If POT3<5 Then POT3=0
EndIf
EndIf
If MOD=3 Then
If YUKARI=0 Then
While YUKARI=0 :Wend
POT4=POT4+10
If POT4>255 Then POT4=0
EndIf
If ASAGI=0 Then
While ASAGI=0 :Wend
POT4=POT4-10
If POT4<5 Then POT4=0
EndIf
EndIf
GoSub POT_YAZ ' DİJİTAL PORTA YAZ
GoTo LOOP
'================================================= ========
POT_YAZ:
CS10=0 ' AKTIF
CS20=0 ' AKTIF
CS30=0 ' AKTIF
CS40=0 ' AKTIF
SHOut SI, SCK, msbfirst, [$11,POT1]
CS10=1
CS10=0
CS10=1
SHOut SI, SCK, msbfirst, [$11,POT2]
CS20=1
CS20=0
CS20=1
SHOut SI, SCK, msbfirst, [$11,POT3]
CS30=1
CS30=0
CS30=1
SHOut SI, SCK, msbfirst, [$11,POT4]
CS40=1
CS40=0
CS40=1
Return
End]
Paylaşım için teşekkür ederiz.