Discussion in 'General Electronics Chat' started by keaster, Apr 28, 2013.

1. ### keaster Thread Starter New Member

Apr 28, 2013
11
0
I've been searching to solve a small problem but cant find my answer, I don't really know what to search for so I hope someone can help!

I know when reading something a pot or sensor with ADC the range is 0-5v how can I convert the range when the sensor datasheet states the range is .5-4.8v or is it even possible?

Thanks

2. ### t06afre AAC Fanatic!

May 11, 2009
5,939
1,227
What is important here I think. Is the resolution of the ADC. If the ADC resolution is good enough in the 0 to 5 volt range. You do not have do a job scaling the ADC input. The resolution is equal to (range/(2^n)) n is the number of bits. So for a span of 0 to 5 volt, and 10 bit. The resolution will be 5/1024 volt pr bit

3. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,957
1,827
I wouldn't do a thing beyond giving the A2D a stable 5V reference voltage (that may or may not be the same as the chip power).

You always want a bit of margin in your pocket when doing a conversion, perhaps just to cover cases when one particular sensor outputs 0.45 or 4.9V. You can also use the extremes (0V and 5V) to detect when the sensor is disconnected or just plain failed.

<shrug> True, you do loose a bit of resolution doing this. About 14% </shrug>

4. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,957
1,827
BTW it IS possible to do this. I have seen several PICs that use a high and a low voltage reference for the conversion, so you could get the full resolution in this boxed in range.

You would need a chip like this, and also two stable reference voltages of 0.5V and 4.8V.

5. ### ramancini8 Active Member

Jul 18, 2012
473
145
Eee Op Amps for Everyone available on the TI web site. Chapter 4 shows how to use simultaneous equations and an op amp to accomplish your goal. Also, there is a chapter devoted to a sensor to ADC design with an error analysis. So many errors can be encountered in this type of design that you really need to be careful.

6. ### ScottWang Moderator

Aug 23, 2012
6,458
1,000
Is that you really need to limited the adc range At .5-4.8V?

Because it just more then a couples digits, as 0~0.4V and 4.9V for a 8 bits adc.

If there is no any limitation, then using 0~5V is more easier it just likes that we using the multimeter at 20V range to measuring the voltages 5~15V, the display will only shows the voltage 5~15V.

How many bits would like for the ADC ? (8bits,12 bits)

What is type of sensor, any linking page?

7. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,957
1,827
Perhaps I misunderstood... is this the conversion inside the processor after the reading is taken?

Sure it's possible, many ways. If the sensor is linear you can define an equation for a straight line to match. Other relations of the non-linear type may best be handled by a table, it depends on how complex the relation is.

keaster, are you still there?

8. ### keaster Thread Starter New Member

Apr 28, 2013
11
0
Sorry for the delay, thanks for the info but I'm still I but fuzzy on how to solve this problem, I don't the sensor I'm just going by what the specs say
So this problem should be solved with some math after a reading?

9. ### THE_RB AAC Fanatic!

Feb 11, 2008
5,432
1,312
That is usually the best (easiest) way.

The sensor value probably needs math to convert it to it's real world units (like temperature in degrees), so doing an extra bit of math to offset your 0.5v bottom offset is trivial.

10. ### keaster Thread Starter New Member

Apr 28, 2013
11
0
I have another scenario, what is the output for example a hall effect sensor voltage range is 0.8v - 4.8v how can it be converted to swing 0-5v I read something about using a rail to rail op amp to convert it or is this something that can be done in software?

Thanks

11. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,957
1,827
You need to make an amplifier that also subtracts an offset:

Vo = 1.25 * (Vin - 0.8)

Or... you can apply a similar formula in software (which is how I would do it).

12. ### keaster Thread Starter New Member

Apr 28, 2013
11
0
Thanks for the info, that simple formula is all I need ?

13. ### GetDeviceInfo AAC Fanatic!

Jun 7, 2009
1,615
238
It's possible but typically there is no need. As mentioned, resolution, and particularly, linearity will be you major concerns. I've run load cells through PLC based converters, then had Labview sort out any logarithmic requirements.

14. ### keaster Thread Starter New Member

Apr 28, 2013
11
0
Would you be able to share such similar formula?

15. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,957
1,827
I cannot. While you have shared the sensor output voltage range we are clueless to know what the sensor output represents.

16. ### keaster Thread Starter New Member

Apr 28, 2013
11
0
What does that even mean? what the 'sensor output represents'? its a hall effect sensor that outputs a voltage range from .8 - 4.8v with a vdd of 5v I would like to know how to convert the sensors output to 0-5v to read it into an adc pin on a pic16f887

17. ### nsaspook AAC Fanatic!

Aug 27, 2009
5,051
5,523
Most single supply open-loop Hall current sensors use 1/2 the supply voltage as the zero current set-point.

http://www.ampsense.com/HANDBOOK%20web.pdf

Basic measurement method:
Record the ADC reading with zero current, this will be the zero set point value. With current flowing the ADC reading change from the zero null value can be scaled to the correct current using the mV/A sensitivity of the sensor.

Last edited: May 16, 2013