Searching \ for '[pic]: adc' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=adc
Search entire site for: 'adc'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: ADC'
2001\11\12@033651 by MATTHEWS, DEAN (D.)

picon face
I am trying to get my a2d converter working on a 16F877 with no success.  The code I am using is below.  RA3 is connected to 5v and I have connected RA0 directly to a 0-5v variable power supply (is that my problem).  I have connected the pins of portB to eight LEDs so I can see what binary/hex value I get when for example 2.5v is going into RA0.

Also I am not sure how to read the 10 converted bits, the code below will only read 8bits.  Any suggestions.

{Quote hidden}

Dean Matthews

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\11\12@083855 by cdb

flavicon
face
I think your error comes from the fact you need to do the following in your
Read_ADC function

adc_val= adc_high_byte;
adc_val=(adc_val << 8) | adc_low_byte;
return(adc_val)

or

adc_val=(((long) adc_high_byte) << 4) | (adc_low_byte);
return(adc_val)


I think this could also be made part of a a union

it works using FED C

colin

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\11\12@084521 by MATTHEWS, DEAN (D.)

picon face
What is FED C?

Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: dmatth14spamKILLspamford.com
` Please consider your environmental responsibility before printing this e-mail


{Original Message removed}

2001\11\12@090210 by D Lloyd

flavicon
face
part 1 1741 bytes content-type:text/plain; charset=us-ascii
Hi,

FED C is a PIC compiler (see http://www.fored.co.uk/CComp.htm)

Have you Internet access at your site? If you do have access, and you see
something you don't understand/know about, just look it up in Google.
If you don't have access, I suggest you request it because afterwards, you won't know how you coped without it especially in this line of work

Dan





(Embedded     "MATTHEWS, DEAN (D.)" <.....dmatth14KILLspamspam.....FORD.COM>KILLspamspam.....MITVMA.MIT.EDU>> image moved   12/11/2001 13:43
to file:
pic07750.pcx)





Please respond to pic microcontroller discussion list
     <
EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU>
Sent by:  pic microcontroller discussion list <PICLISTspamspam_OUTMITVMA.MIT.EDU>


To:   @spam@PICLISTKILLspamspamMITVMA.MIT.EDU
cc:
Subject:  Re: [PIC]: ADC

Security Level:?         Internal


What is FED C?

Dean Matthews
Reliability Engineering
Ford Engine Plant Bridgend
South Wales, U.K
Tel No:(01656)672597
Fax No:(01656)672558
Email: KILLspamdmatth14KILLspamspamford.com
` Please consider your environmental responsibility before printing this
e-mail


{Original Message removed}
part 2 165 bytes content-type:application/octet-stream; (decode)

part 3 105 bytes
--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\11\12@091246 by MATTHEWS, DEAN (D.)

picon face
Hi,

Sorry, but I am using a CCS C compiler and so would I be right in saying that your code is not applicable for myself.

Dean Matthews

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2001\11\12@124006 by Dale Botkin

flavicon
face
On Mon, 12 Nov 2001, MATTHEWS, DEAN (D.) wrote:

> I am trying to get my a2d converter working on a 16F877 with no
> success.  The code I am using is below.  RA3 is connected to 5v and I
> have connected RA0 directly to a 0-5v variable power supply (is that
> my problem).  I have connected the pins of portB to eight LEDs so I
> can see what binary/hex value I get when for example 2.5v is going
> into RA0.

So what happens when you try this?

> Also I am not sure how to read the 10 converted bits, the code below
> will only read 8bits.  Any suggestions.

You need to use #device PIC16F877 ADC=10 to tell the compiler to use
all 10 bits of ADC result.  I just put #device PIC16F877 *=16 ADC=10
into 16f877.h since I use it that way all the time.

{Quote hidden}

       /* You should move your set_tris_b() up to the top so it's nt part
of the loop. */
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspamTakeThisOuTmitvma.mit.edu


2001\11\12@124457 by Dale Botkin

flavicon
face
On Mon, 12 Nov 2001, cdb wrote:

> I think your error comes from the fact you need to do the following in your
> Read_ADC function
>
> adc_val= adc_high_byte;
> adc_val=(adc_val << 8) | adc_low_byte;
> return(adc_val)
>
> or
>
> adc_val=(((long) adc_high_byte) << 4) | (adc_low_byte);
> return(adc_val)
>
>
> I think this could also be made part of a a union
>
> it works using FED C

But not with CCS.  Read_ADC() returns a long with all 10 bits, if you've
properly set it up.

Dale

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu



'[pic]: adc'
2002\02\04@182751 by juan manuel garofalo
flavicon
face
Hi there:


Does it make sense to build an ADC using a PWM output, low pass filtered and
a comparator from a 16f627 ?

My idea is to conect the voltage i want to measure to one input of the
comparator and the pic's PWM output to the other input. Then i sweep the
duty cycle from 0 to the point  at wich the comparator changes. My guess is
that it's not a very fast ADC, but that's not a concern. Is this a workable
solution or are there any gotchas i should be aware of  ?


Thanks in advance.

jm

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspammitvma.mit.edu with SET PICList DIGEST in the body


2002\02\04@184834 by Jon Baker

flavicon
face
> Does it make sense to build an ADC using a PWM output, low pass filtered
and
> a comparator from a 16f627 ?
> My idea is to conect the voltage i want to measure to one input of the
> comparator and the pic's PWM output to the other input. Then i sweep the
> duty cycle from 0 to the point  at wich the comparator changes. My guess
is
> that it's not a very fast ADC, but that's not a concern. Is this a
workable
> solution or are there any gotchas i should be aware of  ?

Nice idea, instead of sweeping though, think about doing a binary search by
starting at
50% and playing the higher or lower game, then to 25% or 75% etc.. would
increase
the speed- even though you say its not a concern now, you may want to use
this design in
a more time critical application later.

Jon Baker
( who used vitrually the same technique to build an analog joystick
interface not-so-long ago)

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservEraseMEspamEraseMEmitvma.mit.edu with SET PICList DIGEST in the body


2002\02\04@185511 by Dave Dilatush

picon face
juan manuel garofalo wrote...

>Does it make sense to build an ADC using a PWM output, low pass filtered and
>a comparator from a 16f627?

>My idea is to conect the voltage i want to measure to one input of the
>comparator and the pic's PWM output to the other input. Then i sweep the
>duty cycle from 0 to the point  at wich the comparator changes. My guess is
>that it's not a very fast ADC, but that's not a concern. Is this a workable
>solution or are there any gotchas i should be aware of  ?

This should be workable, though you're right about it not being very
fast.  
As for the "gotchas", keep in mind that the comparator's input
common-mode range goes up only to Vdd-1.5V; also, you'll need a filter
that reduces the worst-case PWM output ripple by at least 60 db to get
full 10-bit resolution.  You probably would be best with a filter
response which has no time-domain overshoot, i.e. a Bessel response.

As a matter of strategy, how about arranging the software to implement a
"tracking" converter?  You'd have an interrupt on each PWM cycle; in
this interrupt, you'd query the comparator to determine whether the
current PWM output is too high or too low, then increment or decrement
the PWM accordingly.  This arrangement would not be good at following
fast input changes; but it would be superior for slowly-changing inputs
since it continually keeps itself within a count or two of the current
input value.

Just an idea...

Dave

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspam_OUTspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body


2002\02\04@191753 by Byron A Jeff

face picon face
On Mon, Feb 04, 2002 at 08:08:01PM -0300, juan manuel garofalo wrote:
> Hi there:
>
>
> Does it make sense to build an ADC using a PWM output, low pass filtered and
> a comparator from a 16f627 ?

Absolutely. It'll be slow, grainy, and somewhat uncalibrated.
>
> My idea is to conect the voltage i want to measure to one input of the
> comparator and the pic's PWM output to the other input. Then i sweep the
> duty cycle from 0 to the point  at wich the comparator changes. My guess is
> that it's not a very fast ADC, but that's not a concern. Is this a workable
> solution or are there any gotchas i should be aware of  ?

You have the major gotcha: You'll have to sweep slowly and allow the filter
time to settle between steps. You may also want to consider an opamp sample
and hold for your input voltage so that it won't change during your sweep.
Here's a pdf with some tutorial slides:

http://www.eecg.toronto.edu/~kphang/ece1352f/chap08a_slides.pdHere's a pdf with some tutorial slides:

http://www.eecg.toronto.edu/~kphang/ece1352f/chap08a_slides.pdff

If you can spare a timer you could program an interrupt to step the PWM
and check the comparitor, essentially automating the operation.

BAJ

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\02\04@194734 by mark

flavicon
face
You can use the same idea from this page :

http://medo.fov.uni-mb.si/mapp/ds_adc/index.html

The conversion time is something about 10 mS.

Regards.


On 4 Feb 2002 at 20:08, juan manuel garofalo wrote:

{Quote hidden}

---
Marcelo Puhl
Mensa Brasil member
http://www.mensa.com.br

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\02\04@231805 by Frank Brancato

picon face
Take a look at http://www.bytecraft.com/addaconv.html
for a very simple A/D.

If you need more bits, just add some dither to the analog signal and then
use the average value of many samples.

For example, the average of 4 samples will add 1 bit of resolution to the
measurement. The average of 16 samples will give you 2 bits .

-Frank



{Original Message removed}

2002\02\07@104746 by juan manuel garofalo

flavicon
face
Thanks to everybody who commented on making a simple adc using PWM and a
comparator (on a 627)



juan.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...