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 support@ccsinfo.com

ADC Input Buffer Question

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



Joined: 16 Jan 2004
Posts: 9

View user's profile Send private message

ADC Input Buffer Question
PostPosted: Sun Jan 25, 2004 2:08 pm     Reply with quote

Hello,

I'm having problems gettinig the ADC on my 16f876 to work. I've searched back through 100's of posts on this topic, and I have ideas on what I am doing wrong from a programming standpoint. However, I have a question about the proper way to connect the analog signal to the PIC.

I currently set the circuit up so that the output from a joystick pot is driving the non-inverting input of a voltage follower. I then connect the output of the follower to RA0. I ran the system like this for a very short period of time at which point the PIC started to get warm so I shut it down. If you pm me(erb@pitnet.net), I can send a bmp of the circuit for clarity. I must need to current limit somewhere, but I'm not sure where.

Thoughts are Appreciated,

Eric
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Sun Jan 25, 2004 2:27 pm     Reply with quote

Hi

Can you post your PIC code?
I don't see why you have to use a current limiter, the analog inputs have already a very high impedance.
May the RA0 isn't set as analog input?

mfg
Felix
Freddie



Joined: 06 Sep 2003
Posts: 49

View user's profile Send private message

PostPosted: Sun Jan 25, 2004 6:35 pm     Reply with quote

I think I can help you with the code part . This code takes 10 AtoD reads on RA0, averages them and sends the data out to the serial port. I use a PC terminal program to see the data. I removed some other non related code so I hope I did not introduce a syntax error. Hope this helps.

To test if the code and if your circuit is working, run the code and connect RA0 to ground and Vcc (through a pullup resistor) as a test. You should get 0x0000 and 0x03FF respectively.

Code:

#include <16F876.h>
#device *=16 ADC=10  //needed for 10 bit AtoD

#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=10000000)

#include <string.h>
#include <stdlib.h>


#define txPC   PIN_C6
#define rxPC   PIN_C7

#use rs232(baud=9600, xmit=txPC, rcv=rxPC, STREAM=serialPC ) 


void main() {

   int16 atodValue, int16Temp;
   
   fprintf(serialPC,"\r\Running...\r\n");

   setup_port_a(RA0_ANALOG);  //see 16F876.h for other parameters
   setup_adc(ADC_CLOCK_INTERNAL);  //see 16F876.h for other parameters

   while (1)
   {

      set_adc_channel(0);

      int16Temp = 0;
      for(i=0;i<10;i++)
      {
         atodValue = Read_ADC();
         int16Temp = int16Temp + atodValue;
         fprintf(serialPC, "atodValue = %LX\r\n", atodValue);
         delay_ms(50);
      }
      atodValue = 0;
      atodValue = int16Temp / (long)10;
      fprintf(serialPC, "atodValue AVG= %LX\r\n", atodValue);
      
     } //end while(1)

} //end main

Ttelmah
Guest







Re: ADC Input Buffer Question
PostPosted: Mon Jan 26, 2004 8:57 am     Reply with quote

bauereri wrote:
Hello,

I'm having problems gettinig the ADC on my 16f876 to work. I've searched back through 100's of posts on this topic, and I have ideas on what I am doing wrong from a programming standpoint. However, I have a question about the proper way to connect the analog signal to the PIC.

I currently set the circuit up so that the output from a joystick pot is driving the non-inverting input of a voltage follower. I then connect the output of the follower to RA0. I ran the system like this for a very short period of time at which point the PIC started to get warm so I shut it down. If you pm me(erb@pitnet.net), I can send a bmp of the circuit for clarity. I must need to current limit somewhere, but I'm not sure where.

Thoughts are Appreciated,

Eric

The key question, is what voltage range the input may go to?.
There are two basic reasons for heating in the PIC in this configuration. The first would be that the input pin was configured as an output (as has allready been suggested), while the second would be if the input signal went outside the range -0.6v to Vdd+0.6v. In this latter case, current will be drawn through the input protection diodes on the PIC.
Even if the source voltage is in the range 0v to Vdd, it is worth remembering that a op-amp wired as a voltage follower, may if not properly compensated for unity gain operation, start to oscillate. If this was happening, and the op-amp is running off (say) +/-12v, the voltages actually presented to the PIC's input, could again be driving into the protection diodes, and causing heating.

Best Wishes
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