View previous topic :: View next topic |
Author |
Message |
omallicha
Joined: 15 Aug 2007 Posts: 5
|
hOW TO DISABLE vREF PINS |
Posted: Wed Sep 26, 2007 10:41 am |
|
|
HI i am using a PIC 18f8720 and what to disable the Vref pins (RA2 and RA3) i only want to use them as analogue inputs. Can anyone please advice.
thankx |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Sep 26, 2007 11:11 am |
|
|
The options for the Analog pins are setup with this CCS function:
The values that can be used with that function are given near the end
of the 18F8720.H file. Look in that file.
There are settings to select a range of pins to be A/D pins.
Also, the 18F8720.H file lists some settings to enable the Vref pins.
So to disable Vref, just select this constant:
Actually, because that constant is equal to 0x00, you could just leave it
out.
Both of these lines of code will do the same thing. They setup pins
AN0 to AN3 as analog pins, and they disable Vref.
Code: |
setup_adc_ports(AN0_TO_AN3);
setup_adc_ports(AN0_TO_AN3 | VSS_VDD );
|
|
|
|
omallicha
Joined: 15 Aug 2007 Posts: 5
|
|
Posted: Wed Sep 26, 2007 11:14 am |
|
|
thanks for the suggestion, i will try that shortly, and will keep you updated |
|
|
omallicha
Joined: 15 Aug 2007 Posts: 5
|
|
Posted: Wed Sep 26, 2007 11:26 am |
|
|
Hi,
i tried out your suggestion but im still having problems, the actual problem is that i have about 4 a/d inputs A0,A1,A2 and A3, i noticed that when i increase the voltage input of A2 the input values of A1 increases even though there is no connection to the PIN and it has a pull down resistor to ground. i was under the impression that it was due to the Vref+ please correct me if im wrong and advise.
thanks |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Sep 26, 2007 11:52 am |
|
|
Two questions:
1) Does the pull down resistor meet the imput impedance requirements of the A/D?
2) Are you waiting the required settling time between changing A/D channels?
Either of these can make voltage seem to leak from one channel to another. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
omallicha
Joined: 15 Aug 2007 Posts: 5
|
|
Posted: Wed Sep 26, 2007 1:18 pm |
|
|
Quote: | Does the pull down resistor meet the imput impedance requirements of the A/D?
|
The pin was designed to be an input from a pressure sensor(0-5v) but because of the unavailability of the senor, i temporaryly connected a 1k resistor to ground. this was because i wanted to keep the value at 0v which seemed not to be working.
Quote: | Are you waiting the required settling time between changing A/D channels?
|
i am actually delaying for 10us.
Code: | setup_adc_ports(AN0_TO_AN3 | VSS_VDD );
SETUP_ADC( ADC_CLOCK_INTERNAL );
SET_ADC_CHANNEL( 1 );
delay_us(10);
filter_sensor1 = READ_ADC();
delay_cycles(1);
filter_sensor =(filter_sensor1*k); |
|
|
|
|