ADC problem with SK40C

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

ADC problem with SK40C

Postby MaxD » Sat May 05, 2012 3:26 am

ADCON0:
bit7 - ADCS1
bit6 - ADCS0
bit5 - CHS2
bit4 - CHS1
bit3 - CHS0
bit2 - GO/DONE
bit1 - unimplemented bit
bit0 - ADON
----------------------------------------------------------
ADCON1:
bit7 - ADFM
bit6 - unimplemented bit
bit5 - unimplemented bit
bit4 - unimplemented bit
bit3 - PCFG3
bit2 - PCFG2
bit1 - PCFG1
bit0 - PCFG0
---------------------------------------------------------
According to the registers above, I set RA3 as Vref+ and RA2 as analog input:
CODE: SELECT_ALL_CODE
TRISA = 0b11111;
TRISE = 0b111;

ADCON0 = 0b10010001;
ADCON1 = 0b10000001;

__delay_ms(2);
   ADGO=1;
   while(ADGO==1)
      continue;
   return(256*ADRESH+ADRESL);

I can't get any power supply from RA3, why? If there is no power supply from RA3, then why LCD didn't show 0 value? Any problem with my register setting?
MaxD
Newbie
 
Posts: 11
Joined: Thu Apr 26, 2012 10:51 am

Re: ADC problem with SK40C

Postby ABSF » Sat May 05, 2012 9:05 am

Vref+ is an input pin. You're not going to get any voltage from it.

PIC_ARCH.JPG


Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: ADC problem with SK40C

Postby holy_rainman » Sat May 05, 2012 11:16 am

Doesn't that mean we have to supply voltage ranging from 0V to 5V to Vref? Does it act like a comparator? I haven't played with Vref yet...
holy_rainman
Newbie
 
Posts: 8
Joined: Mon Nov 30, 2009 2:45 am

Re: ADC problem with SK40C

Postby ABSF » Sat May 05, 2012 10:29 pm

The Vref+ of the ADC is selectable to Vdd internally or externally through RA3 by the "PCFGx" bits. The external Vref+ can be 0-5V using linear pot or a voltage reference chip such as TL431.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: ADC problem with SK40C

Postby robosang » Sat May 05, 2012 11:35 pm

Allen is right. :mrgreen:

1st thing, PIC does not have analog output pin, only Analog Input pin. Of course some uses PWM output to get analog voltage, still you need to do some circuitry to get that :)

2nd, don know why you want to change the Vref(+) to RA3, just tie it to VDD which is 5V normally. For cases where Vref(+) is tie to I/O pin is they wanted the Vref(+) to be other than VDD, example 2.0V, 4.0V, 1.023V.....
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: ADC problem with SK40C

Postby MaxD » Sun May 06, 2012 3:16 pm

So in order to get voltage from Vref+, i need to add in some extra components in the circuit, else it is just an analog input with no input voltage, right?
MaxD
Newbie
 
Posts: 11
Joined: Thu Apr 26, 2012 10:51 am

Re: ADC problem with SK40C

Postby ABSF » Sun May 06, 2012 5:26 pm

MaxD WROTE:So in order to get voltage from Vref+, i need to add in some extra components in the circuit, else it is just an analog input with no input voltage, right?


No, you're not going to get voltage from Vref+ but you're going to give a reference voltage to Vref+.

robosang WROTE:1st thing, PIC does not have analog output pin, only Analog Input pin. Of course some uses PWM output to get analog voltage, still you need to do some circuitry to get that


What robosang was saying is that PIC does not have analog output PIN cos ADC output is in digital form stored in ADRESx. If you need analog output, you have to use another IO pin (CCP1 or ordinary IO pin) and use PWM method to convert the number stored in ADRESx or any other variables into analog form. But why do you want to do that ? This can be easily done with an op-amp..... :mrgreen:

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: ADC problem with SK40C

Postby MaxD » Mon May 07, 2012 6:30 am

Oh, i see...thank you for your well explanation allen and robosang, thank you for your help =D
MaxD
Newbie
 
Posts: 11
Joined: Thu Apr 26, 2012 10:51 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest