PIC interface with temperature sensor LM35

Status
Not open for further replies.

ljljlj

Newbie level 1
Joined
Nov 17, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
I have some enquiries about the assign of the PIN as my output.
Code:
 setup_adc_ports(PIN_A0); 
        set_adc_channel(0);
At first, I set PIN A0 as my output;however, I can't obtain the correct temperature I wanted.
But when I put like this
Code:
 setup_adc_ports(PIN_A1); 
        set_adc_channel(1);
I am able to obtain the correct result.

Therefore, I try the remaining two pins A2 and A3. Unfortunately, both of the pins also didn't give me the correct result I wanted.

May I know why?
I have check my hardware there is no problem.So, I think is the code giving me the problem.

P.S: I am using CCS compiler.:wink:
 

Hi,

May i know it is allow to use only 1 of the Port A pin (channel 0 to read the adc), then the remaining Port A pins to control my motor?

Problem Encountered:

when i only use PIN_A0 interface with the output of LM35, my LCD show me valid temperature result. (29 Celcius or 61 Resolution number.)

But when i enable my motor control pins that also use in Port A, then the temperature result become not correct. I wonder why this could happen

following is my setup:

Code:
   set_tris_A(1) ;                 //only pin_a0 to be an input 
   output_A(0) ;                  //set all pins to 0 value by default 
   setup_adc(ADC_CLOCK_INTERNAL); //use internal clock 
   setup_adc_ports(0xE);          //use only pin_a0 as analog input 
   set_adc_channel(0);            //set pin_a0 as adc channel

Anyone can point out my setup problem?

Thanks,

sysysy
 


i suggest u to use another port that available..when use port a as analog mood, it cant be digital at the same time..
 

Thanks for the reply.

I suspect some noise affect the result when share the same port since 10mV is enough give 1 Celcius.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…