I thought I was calling the A/D of my controller by using ADCON and ADCIN...
ken
I thought I was calling the A/D of my controller by using ADCON and ADCIN...
ken
mainly I just want to use this program but convert it
in picbasic pro and have a LCD out of the input.
‘***Real A to D on the 876****
program RealAtoDSafe
Dim data1 as word
Main:
TrisB = %00000000
TrisA = %00001000
ADCON1 = %10000100
while TRUE
data1=Adc_Read(3)
If data1 < 4 Then
data1 = 4
End If
PortB = word(data1 >> 2)
wend
End.
‘***************************
Come on lerameur,
"Dim data1 as word"
You are also not using PBP!
-----------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Like I said, I want to use this program but convert it into PBP
So from basic to PBP
I know that this is a pogram that compiles good with microbasic, but I want to use PBP.
K
Ken,
you have written parts of this thread also to the PicList-mailinglist. Just try to understand the answers there !
I think you have 2 problems in 1 thread:
1. talking to a LCD by 8 data-lines
2. Using the AD-modul of a 16F876A
1.:
You have to wire PortB.0 until PortB.7 to the signals DB0 to DB7 of the LCD. The E-, RS- and RW-signal can be set to any free digital portpin !
2.:
my writing from the PicList:
-----
Ken,
you have to make clear, what ports you are using. This is important !
First you tried PortC.0 as AN4 - wrong,
then you changed it to PortA ? What pin ?
Now you use an unknwon language and refers to channel 3.
So,
make it easy for us to write your program.
What Port-Pin is connected to the analog input ?
-----
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
well I do not want to start a new thread.
Mainly,I thought that I needed 8 bit to LCD since I wanted 8 bit analog input, but that is not the case, SO I will stay at 4 bit to LCD. which works fine.
Just my A/D conversion is not working. I have een playing around with ADCON0 AND ADCON1. I looked into PBP manual but no reference of ADCON0, AND THERE IS LITTLE on the spec sheet.
DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 0 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
' Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000000
ADCON0 = %00000101
Low PORTB.2 ' LCD R/W line low (W)
Pause 500 ' Wait .5 second
loop: ADCIN 4, adval ' Read channel 4 to adval
Lcdout $fe, 1
Lcdout "Value: ", DEC adval
Pause 100
Goto loop
End
end
as far as port I am using .
RB4 to RB7 out to LCD
RB0 RB1 as enable and register select bit
RA analog input
k
Bookmarks