LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

look up table

I am doing analog to digital conversion in 'c' on a pic18f4620 controller. However, I do not wanna work on a look-up table on pic controller; I want to make a lookup table in LABVIEW instead. One column of my excel sheet contains the temperature values and the other column contains the corresponding voltage values sent by the pic controller to the serial port through RS232 cable. I am a newbie to NI, and would like to get any help possible.
0 Kudos
Message 1 of 9
(9,599 Views)
 

Doing a lookup on a relatively small number of values should be no problem using standard array functions -

  1. Save your excel column as a sorted CSV file.
  2. Use the Read From Spreadsheet File VI to read the data into a LabVIEW array.
  3. Use the Index Array function to get the first column (0) and search it using the Search 1D Array VI.
  4. Use Index Array on the original array to extract the element from index (i,1) where i is the result from the search.

There are some potential problems with this (large arrays, searching would be worthless on floating point numbers unless your values precise), but this covers the basic way. There are also more clever ways.

The real question is whether you can communicate this data back and forth to the PIC easily?

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 2 of 9
(9,596 Views)
I am just getting the voltage value corresponding to my temperature which the pic is throwing to the rs232 port of the pc. The only task I need to perform is to find that voltage value in the table and show the corresponding temperature in the waveform chart. I do have a large array of table comprising of 100 values including floating point numbers. I am communicating back to the pic to get the next voltage value for new temperature.
0 Kudos
Message 3 of 9
(9,591 Views)
Hi tst,

Thanks a lot for promt response. I just figured out that my table in excel is formed using the formulae. In other words, two columns in excel which I wanna compare are inter-related with a formula. So I was wondering if I can just create a sub vi using the formulae to get my corresponding values rather than searching in the look-up table. I tried it and it works. However, I haven't merged it with my original vi I am currently working on. So, I would like to know if it is better to use look-up table or just formula to achieve the results from the accuracy and latency point of view? What does your experience say?

Thank you.


0 Kudos
Message 4 of 9
(9,582 Views)
Well, a lookup table of size 100 is not large, so memory considerations should not be an issue. How complicated is the formula? (e.g.: Just a few elementary operations or a complex iterative procedure?)
 
How smooth is the curve? Do some tests and e.g. calculate it for 1000 values covering the range of the lookup table and compare the formula and interpolation results.
 
If the formula is computationally simple and good precision is required, a formula will always be better.
0 Kudos
Message 5 of 9
(9,585 Views)
Hi Altenbach,

The formula consists of non-linear exponentially decaying function. I am attaching the formula. I havent implemented this formula in my vi yet. I would like to know what is the better choice-look-up table or just the implementation of formula. My lookup table size may increase than 100; i am not sure.
0 Kudos
Message 6 of 9
(9,570 Views)
If I understand correctly (and if I didn't make a mistake with all those parentheses), you can do this by using T=(((ln(Rt/Rh)/B)+(1/Th))**-1); in a formula node.
Of course, you could also do it with native LV nodes. I'm not sure which would be quicker, but I don't know if that matters. I assume that LV should be able to this fast enough for you, since the speed of the serial communication would probably limit you more than LV on this.
 
As mentioned, unless you need to be very fast and are\or are working with very large data sets, you should use the formula and not the lookup table.

___________________
Try to take over the world!
0 Kudos
Message 7 of 9
(9,547 Views)
Which one is the independent variable?
 
Since you seem to consider a 1D array as lookup table, there should be only one independent variable. Most likely your can even precompute some subcalculation of the formula (e.g. "ln(Rt/Rh)" or "1/Th"), making it even faster. Go with the formula. 🙂
 
0 Kudos
Message 8 of 9
(9,534 Views)
Alright guys...its working.....thanks a lot......
0 Kudos
Message 9 of 9
(9,519 Views)