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

PIC16F690

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



Joined: 30 Mar 2010
Posts: 21

View user's profile Send private message Send e-mail

PIC16F690
PostPosted: Wed Mar 02, 2011 4:22 am     Reply with quote

Hai all,

I`m using PIC16F690 which has been interfaced with LM35 Temperature sensor. the MCU works fine when connect my VDD to 5 volts, it means i`m getting ADC counts correctly but when i reduce the VDD to 3.3 V my ADC goes to saturation(1023 counts). I`m using internal clk @8 MHz and VRef for ADC is internal.

regards
balaji
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 6:32 am     Reply with quote

There shouldn't be any reason for it not to work, but , please post a small complete program,with fuses,includes,version that shows the problem.
balaji



Joined: 30 Mar 2010
Posts: 21

View user's profile Send private message Send e-mail

here is code
PostPosted: Wed Mar 02, 2011 7:08 am     Reply with quote

Code:

#include<16f690.h>
#DEVICE ADC=10
#use delay(internal=8Mhz)
#use rs232(baud = 9600,xmit = PIN_B7, rcv = PIN_B5,parity = n )
#fuses HS,NOWDT,PUT,NOPROTECT,NOBROWNOUT

#byte TRISA=0x85
#byte TRISB=0x86
#byte TRISC=0x87

unsigned long avg;
unsigned long value;
 
void main()
 {
      set_tris_a(0xff);
      set_tris_b(0x00);
      setup_adc_ports( ALL_ANALOG );
      setup_adc(adc_clock_internal);
      unsigned long i,avg, sum = 0;
 
      while(1)
{
      set_adc_channel(0); // Smoke detector
      delay_ms(100);
      value=read_adc();
      printf("\n\n\n smoke count: %lu",value);
   
      set_adc_channel(1);
      delay_ms(100);
      value=read_adc();
      printf("\n\n\n TC: %lu",value);// LM35 input
   
      delay_ms(2000);
      output_toggle(pin_B6);// To check MCU live
}
}
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 7:24 am     Reply with quote

Do not use the following !

setup_adc(adc_clock_internal);

According to the datasheet, it can only be used in sleep mode...
4: When the device frequency is greater than 1 MHz, the FRC clock source is only recommended if the
conversion will be performed during Sleep.

The two options are..
Fosc/16 and Fosc/32
according to the datasheet, table 9.1 , in the ADC section.


Also, you do not need to delay_ms(100) for the readings.
delay_us(10) ; should be more than adequate.
ALPL



Joined: 29 Mar 2009
Posts: 30

View user's profile Send private message

PostPosted: Wed Mar 02, 2011 10:42 am     Reply with quote

Hello, also check the LM35 data sheet. The LM35 operates from 4 to 30V. 3.3V might not be enough.
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