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.

Pic 16F877 with on chip adc

Status
Not open for further replies.

arup

Member level 2
Joined
Sep 6, 2004
Messages
46
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
441
16f877a && adc

sir, me new to pic micros.

I have to measure 50Hz signal amplitude(230V,50Hz AC) using on-chip 10-bit adc.The ac signal is rectified , filtered and fed as dc(with max limit 5V) to a analog channel i/p say,AN0.I have com across following steps.

1) Configure analog/ digital i/o pins in ADCON1

2) selection of i/p channel in ADCON0

3) Turn On A/D and give some stabilization time say 10uS

4) start ADC conversion with GO bit set and check for end of the conversion .and get the result in ADRESH:ADRESL



Now i feel to measure the signal i have to take n no samples and take avg of that.

As a general rule sampling freq will be 2x freq of signal to be measured.

Now i have the following query on the above:



1) i found in the datasheet(PIC16FXXA) "page 131" - table 11-1 : Max Device frequency .......is it the crystal frequency or (Crystal freq / factor ).if it is the 2nd case then what is the factor. pls get me some tech data about prescaler for pic cpu clock.



2) What should be the actual adc clock conversion(in ADCON0) in aboe example ? how to calculate that.



3) What should be sampling freq for n no of samples? How to select it?



4) How many samples will give me good result.



5) Is there any better method than averaging the adc samples in given time?



Thanks for any help.Correct me if anything written wrong.



Regards,

Arup
 

pic adc conversion time

arup said:
1) i found in the datasheet(PIC16FXXA) "page 131" - table 11-1 : Max Device frequency .......is it the crystal frequency or (Crystal freq / factor ).if it is the 2nd case then what is the factor. pls get me some tech data about prescaler for pic cpu clock.
The conversion time should be below the sampling frequency. Do not select fosc/2 as this will be too fast and you will loose out on LSB's.
2) What should be the actual adc clock conversion(in ADCON0) in aboe example ? how to calculate that.
This is in the data sheet.
3) What should be sampling freq for n no of samples? How to select it?
It depends on the no. of samples you require for a cycle.
4) How many samples will give me good result.
5 or 10 times.
5) Is there any better method than averaging the adc samples in given time?
RMS measurement.

Since you are measuring AC and need to store a large amount of data, you will have a problem with 16F series since you will need to do bank switching. Suggest you go in for 18F series.

Cheers

Ravi
 

on chip pic adc

Dear Sir,
In my adc application-measurement of ac voltage, i am considering adc acquisition time (delay) after setting A/D module ON in "init routine".Then in a loop i am reading the on-chip adc.So do i require to give delay eqv. to acquisition time after each conversion(& reading of adc register) has been done??

regards,
Arup
 

on chip adc applications

arup said:
In my adc application-measurement of ac voltage, i am considering adc acquisition time (delay) after setting A/D module ON in "init routine".Then in a loop i am reading the on-chip adc.So do i require to give delay eqv. to acquisition time after each conversion(& reading of adc register) has been done??
Each time you need a sample, you have to:-

1. Select the channel (if more than 1 channel)
2. Provide a acquisition delay
3. Start the conversion
4. Wait for conversion to be over
5. Store the results

All the above is your conversion time, not just the ADC conversion time.
Then you have to provide a delay between 2 conversions to adjust the no. of samples per cycle.

Cheers

Ravi
 

on-chip adc in pic

thanks,
What I understand is if i want to use single channel then i have to set acqusition time once after selecting A/D channel and A/D module ON. After that i don't have to have this acqisition time delay in between conversion again and again. Right !!

rgds,
Arup
 

16f877 adc

arup said:
What I understand is if i want to use single channel then i have to set acqusition time once after selecting A/D channel and A/D module ON. After that i don't have to have this acqisition time delay in between conversion again and again. Right !!
No. For single channel, it is as follows.

1. Select the channel
2. Provide a acquisition delay
3. Start the conversion
4. Wait for conversion to be over
5. Store the results

Sampling delay

goto step 1

Once you select the channel, the sampling starts, hence acquisition delay is ALWAYS required.

Acquisition delay can be as follows.

movlw 0Fh
movwf temp
nop
decfsz temp,f
goto $-2

Cheers

Ravi
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top