Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

how to read all channel of adc of PIC controller using ccs c compiler

Status
Not open for further replies.

amit_dhanawade

Junior Member level 1
Joined
Dec 21, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,394
hello,
can't we use all adc channel of pic in one program using ccs c compiler, when i wrote a code to read one channel it works fine, but when read other channel cross talk like thing happens i don't why.....
does anybody faced same problem and solved..
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,181
Helped
1,140
Reputation
2,299
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,321
Better you post the code section related to A/D acquisition.
This way is impossible know what is happening.

+++
 

amit_dhanawade

Junior Member level 1
Joined
Dec 21, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,394
this is my code

#include <18F458.h>
#device ADC=10
#fuses HS,NOPROTECT,NOLVP,NOWDT
#use delay(clock=20000000)



void main()
{
int16 buffer[8],temp_res,pressure_res,level_res;



setup_adc( ADC_CLOCK_INTERNAL );
setup_adc_ports(AN0_AN1_AN2_AN3_AN4);
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"welcome");
lcd_gotoxy(1,2);

while(1)
{
temp_res = 0;
set_adc_channel(0);
temp_res = read_adc()/2;
buffer[0] = temp_res;
lcd_gotoxy(1,1);
printf(lcd_putc,"Temp:%ld ",temp_res);
delay_ms(1000);

set_adc_channel(2);
pressure_res =read_adc();
buffer[0] = pressure_res;
lcd_gotoxy(1,2);
printf(lcd_putc,"Pressure: %ld",pressure_res);
delay_ms(1000);

set_adc_channel(1);
level_res =read_adc()/4;
level_res = level_res - 125;
buffer[0] = level_res;
lcd_gotoxy(10,1);
printf(lcd_putc,"Lvl:%ld ",level_res);
delay_ms(1000);

}
}



when i comment other two adc routine the temperature one works fine but while three at a time creates cross talk
 

hussain_kiet

Full Member level 5
Joined
Mar 15, 2007
Messages
262
Helped
45
Reputation
90
Reaction score
28
Trophy points
1,308
Location
Karachi, Pakistan
Activity points
2,813
what do you mean by cross talk.?
what exactly do you see..?

---------- Post added at 08:52 ---------- Previous post was at 08:44 ----------

I am not sure......., but the problem might be the second adc value overwrites on the first value as you print the first one on

lcd_gotoxy(1,1);

and second one on

lcd_gotoxy(1,2);
try to shift the second one's location ...
 

amit_dhanawade

Junior Member level 1
Joined
Dec 21, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,394
but there is delay of 1 sec so even if it overwrites will not matter....

cross talk means when i try to change temperature by heating it the value of level input changes and if level changed temperature changes even if sensor is untouched...
 

andre_teprom

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,181
Helped
1,140
Reputation
2,299
Reaction score
1,116
Trophy points
1,403
Location
Brazil
Activity points
53,321
comparing to a code I wrote using multichanel reading I note that is missing the following argument :

Code:
read_adc ( ADC_START_ONLY )   ;
Did you saw the set of examples at CCS instaled folder ?

+++
 

amit_dhanawade

Junior Member level 1
Joined
Dec 21, 2007
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,394
hardware seems to be ok, i had this cross talk problem in simulation also....

ill try adding the suggested line and let you know.

thank you!
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top