AD converter....

Status
Not open for further replies.

just angel

New Member
Hello every body... Hope you all are in good health...

I have these codes and I need an explanation of it...(line by line)....

can any ony anwer my question?

This is the program, it is for converting A/D for 8-bits:

--------------------------------------------------------------------------------------

' PicBasic Pro program to display result of
' 8-bit A/D conversion on LCD
'
' Connect analog input to channel-0 (RA0)

' Define LCD registers and bits
DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTE
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTE
DEFINE LCD_EBIT 1

adval VAR BYTE ' Create adval to store result


TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000010 ' Set PORTA analog and LEFT justify result
ADCON0 = %11000001 ' Configure and turn on A/D Module
Pause 500 ' Wait .5 second


loop: ADCON0.2 = 1 ' Start Conversion

notdone: Pause 5
IF ADCON0.2 = 1 Then notdone ' Wait for low on bit-2 of ADCON0, conversion finished

adval = ADRESH ' Move high byte of result to adval

LCDOut $fe, 1 ' Clear screen
LCDOut "Value: ", DEC adval ' Display the decimal value

Pause 100 ' Wait .1 second

GoTo loop ' Do it forever
End
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…