Lookup values

Recommended Posts


i have the lab jack U3 HV and have bought a license for Daqfactory.

i want to control an output to a electronic pressure regulator based
on a voltage contained in a column of values against a column of time increments (currently in excel)

i would really appreciate some advice and perhaps you could point me
at some information etc that would help me with this.


Sounds like you want to use a lookup table?  First, you'll need to load the document from excel.  That requires only a few lines of script.  But first you have to save your Excel document as a CSV file.  Then the script is:

private handle = file.open("c:\data\myFile.csv",1,0,0,1)
global lookup = file.readDelim(handle, -1, ",", chr(10), -1)

If you have a header row, add a file.read(handle) above the global lookup... line.

Now your file is in the lookup variable accessible from anywhere.  To lookup a value, use the search() function.  Lets say that you want to look up a value in the first column of the excel spreadsheet and that column is listed in numeric order from smallest to largest.  You'd do something like:

private index = search(lookup[][0] >= val)

where val is the value you are looking up.  Then use index to retrieve the corresponding value in the second column:


Link to comment
Share on other sites

  • 8 months later...

I am trying to do something similar to the above on LJ T7 pro.  Twice per day I want to log a value from a temperature sensor.  Then I want to operate some valves based om the logged data.  Is there a way to script this without going to excel?  I know how to write the valve script in terms of usung a set value that I write in (when Itake the temp data and log it in my head as say 73 deg, I set the valves to function off this data.). 

Much easier to script it to automate that for me but not sure how.



Link to comment
Share on other sites

Excel was used in the original post simply as a quick way to generate the table.  What you describe isn't a lookup table, just an evaluate of a value.  Since the value is already in DAQFactory, you can just do the calculation right when you log it.  To log it you might use an export set with [0] in the expression.  Then you might do something like:

   delay(43200) // wait half a day
   if (temperature[0] < 73)
      valve = 1
      valve = 0

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.