Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem in adc using 18f4520

Status
Not open for further replies.

HARIS RASHID

Newbie level 4
Joined
Jul 19, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,334
hi
i have problem in adc part in pic 18f4520.my code is not working mean that when i vary the input analog voltage outputs are not change.can anyone help me plz








Device = 18F4520
Xtal=20
LCD_DTPin PORTD.4
LCD_RSPin PORTD.3
LCD_ENPin PORTD.2
Adin_Res 10 ' Set the resolution to 10
Adin_Tad FRC ' Choose the RC osc for ADC samples
Adin_Stime 100 ' Allow 100us for charge time
ADCON1 = %00001101 ' Set PORTA analog and right justify result
ADCON2=%10000111
Input PORTA.1
Dim raw As Word
Dim v As Float
Print Cls
Loop:
raw=ADIn 1
Print At 1,1,"Raw:", Dec4 raw
v=(5/1023)* raw
Print At 2,1,"volt:", Dec3 v
DelayMS 2000
GoTo Loop

Symbol LED1 = PORTD.0 'Pin where data is to be transmitted


Symbol LED2= PORTD.1

While 1 = 1 ' Loop forever

If raw< 256 Then '25% of Vdd

High LED2
Low LED1

ElseIf raw >256 And raw <1024 Then '50% of Vdd

High LED1
Low LED2
Else

Low LED2
Low LED1

EndIf
DelayMS 500 ' Wait for .5 second
Wend
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top