@sayzer
You have to read the piclist-mailist too, because there is the same thread, but there he wrote, that his "sensor" only gives him 3,7-4 volts.
@sayzer
You have to read the piclist-mailist too, because there is the same thread, but there he wrote, that his "sensor" only gives him 3,7-4 volts.
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
It is working now, The reference voltage on the Pic chip had to be change to 4 volt from 5 v.
thank you all
ken
Hi,
i will continue here and not start a new thread.
I am attempting to have two input values for an A/D conversion.
I added these two lines and did some changes.
How do I use the other input analog ports?
ken
' PicBasic Pro program to display result of
' 10-bit A/D conversion on LCD
'
' Connect analog input to channel-0 and channel1 (RA0, RA1)
' Define LCD registers and bits
Define LOADER_USED 1
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
right var word 'Create right to store result
left var word
TRISA = %11111111 ' Set PORTA to all input
TRISB = 0
ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
ADCON0 = %00000001 ' 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
ADCIN 0, right 'Read channel 0
ADCIN 1, left 'Read channel 1
right.highbyte = ADRESH 'move HIGH byte of result to right
right.lowbyte = ADRESL 'move LOW byte of result to right
left.highbyte = ADRESH 'move HIGH byte of result to left
left.lowbyte = ADRESL 'move LOW byte of result to left
Lcdout $fe, 1 'Clear screen
Lcdout "Value right: ", DEC right 'Display the decimal value
Lcdout $C0, "Value left: ", DEC left 'Display the decimal value
Pause 100 'Wait .1 second
Goto loop 'Do it forever
End
the program still displays the first value at channel 0 , but not a the other channel 1.
k
Remove these parts from your code
ADCON0.2 = 1 'Start Conversion
notdone: pause 5
if ADCON0.2 = 1 Then notdone 'wait for low on bit-2 of ADCON0, conversion finished
and
right.highbyte = ADRESH 'move HIGH byte of result to right
right.lowbyte = ADRESL 'move LOW byte of result to right
left.highbyte = ADRESH 'move HIGH byte of result to left
left.lowbyte = ADRESL 'move LOW byte of result to left
---------------------------------
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Here, inside a forum for PicBasic Pro-Compiler, it is allowed to use some of his commands.Originally Posted by lerameur
ADCIN 0,left
ADCIN 1,right
...will do the job for you.
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Lcdout $C0, "Value left: ", DEC left 'Display the decimal value
use this for the second line:
Lcdout $FE, $C0, "Value left: ", DEC left 'Display the decimal value
Bookmarks