Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

eight analog input working with pic18f4550

Status
Not open for further replies.

ptte

Newbie level 4
Joined
Apr 17, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,327
eight analog input

Hi,,,

am working with pic18f4550 to read eight analog inputs parallely from(AN0-AN7)
i tried some code but did't get read all eight pins...

can anyone help me with similar kind of code or any examples...

thanks,
 

eight analog input

post your code
 

Re: eight analog input

Code:
for(j=0; j<=1; j++){
if(TRISAbits.TRISA0==1)
ReadPOT();
temp = ReadADC();
itoa(temp/2,adc_buffer1);
putsUSBUSART(adc_buffer1);

if(TRISAbits.TRISA1==1)
ReadPOT();
temp = ReadADC();
itoa(temp/2,adc_buffer2);
putsUSBUSART(adc_buffer2);
 }
}

this is for two channels
 

Re: eight analog input

I'm not sure which compiler you are using but I can't see why you are checking the TRIS bits before talking a reading. Can you explain.

Brian.
 

eight analog input

MCC18 only am using...
if pin0 and pin1 are 1 means it should read analog value...
 

Re: eight analog input

I don't use MCC18 but I can tell you the TRIS bits have very little to do with selecting analog inputs. The TRIS bits set the port bit direction, 0 = output, 1 = input. You set them as you wish but they do not change by themselves so I can't see why you are checking them in your program.

I think what you should do is set the bits in the ADC part of the PIC so the pins are analog inputs then select the one you want to read, then take the measurement.
For the second reading, select the next input and then read the value.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top