![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Francesc Guest
|
16F876 A/D problems |
Posted: Sun Sep 29, 2002 5:34 am |
|
|
Hi all,
I need use an A/D connect on pin RA5 (Pin 7) and view results on LCD display connect to Port A and Port B (RB0 to RB7) and (RA0 to RA2).
When I connect on RA5 the voltage source not is possible regulate 0 to 5Volts.The voltage move directly 0 to 5V and 5V to 0V.
Also, when I connect the voltage tester on pin RA5 ( when not is connect voltage source), I measure 5 Volts.
That is my program, I supose what not is correctly configurate.
#include<16f873.h>
#device ADC=10
#USE DELAY(CLOCK=4000000,RESTART_WDT)
#INCLUDE <LCD2.C>
#USE FAST_IO(A)
#USE FAST_IO(B)
#USE FAST_IO(C)
#BYTE PORT_C=7
MAIN()
{
SETUP_ADC(ADC_CLOCK_INTERNAL);
LCD_INIT();
PORT_C=0;
SET_TRIS_C(0X00);
while(1)
{
RESTART_WDT();
SET_ADC_CHANNEL(4);
TEMP=READ_ADC();
DISPLAY(); //Routines for display value on LCD
DELAY_MS(100);
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 7374 |
|
![](templates/subSilver/images/spacer.gif) |
Charlie U Guest
|
Re: 16F876 A/D problems |
Posted: Sun Sep 29, 2002 7:06 am |
|
|
:=Hi all,
:=I need use an A/D connect on pin RA5 (Pin 7) and view results on LCD display connect to Port A and Port B (RB0 to RB7) and (RA0 to RA2).
:=When I connect on RA5 the voltage source not is possible regulate 0 to 5Volts.The voltage move directly 0 to 5V and 5V to 0V.
:=Also, when I connect the voltage tester on pin RA5 ( when not is connect voltage source), I measure 5 Volts.
:=That is my program, I supose what not is correctly configurate.
:=
:=#include<16f873.h>
:=#device ADC=10
:=#USE DELAY(CLOCK=4000000,RESTART_WDT)
:=#INCLUDE <LCD2.C>
:=#USE FAST_IO(A)
:=#USE FAST_IO(B)
:=#USE FAST_IO(C)
:=#BYTE PORT_C=7
:=
:=MAIN()
:={
:= SETUP_ADC(ADC_CLOCK_INTERNAL);
:= LCD_INIT();
:= PORT_C=0;
:= SET_TRIS_C(0X00);
:=
:= while(1)
:= {
:= RESTART_WDT();
:= SET_ADC_CHANNEL(4);
:= TEMP=READ_ADC();
:= DISPLAY(); //Routines for display value on LCD
:= DELAY_MS(100);
:= }
:=}
Please review section 11.0 of the F87x data sheet. This section explains the configuration limitations of the ADC. If you only want 1 analog input, it must be AN0 (RA0). You will need to switch the pin assignments around and control your LCD from other port A pins.
Hope this helps.
___________________________
This message was ported from CCS's old forum
Original Post ID: 7375 |
|
![](templates/subSilver/images/spacer.gif) |
Nicholas Kinnas Guest
|
Re: 16F876 A/D problems |
Posted: Mon Oct 07, 2002 9:46 am |
|
|
:=Hi all,
:=I need use an A/D connect on pin RA5 (Pin 7) and view results on LCD display connect to Port A and Port B (RB0 to RB7) and (RA0 to RA2).
:=When I connect on RA5 the voltage source not is possible regulate 0 to 5Volts.The voltage move directly 0 to 5V and 5V to 0V.
:=Also, when I connect the voltage tester on pin RA5 ( when not is connect voltage source), I measure 5 Volts.
:=That is my program, I supose what not is correctly configurate.
:=
:=#include<16f873.h>
:=#device ADC=10
:=#USE DELAY(CLOCK=4000000,RESTART_WDT)
:=#INCLUDE <LCD2.C>
:=#USE FAST_IO(A)
:=#USE FAST_IO(B)
:=#USE FAST_IO(C)
:=#BYTE PORT_C=7
:=
:=MAIN()
:={
:= SETUP_ADC(ADC_CLOCK_INTERNAL);
:= LCD_INIT();
:= PORT_C=0;
:= SET_TRIS_C(0X00);
:=
:= while(1)
:= {
:= RESTART_WDT();
:= SET_ADC_CHANNEL(4);
:= TEMP=READ_ADC();
:= DISPLAY(); //Routines for display value on LCD
:= DELAY_MS(100);
:= }
:=}
Fist of all you need a setup_adc_ports statement to enable the correct A/D reference and tell the chip what inputs are to be used for analog. For example setup_adc_ports(ALL_ANALOG) will set all ports to analog and use vss and vdd as your rails, if you use something like setup_adc_ports(RA0_RA1_RA3_ANALOG)you are setting just these inputs as analog. Look in you 16f876.h file for all the available settings. You should also use setup_adc(ADC_CLOCK_DIV_8) instead of SETUP_ADC(ADC_CLOCK_INTERNAL) using the internal clock is not recommended for clock freqeuncies over 4mhz.
___________________________
This message was ported from CCS's old forum
Original Post ID: 7532 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|