Lookdown and Strange Return Value
TJHJ
Posts: 243
Ok So I am trying to get this thermocouple thing to work and my most recent thought is to use a lookdown table useing the known voltages.
But it does odd things. To create a search method of sorts it adds until it finds a match, not the best, but I am ok with a premant rounding up solution.
The table is very large it has approx 1500 data points.
It works if I call Look(0037) or Look(37) It returns 1, as it should,or Look(0075) Gives 2.
But if I put in Look(0030) it returns 857. Or Look(0031) gives 82.
And Ideas what is going on here?
Thanks as always
TJ
But it does odd things. To create a search method of sorts it adds until it finds a match, not the best, but I am ok with a premant rounding up solution.
The table is very large it has approx 1500 data points.
PUB Look(Vi) | Table Table := 0 Table := Lookdown(Vi:0,0039,0079,0119,0158,0198,0238,0277,0317,0357,0397,0397,0437,0477...... Repeat Vi := Vi+1 Table := Lookdown(Vi:0,0039,0079,0119,0158,0198,0238,0277,0317,0357,0397,0397,0437,0477..... If Table > 0 Quit Return Table-1
It works if I call Look(0037) or Look(37) It returns 1, as it should,or Look(0075) Gives 2.
But if I put in Look(0030) it returns 857. Or Look(0031) gives 82.
And Ideas what is going on here?
Thanks as always
TJ
Comments
The table starts with the first value greater or equal to v.
Where does the data in your table come from? If it's mathematically-defined, perhaps a formula (either continuous or piecewise continuous) would provide a more compact way to arrive at the desired result.
-Phil
I bet it's finding your values 30, 31 in the table somewhere... Try examining V1 during the iterations to see what's happening...
Who knows, you may have found a bug... Or, maybe theres a mistake in your table.
Or, maybe the memory space for the table is being corrupted somehow...
You might try a test look for the last entry in the table and see if that works right...
What Do you guys think?
So I ended up creating the table to 1500 degrees, even though they limit out at accuracy at somewhere around 1350.
Post Edited (TJHJ) : 5/31/2008 1:21:14 AM GMT
Yeah sorry I have been expermenting and was dumping the 1st lookup value out to a screen just to see if it was finding something before the actuall seach began. Its not needed but I was useing it for examination. Thanks for the help.
I hope it is not a bug, but on the upside I would know I am not insane.
Thanks for all the help as always.
TJ