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

AD595

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



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

AD595
PostPosted: Thu Sep 12, 2013 12:49 am     Reply with quote

Dear Friends;

I am confused to develop a formula for AD595 temperature measurement IC.
My Code is below:
Code:

#include <18F6722.h>
#DEVICE ADC=10

#fuses HS, NOWDT, PROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 10000000)
#include"D:\Drivers\Flex_LCDPORTF.C"
#use rs232 (baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

LONG RatioSel;
float temp;   

void main()
{

set_tris_a(0XFF);
lcd_init();
  setup_adc( ADC_CLOCK_DIV_8  );
  setup_adc_ports(ALL_ANALOG);
 
while(1)
 {
  int16 i;
  set_adc_channel(1);
  delay_us(100);
  RatioSel = read_adc();
   RatioSel = RatioSel * 1.25;
  lcd_gotoxy(1,3);
  printf(lcd_putc,"RatioSel: %ld        ",RatioSel); 
  delay_ms(1000);
 }

}


I am using the resister devider circuit with 15K at IC side and 10K at ground side and middle pin is connected on analog pin of microcontroller.

when the temperature is 30C the value of the IC is 0.3 and ic read 0.12v on its analog pic because of devider circuit.

As per my understanding calculation would be

1023/5 * 0.12 * 1.25 = 30

Is it correct or please make me correct.

I dont know why i have to use "1.25" multiplier to make my result correct.
Also this formula does not work for the whole range from 0C to 1000C i required.

Can any one tell me the correct formula for temperature calculation using above hardware setting or suggest me any other correct option.

Regards
Ashraf
alan



Joined: 12 Nov 2012
Posts: 357
Location: South Africa

View user's profile Send private message

PostPosted: Thu Sep 12, 2013 1:17 am     Reply with quote

Actually quite easy.

You are getting a digital value of 0.12*1024/5 = 24 (already inaccurate because it should be 24.7)

Now you need to convert it back to an "analog value" as that is what you're measurement are related to.

Vchip = (ADC * 5/1024) / (voltage divider) = 24 * 5/1024 * 25/10 = 0.293.

The output of your sensor are 10mV/Deg.

Temp = Vsensor / 0.01 = 29.3 should have been 30 but see top of post.

Thus your actual multiplier are 5/1024 * 25/10 * 1/0.01 = 1.221

Regards
Alan
Ttelmah



Joined: 11 Mar 2010
Posts: 19358

View user's profile Send private message

PostPosted: Thu Sep 12, 2013 1:34 am     Reply with quote

Further comments though:

What is the minimum recommended source impedance for the ADC?. Does your divider meet this?. You need a buffer amplifier, or to use lower resistance values on the divider.

Then, don't set the channels as 'ALL_ANALOG', unless you are going to use all the analog channels. Each channel selected to the input multiplexer, potentially increases noise injected to the ADC. OK if the pins are connected to nice stable analog signals, but not if the pins are floating.

Then the big 'limit' on accuracy is using the power supply as Vref. Even with a good PSU, this will only be 1% 'accurate' at best, and _will_ have significant noise spikes on it as the CPU works. For high accuracy with low level signals, you need to be using a proper high precision Vref.

Remember also that simple resistors, will only typically be 1% at best accuracy....

Best Wishes
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Thu Sep 12, 2013 1:59 am     Reply with quote

Thank you friends
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Thu Sep 12, 2013 8:46 am     Reply with quote

You CAN use Vdd as the reference supply with excellent results.

I have several heat control designs ( with 12bit A/Ds) where
Vdd is supplied by an LM317 from a 12V primary supply.

The "calibration" is preformed by fine adjustment of the LM317 divider pot.

works superbly well,
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Thu Sep 12, 2013 11:34 pm     Reply with quote

Dear Asmboy;

Can you send me a complete schematic of heat c ontrol design on my email address

ctecd@yahoo.com

Ashraf
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sat Sep 14, 2013 3:44 pm     Reply with quote

the controller as a whole is a work 4 hire, so no will do.

but generically - this is what we I am talking about

http://www.circuitstoday.com/few-lm317-voltage-regulator-circuits

using a 100uf or greater tantalum cap on teh Vdd pin to Vss of the PIC dispenses with glitches very nicely and i use this for my a/d readings anyway:

http://www.ccsinfo.com/forum/viewtopic.php?t=50320&highlight=olympic
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