U

12 Bit ADC okuma

Başlatan umitco, 06 Mayıs 2012, 11:22:04

umitco

  Arkadaşlar  12 Bit veya üstü ADC entegreyle veya 12 Bit ADC si olan bir işlemciyle okuma yapan oldumu hiç ?  MCP3201 adında bir entegre aldım ama çalıştıramadım. Eğer sizin denediğiniz ve çalıştırdığınız bir entegre varsa denemek isterim...

Hattuşa

slm
elimde mcp3201 ver ve ben bunu nasıl çalıştıracağımı öğrenemedim, bununla ilgili yardımcı olabilirmisiniz?
Device 18F4520
Xtal 10
Config_Start
   OSC = HSPLL ; HS oscillator, PLL enabled (Clock Frequency=4 x FOSC1)
   PWRT = On ; PWRT enabled
   BOREN = OFF ; Brown-out Reset disabled in hardware and software
   WDT = OFF ; WDT disabled (control is placed on the SWDTEN bit)
   MCLRE = On ; MCLR pin enabled; RE3 input pin disabled
   Debug = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
Config_End
Declare PLL_Req TRUE '40mhz

Declare LCD_DTPort =PORTD
Declare LCD_RSPin =PORTB.2
Declare LCD_ENPin =PORTB.0
Declare LCD_RWPin =PORTB.1
Declare LCD_CS1Pin =PORTB.4
Declare LCD_CS2Pin =PORTB.3
Declare LCD_Type =GRAPHIC
Internal_Font = On
Font_Addr = 0
Declare GLCD_CS_Invert =0
Declare GLCD_STROBE_DELAY = 100

Declare PortB_Pullups =Off
All_Digital yes



Dim adres1 As Word
Dim var1 As Byte

Symbol cs PORTA.0
Symbol di PORTA.1
Symbol ck PORTA.2

TRISA=%00000010
TRISB= %00000000
TRISC=%000000000
TRISD=%00000000
TRISE=%00000000
PORTA=0
PORTB=0
PORTC=0
PORTE=0
PORTD=0
DelayMS 1
Cls
DelayMS 100

Set cs'deselect chip
Clear ck'low clock

loop:

Call convert
Print At 1,1,Dec adres1," "

DelayMS 100
GoTo loop
'--------------------
convert:
Clear cs'start conversion
DelayUS 1

'2 clock for conversion & 1 clock for null bit

For var1 = 0 To 2 step1
Set ck
DelayUS 80
Clear ck
DelayUS 80
Next
Call capture ' this capture msb bit-11

For var1 = 0 To 10
Set ck
DelayUS 80
Clear ck
DelayUS 80
Call capture
Next
Set cs 'deselect chip
'now adres contains your 12 bit data
Return


capture:
If di = 1 Then
Clear STATUS.0
adres1 = adres1 << 1
Set adres1.0
Return
Else
Clear STATUS.0
adres1 = adres1 << 1
EndIf
Return

End
Include "FONT.INC"


adres isimli değişkeni direk adres diyerek yazınca hata veriyor. adres1 yapıyorum sonuç 0 çıkıyor, sanırım mantığını çözemedim
yardımcı olabilirmisiniz

a.zorba


Hattuşa


Powered by EzPortal