View previous topic :: View next topic |
Author |
Message |
i'm child Guest
|
please tell me |
Posted: Thu Oct 19, 2006 4:13 pm |
|
|
dear all....
i want to read temperature from TC74. but when i run this code i read
temperature =-1 why?
what wrong!! please tell me
#include<18f452.h>
#device ADC=10 //use ADC 8 bit convision
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#use I2C(master,sda=PIN_C4,scl=PIN_C3)
//Define address on Temperature Sensor :0100 1101
#define Sensor_ID 0b01001101
#include<stdlib.h>
#include "input.c"
unsigned int TempRead(void){
unsigned int Data;
i2c_start();
i2c_write(Sensor_ID);
Data=i2c_read(0);
i2c_stop();
delay_ms(200);
return(Data);
}
void main(void){
unsigned int Data;
int16 readin; //variable readin---->buffer read in
set_tris_b(0xF0); //set tris b for low nibble as output
output_b(0x00);// Clear port B
setup_adc_ports(RA0_ANALOG); //Select RA0 to analog
setup_adc(ADC_CLOCK_INTERNAL);//Select internal clock
set_adc_channel(0);//Select channel
Printf("\t\t ..::Hello world This is a testing a RS-232::..\n\r");
for(;;){
Data=TempRead();
printf("this is temperature : %d C' \n\r",Data);
readin=read_adc(); //Read in and assigned in readin variable
printf("ADC value is : %w \n\r",readin);
if(readin<0>0 && readin <255>255 && readin <512>512 && readin <767>767 && readin <=1023){
output_b(0x0F);
delay_ms(500);
}
}//for loop
}//main |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Thu Oct 19, 2006 11:31 pm |
|
|
Hi,
Quote: |
//Define address on Temperature Sensor :0100 1101
#define Sensor_ID 0b01001101
#include
#include "input.c"
|
Whats the extra #include directive for , it has no .c file specified ??
thanks
arunb |
|
|
i'm child Guest
|
|
Posted: Fri Oct 20, 2006 5:27 am |
|
|
Thank alot PCM programmer. |
|
|
|