# I Can i get a mathematical function out of this picture?

1. Jan 18, 2017

### Bayoudh101

i am working for a small project at home , and for it i am using an infra red sensor . which returns a voltage value relative to distance .
this picture describes the output : (given by the datasheet) :

(the picture is highly precise)

now all of the distances that i will be getting are superior than 8cm so it's a bijective function for me . within the micro-controller , the only solution that was able to find is to make a large array of floats with segments of voltage and the corresponding distance values . i need high precision with this project so that solution would consume a massive amount of memory and would cut down from other of the project's aspects .
is there anyway i can find a function that mimic with good precision the behavior of the evolution these values ?
thank you .

Last edited by a moderator: Jan 18, 2017
2. Jan 18, 2017

### dkotschessaa

Picture did not seem to come through. Can you re-attach?

3. Jan 18, 2017

### Bayoudh101

done , thank you for responding sir .

4. Jan 18, 2017

### Staff: Mentor

What does "high precision" mean? The visible corners in the graph look like measurements artifacts. If you can see deviations from a smooth curve by eye, it cannot be that precise.

You can store some values and then make linear interpolations between them.

You can try exponential decays, 1/x, 1/x2 functions and so on, but they won't beat the accuracy of linear interpolations - if you measurements are all really accurate.

5. Jan 18, 2017

### Bayoudh101

thank you sir .

6. Jan 18, 2017

### Staff: Mentor

Make a linear interpolation table of the graph. Where things are relatively flat (ie same slope) you can space the x,y points further apart and where things change you can select more x,y points.

Some examples are provided in the article:

https://en.wikipedia.org/wiki/Interpolation

7. Jan 18, 2017

### Stephen Tashi

Do you also need flexibility? For example, will the actual curve on the device change as the component ages? Will you need to calibrate the system if you use a new type of paper?

8. Jan 18, 2017

### Svein

The curve looks like $xe^{-x}$...

9. Jan 18, 2017

### Nidum

Use electronics to linearise the sensor response .

Last edited: Jan 18, 2017