EmbeddedRelated.com
Forums

MPX pressure sensor & PIC math

Started by bergweed November 24, 2004

--- In , "Phil" <phil1960us@y...> wrote:
...
> Note the spec for sensitivity. that gives you 45.9 mV/kPa. so,
> picking 4.7V (45.9*1023 = 4.696) as your Vref for a 10 bit ADC will

dang, that should read:
picking 4.7V (45.9*1023/10 = 4.696) as your Vref for a 10 bit ADC will





Thanks to the group for the help.
Once the turkey wears off, you folks really get sharp <grin>.
Some interesting suggestions how to tackle this problem.

To summarize, we can either get it done with more complex software or
by adding hardware - in this case an adjustable voltage regulator and
tweaking the sensor supply.
Cool.

73 Mike





--- In , "bergweed" <mikeberg@r...> wrote:
>
> Thanks to the group for the help.
> Once the turkey wears off, you folks really get sharp <grin>.
> Some interesting suggestions how to tackle this problem.
>
> To summarize, we can either get it done with more complex software or
> by adding hardware - in this case an adjustable voltage regulator and
> tweaking the sensor supply.
> Cool.
>
> 73 Mike

reasonable summary. I would not use a regulator but rather a voltage
ref and a couple of precision resistors. Usually better temp
stability. Zetex and ST make some decent ones that are very cheap
($.30 for the ST TL431 for example). If you dont care that much about
accuracy, you could just use a simple multiturn trimpot as a divider
to get your reference.

Note also that your accuracy will also be dependent on your voltage
supply which unless you take a lot of care can be off as much as +/- 10%.

Finally, ADC requires a lot of care with the analog section. Its easy
to get a situation where you see error/fluctuations of +/- 3 LSBs or
more. Kind of ruins your accuracy.

Phil





I'm using the TL431 at work right now, and I'd suggest rather than
using precision resistors, just add in a variable resistor instead.
Using 25K per side (see the suggested circuit for making variable
zener), and a 2K 25turn resistor, I could get accuracy to 0.001 Volt
(more, but the voltmeter wasnt that accurate). Im not sure how
temperature sensitive it would be, but man do thoes ever work slick
for only using up around 5mA of current. --- In , "Phil" <phil1960us@y...> wrote:
>
> --- In , "bergweed" <mikeberg@r...> wrote:
> >
> > Thanks to the group for the help.
> > Once the turkey wears off, you folks really get sharp <grin>.
> > Some interesting suggestions how to tackle this problem.
> >
> > To summarize, we can either get it done with more complex
software or
> > by adding hardware - in this case an adjustable voltage
regulator and
> > tweaking the sensor supply.
> > Cool.
> >
> > 73 Mike
>
> reasonable summary. I would not use a regulator but rather a
voltage
> ref and a couple of precision resistors. Usually better temp
> stability. Zetex and ST make some decent ones that are very cheap
> ($.30 for the ST TL431 for example). If you dont care that much
about
> accuracy, you could just use a simple multiturn trimpot as a
divider
> to get your reference.
>
> Note also that your accuracy will also be dependent on your voltage
> supply which unless you take a lot of care can be off as much as
+/- 10%.
>
> Finally, ADC requires a lot of care with the analog section. Its
easy
> to get a situation where you see error/fluctuations of +/- 3 LSBs
or
> more. Kind of ruins your accuracy.
>
> Phil





--- In , "sirtiffguy" <sirtiff@h...> wrote:
>
> I'm using the TL431 at work right now, and I'd suggest rather than
> using precision resistors, just add in a variable resistor instead.
> Using 25K per side (see the suggested circuit for making variable
> zener), and a 2K 25turn resistor, I could get accuracy to 0.001 Volt
> (more, but the voltmeter wasnt that accurate). Im not sure how
> temperature sensitive it would be, but man do thoes ever work slick
> for only using up around 5mA of current.
>

I've used similar for Vref. Horrible temperature stability but they
sure are easy to use. I've seen tricks where one puts a low value,
high wattage resistor next to the pot to act as a heater to keep a
reasonable stable temperature. You have to calibrate after 15 mins of
operation or so. Doesn't work well for battery equipment, though.

Using a decent trimmable Vref chip isn't that much more effort or cost.





Hi Guys

I use voltage references extensivly throughout our precision
industrial instrumentation range.
TL431/LM431 etc will work on 1mA and temperature drift is in the
order of 10's of parts per million per degC. They are very cost
effective too.
They are rock stable for most applications.
What you MUST be careful of is the capacitance across it must NOT be
in the range 10nF<>10uF (it must be equal to or greater than 10uF or
less than 10nF)or it will likly become unstable .. even oscillate.
This may at first appear to be a wavering voltage level.

Lance
ICM

--- In , "Phil" <phil1960us@y...> wrote:
>
> --- In , "sirtiffguy" <sirtiff@h...> wrote:
> >
> > I'm using the TL431 at work right now, and I'd suggest rather
than
> > using precision resistors, just add in a variable resistor
instead.
> > Using 25K per side (see the suggested circuit for making
variable
> > zener), and a 2K 25turn resistor, I could get accuracy to 0.001
Volt
> > (more, but the voltmeter wasnt that accurate). Im not sure how
> > temperature sensitive it would be, but man do thoes ever work
slick
> > for only using up around 5mA of current.
> >
>
> I've used similar for Vref. Horrible temperature stability but
they
> sure are easy to use. I've seen tricks where one puts a low
value,
> high wattage resistor next to the pot to act as a heater to keep a
> reasonable stable temperature. You have to calibrate after 15
mins of
> operation or so. Doesn't work well for battery equipment,
though.
>
> Using a decent trimmable Vref chip isn't that much more effort or
cost.




I used the following equations (which coded in asm) with a MPX4115A
(in a 867 case) with great success. These are based on the equation
given in the Motorola datasheet. Note that I scaled everything so
that the division would be easy (trivial in fact!) in asm *and*
integer math will provide a result that is scaled up by 100 so it
contains two decimal places. I'm using the 10 bit AD value in the
calculation and if you convert the 32 bit binary result to BCD the
lowest byte (two BCD digits) will be the decimal portion.

millibar = (AD * 1111 + 10809) / 1024
inHg = (AD * 3281 + 319186) / 1024

These are from the comments in my code. I actually used the "inHg"
equation and it provides values as accurate as the device is (which
really isn't *that* great -- +/-1.5kPa). I beleive the millibar
equation is correct but it is untested.

As for the circuit, I simply used a bypass caps like shown in the
Motorolla datasheet. That is, I put a 1.0uF and .01uF cap on the
supply pin, with the supply being the same regulated 5V supply rail
the PIC uses, and a 470pF cap on the output pin. Measurements are stable.

Let me know if how this works.

--Scott
--- In , "bergweed" <mikeberg@r...> wrote:
>
> Thanks to the group for the help.
> Once the turkey wears off, you folks really get sharp <grin>.
> Some interesting suggestions how to tackle this problem.
>
> To summarize, we can either get it done with more complex software or
> by adding hardware - in this case an adjustable voltage regulator and
> tweaking the sensor supply.
> Cool.
>
> 73 Mike





I hope to start a project using the same MPX4115A sensor, would you
care to share your working code ? I don't want to reinvent the wheel.
Max

--- In , "Scott Lee" <midl_man@y...> wrote:
>
> I used the following equations (which coded in asm) with a MPX4115A
> (in a 867 case) with great success. These are based on the equation
> given in the Motorola datasheet. Note that I scaled everything so
> that the division would be easy (trivial in fact!) in asm *and*
> integer math will provide a result that is scaled up by 100 so it
> contains two decimal places. I'm using the 10 bit AD value in the
> calculation and if you convert the 32 bit binary result to BCD the
> lowest byte (two BCD digits) will be the decimal portion.
>
> millibar = (AD * 1111 + 10809) / 1024
> inHg = (AD * 3281 + 319186) / 1024
>
> These are from the comments in my code. I actually used the "inHg"
> equation and it provides values as accurate as the device is (which
> really isn't *that* great -- +/-1.5kPa). I beleive the millibar
> equation is correct but it is untested.
>
> As for the circuit, I simply used a bypass caps like shown in the
> Motorolla datasheet. That is, I put a 1.0uF and .01uF cap on the
> supply pin, with the supply being the same regulated 5V supply rail
> the PIC uses, and a 470pF cap on the output pin. Measurements are
stable.
>
> Let me know if how this works.
>
> --Scott >
> --- In , "bergweed" <mikeberg@r...> wrote:
> >
> > Thanks to the group for the help.
> > Once the turkey wears off, you folks really get sharp <grin>.
> > Some interesting suggestions how to tackle this problem.
> >
> > To summarize, we can either get it done with more complex
software or
> > by adding hardware - in this case an adjustable voltage regulator
and
> > tweaking the sensor supply.
> > Cool.
> >
> > 73 Mike