PDA

View Full Version : A/D on 16F877. How fast can I go?



atomski
- 4th April 2004, 00:39
Hello,

Just a quick question. I need to run all
8 channels in A/D mode pretty fast.
Also, I need to compare all returned
values and choose the one with the
highest result. But there's a catch. I
need to be able to define the offset
(hysteresis) between the values I'm
comparing. For example if ch1 is
giving the reading 20% higher than
ch3 PIC should choose ch1 value for
further processing. Now with all this
I'm concerned with timing. I need to
read 8 ch, do at least 5 measurements,
average them and compare, choose
the highest value, and make a certain
pin high. All that within 50mS or less
(preferable). While reading the posts
in the archives I bumped into one of
Melanie's posts about ADC that
caught my attention. She said that she
prefers using direct addressing for
ADC to ADCIN, especially when
using interrupts. My question is is
this method any faster and how fast
can I really go with ADC without
getting garbage from it? Anyone?

--
Sincerest regards,

YZ7REA Vladimir M Skrbic
4N7ATV Repeater Administrator
YU7GHZ Radio Club President

Melanie
- 5th April 2004, 12:58
You should easily be able to read an ADC in well under 100uS (subject to input capacitances). After reading eight inputs, that leaves you 49mS to do your calculations. Enough time for at least a full Continental Breakfast and a couple of Coffee's as well!

It's so simple to read ADC's directly and have total and complete control, that I find ADCIN quite unnescessary and if anything a hinderance. I think it's really included for the convenience of those who are afraid of accessing a PIC's internals directly.

Melanie

atomski
- 8th April 2004, 07:51
Mel,

Thanks for the reply. I will certainly give
it a try with direct ADC control. I 'll have
to give it a good shake before I figure
out how to do all the averaging and
comparing of the values within the
variables in order to process the one
with the highest value, though. The
hysteresis between the values has to
be a variable too, so I can change it for
fine tuning and for eliminating all the
transients on analog channels that will
most certainly occur.

--
Sincerest regards,

YZ7REA Vladimir M Skrbic
4N7ATV Repeater Administrator
YU7GHZ Radio Club President