yes I am printing them out and carefully reading them now.
But, i am curious, if I wanted to use the POT command, what do i have to do to read from port A?
k
yes I am printing them out and carefully reading them now.
But, i am curious, if I wanted to use the POT command, what do i have to do to read from port A?
k
lerameur,Originally Posted by lerameur
without actually doing it to verify it works . . .as I do not have a 16F88
put the three BOLD commands into your code to make the PortA pins digital and turn off the analog comparators
This should work.Code:CMCON=7 ' Disable comparators ANSEL=0 ' Set port as digital I/O ADCON1=7 TrisA = %11111111 'sets all port a as input TrisB = %00000000 ' sets all port b as output B0 var byte ' establishes a variable called B Start: Pot PortA.2,255,B0 ' would like PortA.2,175,B0 use number to suit you Lcdout $fe, 1 'Clear screen Lcdout $FE,$80,"Pot: ", #B0 'Display the numerical value Pause 300 goto start end
JS
Last edited by Archangel; - 24th November 2006 at 07:29.
Hi Lerameur. I have an 'F88 and this program works. The 'F88 has 5 ADC's which are better than using the pot command. I connected pin 17 (ana 0) to the center terminal of a 1 meg pot. The CCW terminal to ground, CW terminal to B+.
OSCCON = $60 'SET INT OSC TO 4MHZ
ANSEL = 0 'SELECT ANALOG INPUTS 0 = NONE AND ALL DIGITAL
ADCON0 = 0 'AD MODULE OFF & CONSUMES NO CURRENT
CMCON = 7 'COMPARATORS OFF
TRISA = %11111111 'PORTA INPUTS
TRISB = %00000000 'PORTB OUTPUTS
X VAR BYTE 'VARIABLE TO PUT POT VALUE
PORTB = 0 'ALL OUTPUTS LOW
START:
ADCIN 0, X 'READ VALUE ON ANA 0
IF X > 0 AND X <= 50 THEN LED1
IF X > 50 AND X <= 100 THEN LED2
IF X > 100 AND X <= 200 THEN LED3
IF X > 200 THEN LED4
GOTO START
LED1:
HIGH PORTB.0
PAUSE 1000
LOW PORTB.0
GOTO START
LED2:
HIGH PORTB.1
PAUSE 1000
LOW PORTB.1
GOTO START
LED3:
HIGH PORTB.2
PAUSE 1000
LOW PORTB.2
GOTO START
LED4:
HIGH PORTB.3
PAUSE 1000
LOW PORTB.3
GOTO START
I am going to try this today thanks.
I am following John Iovine,s book, he usesa F84a pic. He always uses the portB by default, I wanted to try using port A , but on a F88.
Also I was reading the command CMCON=7 meaning th three first bit are set to one. When I read the legend it says 1 is for Setting th bit, I would of first thought setting would be for setting for comparator mode.
k
Hi Lerameur,Originally Posted by lerameur
I have his book too, I thought that was where you got that code. He , in my opinion, left too many loose ends in his code as he neglected to put in all the needed little setup routines, like the trisa and trisb etc. he relies on pbp defaults
and that sorta leaves beginners out in the cold, if you do not rely on defaults and write in everything your code will always be usable and only require minor tweaking to port to other PICs
Cheers
JS
yes thats what I am beginning to realize too , lots of stuff missing in the book, then when you use another chip, I'm screwed.
Abou tthe A/D, doesn't that read a voltage ? whereas the Pot read a resistance ?
both cde works,
i am trying to figure out one thing now.
I am replacing this command line:
HIGH PORTB.0
PAUSE 1000
LOW PORTB.0
by this one:
serout 2,n9600,(2)
i am getting errors:
C:\PBP\POT_TRY.BAS ERROR Line 39: Bad expression.
C:\PBP\POT_TRY.BAS ERROR Line 33: ID LED2 is not a LABEL.
C:\PBP\POT_TRY.BAS ERROR Line 34: ID LED3 is not a LABEL.
C:\PBP\POT_TRY.BAS ERROR Line 35: ID LED4 is not a LABEL.
suddenly my labels are not labels ??
Bookmarks