The Philippine Electronics and Technology Forum
February 10, 2012, 03:21:49 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  

Pages: [1]   Go Down
  Print  
Author Topic: Analog to digital conversion program problem  (Read 388 times)
toinkman
CR2032 Battery
**

Pogi/Ganda Points: 0
Offline Offline

Posts: 10


« on: February 16, 2010, 07:44:09 PM »

Hi guys! Can anybody help me with the analog to digital conversion module of PIC16f887
Im trying to input to the vref of the PIC 16f887 and then i wanted to use other adc pins
I declared portD as output with 8 bits of data. I discarded the 2 least significant bits
I input 5 volts at the vref+ pin and then smaller voltages in the other pins to check the
resolution of the conversion
Nothing is happening..is there something wrong with my program?
anyhelp is well appreciated..ThankS!

unsigned int L1,L2,L3,L4,L5,L6,L7,L8;

int i;

void main()
{
ANSEL = 0x00;   //Configure AN0 as analog input
ANSEL = 0x08;   //Configure AN1 as analog input
ANSEL = 0x04;   //Configure AN2 as analog input
ANSEL = 0x0C;   //Configure AN3 as analog input
ANSEL = 0x02;   //Configure AN4 as analog input
ANSEL = 0x0A;   //Configure AN5 as analog input
ANSEL = 0x06;   //Configure AN6 as analog input
ANSEL = 0x0E;   //Configure AN7 as analog input
ANSEL = 0x01;   //Configure AN8 as analog input
ANSEL = 0x09;   //Configure AN9 as analog input
ANSELH = 0;     //Configure other analog inputs to digital I/O
ADCON0 = 0x90;  //Configure Vref+
TRISA = 0xFF;   //Configure all PortA input
TRISE = 0x0F;   //Configure all PortE input
TRISB = 0x0E;   //Configure AN8 and AN9
PORTD = 0;      //PortD as output
TRISD = 0;      //PortD as output

switch (i)
{

case 0:
{
L1 = ADC_Read (0) >>2;  //read from pin AN0
ADCON0 = 0x83;            // convert analog to digital
PORTD = L1;                 // Send output to portD
}break;

case 1:
{
L2 = ADC_Read (1) >>2;
ADCON0 = 0x87;
PORTD = L2;
//Delay_ms (1000)
}break;

case 2:
{
L3 = ADC_Read (4) >>2;
ADCON0 = 0x93;
PORTD = L3;
//Delay_ms (1000)
}break;

case 3:
{
L4 = ADC_Read (5) >>2;
ADCON0 = 0x97;
PORTD = L4;
//Delay_ms (1000)
}break;

case 4:
{
L5 = ADC_Read (6) >>2;
ADCON0 = 0x9B;
PORTD = L5;
//Delay_ms (1000)
}break;

case 5:
{
L6 = ADC_Read (7) >>2;
ADCON0 = 0x9F;
PORTD = L6;
//Delay_ms (1000)
}break;

case 6:
{
L7 = ADC_Read (Cool >>2;
ADCON0 = 0xA3;
PORTD = L7;
//Delay_ms (1000)
}break;

case 7:
{
L8 = ADC_Read (9) >>2;
ADCON0 = 0xA7;
PORTD = L8;
//Delay_ms (1000)
}break;

}


}
Logged
The Philippine Electronics and Technology Forum
« on: February 16, 2010, 07:44:09 PM »

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
ANALOG VS DIGITAL « 1 2 »
The Academic Community (Engineering and Vocational Students)
celdricg 31 4775 Last post September 13, 2008, 02:45:27 AM
by ferdie444
Number conversion problem displayin to lcd
PIC Microcontrollers
phage_04 1 431 Last post May 03, 2008, 03:27:40 AM
by Mentor Lee
Analog to digital conversion of VHS tape
Mixed Signal and ASICs
mikel 6 1462 Last post September 04, 2008, 03:41:19 AM
by N1X
patulong naman sa design namin,, digital tape measure with conversion « 1 2 3 »
ECE Students
ged_rooms 47 3347 Last post July 19, 2009, 08:08:30 PM
by ged_rooms
patulong naman.. digital tape measure with conversion!!
Thesis and Project Proposal
ged_rooms 6 925 Last post June 29, 2009, 02:21:59 PM
by ged_rooms
television analog to digital transition(conversion)
General Electronics and Technology Discussion
rogerjuvy 2 676 Last post August 26, 2009, 09:31:57 AM
by Ka irnie
2-channel Analog-to-Digital conversion + USART « 1 2 »
PIC Microcontrollers
toinkman 22 1243 Last post February 22, 2010, 03:42:32 PM
by marcelino
Powered by MySQL Powered by PHP Powered by SMF 1.1.15 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!