Once again, we can't guess wich PIC you're using so try one or all of the following lines
CMCON=7
ADCON1=7
ADCON1=$0F
ANSEL=0
ANSELH=0
if any of ADCON or ANSEL setting work... you may discover something interesting and NEVER EVER use POT command![]()
Once again, we can't guess wich PIC you're using so try one or all of the following lines
CMCON=7
ADCON1=7
ADCON1=$0F
ANSEL=0
ANSELH=0
if any of ADCON or ANSEL setting work... you may discover something interesting and NEVER EVER use POT command![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Now you have to forget POT but use ADCIN instead. Just your POT on your PORTA, no capacitor in serie.
Your PIC have ADCs AND analog comparator on PORTA... it's useless to use POT.
Datasheet section 12.0 and 13.0.
You need to disable the comparator first.. something is right in my previous thread about that.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
well the adcon1 I used before doing some A/d conversion.
I also tried setting the port to output using the Tris command. NOthing works.
Also, I guess when you say I donthave to use the Pot command you are refering to making A/D conversion ??
k
Probably you have disable the ADCs but not the comparator? Both have to be disable.
And yes i'm talking about doing a A/D conversion... that's already built-in, free and far better than POT
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
by just using a pot on that pin, wont I have to use a voltage divider. If I just put a pot, then it will the same voltage and the convertion will be the same.
Right now with this I am getting weird characters on the lcd.
I did not touch portB..
To disable I guess by using the ADCON1 = 0 it is disable (bit 2 and 3)
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
B0 var byte
Start:
TRISA = 3 ' Set PORTA to all input
ADCON1 = 0 ' PORTA is analog
ADCIN 0, B0 ' Read channel 0 to B0
Lcdout $fe, 1 'Clear screen
Lcdout "Pot: ", Dec B0 'Display the decimal value
Pause 300
Hi Lerameur,Originally Posted by mister_e
I think we gave mister_e a headache tonight, The data sheet chap. 5, 12, 13 makes mention of these. Get it here if you do not have.
Cheers
JS
http://www.microchip.com/stellent/id...cName=en010243
Last edited by Archangel; - 24th November 2006 at 08:29.
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 08: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
Bookmarks