Go Down

### Topic: Look-up Table (Read 1 time)previous topic - next topic

##### Mar 17, 2009, 06:07 pm
Hello,

can someone explain me the basics how to make a look-up table for a sensor.
I have no problems with wiring.
I only have no clue how to make the software part.
Thanks

#### mem

#1
##### Mar 17, 2009, 06:12 pm
There are many ways to do it. It will be easier giving you an answer if you could say a little about your project and the purpose and size of your table.

#2
##### Mar 17, 2009, 06:33 pm
Okay i try to.
I will creat a look-up table for 2 sensors. the first one is a KTY81-200 and the second will be a selfmade Aenometer.
If it is possible the table shouldn`t be stored in the Ram.
Is it possible to store it in the flash memory?
My first idea is making an arry for the analog values(0-1023), if this is the wrong way please correct me.
But in this case i have to store 1024 values is there any better way to do this?

#### mem

#3
##### Mar 17, 2009, 06:57 pmLast Edit: Mar 17, 2009, 06:58 pm by mem Reason: 1
There are two parts to the task. One is how you design the table, the other is how you store and retrieve the data. You are correct that flash would be needed to store a table of 1024 values but it may not be necessary to have that many values.

For example if the temperature sensor is only accurate to 1% and you are measuring a temperature range of less than 100 degrees C then you may only need 100 integer values.
But rather than us guessing what you want to do, why not say a little more about the data you expect to get and what you want the table to do.

#4
##### Mar 17, 2009, 07:31 pm
temperature range will be between 0-50°C.
i don`t know the values of the Aneometer first i have to build it
I want to to compare the Analog input with the look-up table and get the real temperature back.
So the look-up table have to store the analoginput value and the "real" temperature value.
i haven`t decide if i take the whole 1024 for 0-50°C or not.
i'm interessted in the basics how to make such a look-up table.

#### mem

#5
##### Mar 17, 2009, 08:13 pm
One way is to have an array of raw values for each of the temperatures in the range of  0-50°C.  To make things simple, lets say that you store the 51 expected values from anlaogRead for each of the degrees within the range.

Your sketch would then get the actual value from analogRead and search through the array until it found an entry that was equal to or greater than the value.  If the value is exactly the same, you can use this directly. But if the value is between two array entries, you could interpolate the temperature. (you should find lots of info on how to do that if you need fractional temps)

I hope that helps.

Go Up