CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

About the VREF+ and VREF-

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 19, 2009 5:04 pm     Reply with quote

I created the Vref voltages with a voltage divider made from 3 resistors,
and I connected it to the PIC as shown below.
Code:

        2.2K           2.0K        820 ohms
+5v ---/\/\/\/---o---/\/\/\/---o---/\/\/\/--- Ground
                 |             |               
                 |             |
                2.8v          0.8v
             To pin RA3     To pin RA2
               Vref+          Vref-


I have a 5K trimpot connected to pin A0 to provide the input analog
voltage. If I set the trimpot to 2.82v, I get this output from the program
below. (The compiler is doing the A/D conversions in 8-bit mode).
Quote:
254
254
254
254
254


If I set the voltage on pin A0 to 0.83 volts, I get the following output:
Quote:

1
2
2
1
1
1
1

Those readings are correct, for the given Vref circuit. This was tested
with vs. 4.093 of the compiler, on a PicDem2-Plus board.

Here is the test program:
Code:

#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//=============================
void main()
{
int8 result;

setup_adc_ports(AN0_VREF_VREF);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(20);

while(1)
  {
   result = read_adc();
   printf("%u \n\r", result);
   delay_ms(500);
  }

}
Guest








about the solution
PostPosted: Sat Jun 20, 2009 8:06 am     Reply with quote

thanks, I'm using the Proteus 7.4 to simulate the circuit. Then, I print the voltage values on LCD 16X2. I'll try to use your example and come back to show the results.
Thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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