Searching \ for '[PIC] Automotive analog signal conditioning' 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=analog
Search entire site for: 'Automotive analog signal conditioning'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Automotive analog signal conditioning'
2005\06\07@201144 by Anthony Toft

flavicon
face
I would like to apologize in advance for this silly question, but I have
been unable to find it in the datasheets...

When using the AD with Vref+ and Vref-, does the AD read 3FF when the
measured voltage==Vref+ and 0 when the voltage==Vref-?

I ask because I have found a resistor that gets better separation but as
it is quite small, the highest voltage is about 1.7v (on the DVM) but if
the answer to the question above is what I think it is, then it won't
matter because I can just bring Vref+ down to match by changing its "to
ground" resistor.

Again I apologize for this fundamental question, but I just would like
my mind set straight.
--
Anthony Toft <spam_OUTtoftatTakeThisOuTspamcowshed.us>
    I'm Anton, and I approve this message

2005\06\08@070022 by Gerhard Fiedler

picon face
Anthony Toft wrote:

> [...] but I have been unable to find it in the datasheets...

It's not explicitly there, but if you look for example at the block diagram
of the ADC section (in my mid-range reference manual, that's figure 23-1),
it kind of is implied. If you don't use the "explicit" reference voltages,
Vref+ is connected to Vdd and Vref- is connected to Vss -- so this is
nothing different, it's just a special case of reference voltages.

> When using the AD with Vref+ and Vref-, does the AD read 3FF when the
> measured voltage==Vref+ and 0 when the voltage==Vref-?

Correct.

Gerhard

2005\06\08@070150 by olin piclist

face picon face
Anthony Toft wrote:
> When using the AD with Vref+ and Vref-, does the AD read 3FF when the
> measured voltage==Vref+ and 0 when the voltage==Vref-?

Yes.

*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

2005\06\08@094153 by Michael Rigby-Jones

picon face


>-----Original Message-----
>From: .....piclist-bouncesKILLspamspam@spam@mit.edu [piclist-bouncesspamKILLspammit.edu]
>Sent: 08 June 2005 01:12
>To: Microcontroller discussion list - Public.
>Subject: [PIC] Automotive analog signal conditioning
>
>
>I would like to apologize in advance for this silly question,
>but I have been unable to find it in the datasheets...
>
>When using the AD with Vref+ and Vref-, does the AD read 3FF
>when the measured voltage==Vref+ and 0 when the voltage==Vref-?
>

Correct.

>I ask because I have found a resistor that gets better
>separation but as it is quite small, the highest voltage is
>about 1.7v (on the DVM) but if the answer to the question
>above is what I think it is, then it won't matter because I
>can just bring Vref+ down to match by changing its "to ground"
>resistor.

Note that there are limits on the vaoltages you can use as references, and I suspect 1.7volts will be too low if you are using a 5 volt Vdd.  This information is shown in the datasheet in the "Electrical Characteristics" section.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2005\06\08@141621 by Mike Hord

picon face
> I would like to apologize in advance for this silly question, but I have
> been unable to find it in the datasheets...

Not silly:  that information isn't there because the assumption is
that if you are working with PICs, you already know how an ADC
works.  Bad assumption on the part of a company who is
(arguably) the most popular microcontroller comapny for
hobbyists!  That also underscores the trouble with learning from
the datasheets:  they expect a certain amount of familiarity with
the jargon and concepts.

> When using the AD with Vref+ and Vref-, does the AD read 3FF when the
> measured voltage==Vref+ and 0 when the voltage==Vref-?

Yes, with a few caveats:

1.  Vref+ and Vref- have minimum and maximum allowable
voltages.  Those voltages are related to the Vdd of the
chip, and are outlined in the datatsheet.
2.  That assumes right justified data.  If the data is left
justified, the range is FFC0->0000, with a minimum
nonzero value of 0040.  Left justification is useful for
obtaining an 8-bit result:  ADRESH contains the 8 MSBs
of the value.  The lower two can be ignored.

Mike H.

2005\06\08@151314 by Wouter van Ooijen

face picon face
> Not silly:  that information isn't there because the assumption is
> that if you are working with PICs, you already know how an ADC
> works.  Bad assumption on the part of a company who is
> (arguably) the most popular microcontroller comapny for
> hobbyists!

Only if it is an important source of profit for them, which I doubt.

> That also underscores the trouble with learning from
> the datasheets:  they expect a certain amount of familiarity with
> the jargon and concepts.

It is impossible to write without assuming a context. Personally I would
like the manuals to be more terse, which would make it easier reading
for me. Which shows that you can never please everyone.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu


2005\06\08@201947 by Anthony Toft

flavicon
face
> Not silly:  that information isn't there because the assumption is

It certainly seems as though it is something that you know. I had an
inkling but needed confirmation (which I got in barrow loads)

> 1.  Vref+ and Vref- have minimum and maximum allowable
> voltages.  Those voltages are related to the Vdd of the
> chip, and are outlined in the datatsheet.

I found this in the midrange book Vref+ <= AVdd +0.3v not a problem as
Vdd is 5v and my current selection gives a Vref+ of about 1.85-1.9v
depending on other load (and probably the noise) I have Vref- >=
AVss-0.3v not a problem because it is coupled to Vss, I would use a mode
that only required one reference, but it's not possible without a
(albeit simple) redesign and etch. What bothers me are the lines below
it that says the minimum difference should be 0v to avoid latch up, or
3v for 10bit resolution. I am using left justified data (for 8 bit
resolution) will this affect me? I really like the resistor selection I
have right now as the 8 buttons are giving ~10% separation. If I go to
3v then I will have ~7% separation.

--
Anthony Toft <.....toftatKILLspamspam.....cowshed.us>
    I'm Anton, and I approve this message

2005\06\09@031626 by Michael Rigby-Jones

picon face


{Quote hidden}

Don't use the mid range reference manual for detailed electrical specs.  Depending on the process used in the PIC you have, these details can change, you should always use the datasheet for these values.

Also, you have looked at the maximum voltage on Vref+, but you haven't checked the minimum voltage which is rather more important for your application.  This is typicaly AVdd-2.5v so you would be out of spec with a 5volt supply.

Thirdly, you should be able to get a fixed separation between the buttons irrespective of the reference voltage, by selcting suitable resistors.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2005\06\09@073044 by Anthony Toft

flavicon
face
> Don't use the mid range reference manual for detailed electrical specs.  Depending on the process used in the PIC you have, these details can change, you should always use the datasheet for these values.

I hadn't found it before, but an electronic search of the datasheet
turned it up.

> Also, you have looked at the maximum voltage on Vref+, but you haven't checked the minimum voltage which is rather more important for your application.  This is typicaly AVdd-2.5v so you would be out of spec with a 5volt supply.

The midrange only had maximums, the actual 'F87XA has minimums too and
you're right, the minimum for Vref+ is AVdd-2.5v so in my case 2.5 volts
(Vdd is 5v)

> Thirdly, you should be able to get a fixed separation between the buttons irrespective of the reference voltage, by selcting suitable resistors.

Unfortunatly the resistors are selected for me by the car manufacturer,
I cannot change them (I will need to restore the stock radio at some
point)

If it was left to me I'd either implement a bus protocol of some kind or
use a simple R/2R ladder to get maximum spread.

Thanks for your help with this, I guess it's back to the thinking room
on this for a while, I was really hoping to see if I could get a wider
spread by taking Vref lower.

--
Anthony Toft <@spam@toftatKILLspamspamcowshed.us>
    I'm Anton, and I approve this message

2005\06\09@073837 by Gerhard Fiedler

picon face
Michael Rigby-Jones wrote:
> Anthony Toft wrote:
>> I really like the resistor selection I have right now as the 8 buttons
>> are giving ~10% separation. If I go to 3v then I will have ~7%
>> separation.
> [...]
> Thirdly, you should be able to get a fixed separation between the
> buttons irrespective of the reference voltage, by selcting suitable
> resistors.

If you sent us some real values and how you want to connect them (something
like a quick ASCII draft), you'd probably get some better advice. I think
there's no reason here for the reference voltage limits being a problem.

Gerhard

2005\06\10@074857 by Anthony Toft

flavicon
face
> If you sent us some real values and how you want to connect them (something
> like a quick ASCII draft), you'd probably get some better advice. I think
> there's no reason here for the reference voltage limits being a problem.


The car is set up with 8 buttons looking like this...

+--- ... -/\/\/\-+-/\/\/\-+-/\/\/\---- 12v (hot in run or accy)
|                     |            |
\                     \          \
|                     |          |
+----------------+--------+----------> to the ADC circuit

The actual values from the circuit diagrams are (in Ohms)

before Switch               R        Total R
       1                1270        1270
       2                294        1564
       3                348        1912
       4                475        2387
       5                715        3102
       6                1180        4282
       7                2370        6652
       8                6980        13632

I am treating it as a variable resistor with discrete values, I have nor
seen a pattern in the resistors.

I have found the based on the switched resistance, 470 Ohms on the
bottom side of the divider makes for 0.34v difference between each
switch, if I use 470 Ohms on the Vref+ the voltage runs to about 3.4v
making the difference 10% and this viable solution.

One question is how much of a noise cancelling effect can I expect by
feeding the noise into Vref+ as well as RA0?

Thanks for all the help guys, this part of the project has proven to be
the hardest by a long shot, but once it is done, the project is finished
and I can work on the next idea.
--
Anthony Toft <KILLspamtoftatKILLspamspamcowshed.us>
    I'm Anton, and I approve this message

2005\06\10@082526 by Alan B. Pearce

face picon face
>One question is how much of a noise cancelling effect can
>I expect by feeding the noise into Vref+ as well as RA0?

You are better off filtering the RA0 input. You may find that you need to
take two or three readings to get a stabilised value if you are expecting
things to happen fast, but I would have thought this is the sort of use
where the person keeps their finger on the button until the desired action
happens, so speed is not essential, so a longish (1/10 to 1/4 sec?) time
constant on the filter would be fine.

2005\06\10@092904 by olin piclist

face picon face
Alan B. Pearce wrote:
> You are better off filtering the RA0 input. You may find that you need
> to take two or three readings to get a stabilised value if you are
> expecting things to happen fast, but I would have thought this is the
> sort of use where the person keeps their finger on the button until the
> desired action happens, so speed is not essential, so a longish (1/10
> to 1/4 sec?) time constant on the filter would be fine.

I agree about the filtering, but not so sure that 250mS might not be
annoying.  I guess it depends on exactly what the user expects to happen.

The tricky part of the filtering will be that the step response needs to be
matched between the data signal and the supply reference, otherwise glitches
will look like valid signals.  This is why I would do only relatively fast
filtering in analog, just to smooth out the nasty spikes and avoid aliasing
in the A/D.  Maybe a two pole filter on each signal that has a 90% step
response around 5mS.  Sample each A/D input as fast as possible, say one
sample every 200uS (1000 instructions on 20MHz PIC).  That means each signal
is sampled every 400uS.  Now do a digital filter on each signal with a 90%
step response around 20-25mS.  One pole shifting 4 bits and another shifting
3 bits comes out close enough.  That gives you about a 93% step response in
50 iterations or 20mS.  Since these final slower filters are digital, they
will be exactly matched.

Now that the filtered digital values are available, the code can come along
every 1 or 2 mS and do the divide to recover the single value.  It won't
recognize a valid state until the resulting level has been within 5-10% of a
valid level for 25mS.  That will prevent triggering on intermediate states
as the filtered values slew from one end to the other.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

2005\06\10@195008 by Anthony Toft

flavicon
face
> > You are better off filtering the RA0 input. You may find that you need
> > to take two or three readings to get a stabilised value if you are
> > expecting things to happen fast, but I would have thought this is the
> > sort of use where the person keeps their finger on the button until the
> > desired action happens, so speed is not essential, so a longish (1/10
> > to 1/4 sec?) time constant on the filter would be fine.
>
> I agree about the filtering, but not so sure that 250mS might not be
> annoying.  I guess it depends on exactly what the user expects to happen.

Action will happen at button release (and one action per release) what I
had planned on doing was...

Sample as fast as possible, normally this will yield 0's (no button
pushed) On button push, start counting how many times the value falls
inside each range of values (ie button 1 is 5-25) once the button goes
back to 0 (for a few samples to debounce) take the button with the most
samples recorded in range as the pressed button. So if say b3 was pushed
then there'd be low numbers in b1 and b2 counts (from the rise and
fall), a higher number in b3 (because your thumb is not momentary
contact) , perhaps a few in b4 from something funky going on, but from
the counts b3 is it and it gets sent once the values have returned to
zero (or near). I think if I can just smooth RA0 a bit I won't have to
do too much fancy work inside the PIC.

--
Anthony Toft <RemoveMEtoftatTakeThisOuTspamcowshed.us>
    I'm Anton, and I approve this message

2005\06\10@200930 by Bob Ammerman

picon face
The below sounds like an excellent algorithm. I would still use the
ratiometric concept by connecting the Vref to a voltage divider to the same
+12 signal as the inputs are based on.

Bob Ammerman
RAm Systems

{Original Message removed}

2005\06\11@080014 by Gerhard Fiedler

picon face
Bob Ammerman wrote:

>> Sample as fast as possible, normally this will yield 0's (no button
>> pushed) On button push, start counting how many times the value falls
>> inside each range of values (ie button 1 is 5-25) once the button goes
>> back to 0 (for a few samples to debounce) take the button with the most
>> samples recorded in range as the pressed button.

> The [above] sounds like an excellent algorithm.

I would not use the full range for each button as criterion, but rather a
reasonable range around the "correct" values and discard points that are
outside all ranges. Using a ratiometric method, your measurements should be
very close to the "correct" value, with only noise (but not battery voltage
changes) to be considered.

> I would still use the ratiometric concept by connecting the Vref to a
> voltage divider to the same +12 signal as the inputs are based on.

Definitely seconded... could look like this:


12V -----+----------+-----------+
        |          |           |
        R3         R5          R1
        |          |           |
        +-Vref+    +-Vref-     +-ADCin
        |          |           |
        R4         R6          R2
        |          |           |
Gnd -----+----------+-----------+

R1 is your "variable" switch resistor. R2 you select so that ADCin has a
nice range (within the maximum range of 0...5V) and nice steps. R3/R4 you
select so that Vref+ is a little bit over the maximum of ADCin, and R5/R6
you select so that Vref- is a little bit below the minimum of ADCin.

For noise cancelling it is important that you take the 12V feed for R3 and
R5 from as (electrically) close as possible to the 12V feed for your
switched R1. This gives you two filter locations:

12V ----------------------------+
                               |
        +----------------------+
        |                      |
      Filter                   R1
        |                      |
        +----------+         Filter
        |          |           |
        R3         R5          |
        |          |           |
        +-Vref+    +-Vref-     +-ADCin
        |          |           |
        R4         R6          R2
        |          |           |
Gnd -----+----------+-----------+

The two filters should be identical (take the different load resistance
into account if that makes a difference for your filter).

The ratiometric effect is pretty independent of the filtering (as long as
both filters are the same) and should give you much more stable readings.
It is not practical to use a signal derived from the car's 12V without
referencing it to the 12V -- the 12V nominal can be anything from 10V to
15V under normal conditions, and within an even larger range under marginal
or rare conditions.

Gerhard

2005\06\11@082620 by olin piclist

face picon face
Gerhard Fiedler wrote:
> 12V -----+----------+-----------+
>          |          |           |
>          R3         R5          R1
>          |          |           |
>          +-Vref+    +-Vref-     +-ADCin
>          |          |           |
>          R4         R6          R2
>          |          |           |
> Gnd -----+----------+-----------+

I don't see any reason Vref- shouldn't just be tied to ground.  All signals
are ground-referenced.  This also leaves a larger range for Vref+ and is
less complex.

{Quote hidden}

Note however that R1 varies and therefore that filter will have to be
independent of its source impedence.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

2005\06\11@134436 by Anthony Toft

flavicon
face
> I would not use the full range for each button as criterion, but rather a
> reasonable range around the "correct" values and discard points that are

I was envisioning bands of valid values, each band centered around the
nominal value of a button.

If the noise is small enough that it won't encroach into another buttons
band then I won't filter it.

> outside all ranges. Using a ratiometric method, your measurements should be
> very close to the "correct" value, with only noise (but not battery voltage
> changes) to be considered.

Yep, I am sold on this :)

> select so that Vref+ is a little bit over the maximum of ADCin, and R5/R6

yes the minimum the "top side" resistor can be is 1270 Ohm, I am using
1200 Ohm for Vref+ so AN0 gets to 2.8v and Vref+ is about 3.1v

> you select so that Vref- is a little bit below the minimum of ADCin.

vref- is Vss...

--
Anthony Toft <spamBeGonetoftatspamBeGonespamcowshed.us>
    I'm Anton, and I approve this message

2005\06\12@093953 by Gerhard Fiedler

picon face
Olin Lathrop wrote:

>> 12V -----+----------+-----------+
>>          |          |           |
>>          R3         R5          R1
>>          |          |           |
>>          +-Vref+    +-Vref-     +-ADCin
>>          |          |           |
>>          R4         R6          R2
>>          |          |           |
>> Gnd -----+----------+-----------+
>
> I don't see any reason Vref- shouldn't just be tied to ground.  All signals
> are ground-referenced.  This also leaves a larger range for Vref+ and is
> less complex.

The effective ADC resolution is a bit higher. Not much in this case though
(around 10% increase). I don't see how this would affect Vref+ at all, and
the increase in complexity is only two resistors.

With the values given (R1=1270 Ù..13632 Ù), R2 could be something like 500
Ù. That gives for ADCin a range of roughly 0.6 V..4.5 V @ 16V (assumed
highest voltage) or 0.4 V..3.4V @ 12V. There's not much of a point in being
able to measure voltages below the lower limit, so Vref- could be set to
that voltage (or of course a bit below), with a small gain in resolution --
which probably is not really relevant in this case. But I don't see how it
could hurt.

Gerhard

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