Pages: [1]   Go Down
Author Topic: Look-up Table  (Read 889 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
I use the analog Inputs from the Duemilanove Board (10bit).
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?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 17, 2009, 12:58:25 pm by mem » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

temperature range will be between 0-50°C.
i don`t know the values of the Aneometer first i have to build it smiley
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.
For example:    500(analoginput value)=30°C.
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.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: