Jump to content

Find a row in a DTI (data table indexed) table


LPK

Recommended Posts

Hi all,

I have been trying to use the "Find value in DTI column" to find a value in a column, then return a row full of values from the row that the value is found in.

The data table has loaded fine (I checked it using the Online mode) and it contains values of temperature and pressure. I can get a row of data out of it (and display it) using the "Read row from DTI" function. I can’t, however, use the "Find value in DTI column" function as I imagine it was intended.

I was expecting to give it a value, say a temperature I was measuring (all three columns of data are of the Real data type and so was the value passed to the function), and it wold return a row from the table. I passed the correct table to the function, passed the correct column from the struct that the data table is "made of", I passed it a value (of the same type as the data in the table and within the limits of the table data, which has values which ascend with temperature), got it to search from row 0, and asked it to search once (why would you want it to do it more times?)

It doesn't seem to be working, though, and when I check in online mode, it’s constantly returning a row value of -1. Does anyone have any ideas of anything else I can try, or if I’m using this wrong? Since I can’t use loops, as the ladder doesn’t seem to have such things, I’m not sure what else I can try?

Link to comment
Share on other sites

Hello, thank you for using our Unitronics Forum,

To clarify, the E parameter is the number of rows to search (starting from row 0).  Not the amount of times it will search a particular row.  I will lay out the parameters below:

    Parameter A: The data table you wish to look in
    Parameter B: The column of the data table you wish to look in
    Parameter C: The value you are searching for
    Parameter D: The starting row you wish to begin your search
    Parameter E: The number of rows you wish to search from row 0 (not from your starting row declared in parameter D)
    Parameter F: The row index the value was found

Therefore, if you start you search from row 2 (Parameter D = #2) and you want to search for your value for 3 rows from the starting row, Parameter E would need to be a 5 (since it starts its count from row 0). We understand this is a bit misleading so we have alerted our team in Israel about this issue.


Please let us know if this helps or if anything my explanation is unclear. 

Link to comment
Share on other sites

Ah, good, that makes more sense and it seems to be working now. I’d definitely be happier with a description like your own to be added in.

Could I ask a few more things?
Would there be any problems with asking the function to return more rows than there are in the table, or would it gracefully exit without error and go on to the next thing?

It’s looking like a perfect match is required (-1 is returned if there is not a perfect match), rather than where the row number returned is the first row where the value in the nominated column equals or exceeds the provided value. Is there an alternative function/method that I could use to search through some (ordered) data and return the first row where the value in a column meets or exceeds an input value? This was what I was really after here.
 
Is the help likely to be expanded so that it contains more thorough descriptions of the function blocks available? I often find the very brief few-word descriptions given when you hover over the functions to be hard to understand. The help does not seem to contain detailed descriptions of many of the functions, compared, even, to earlier products like VisiLogic, so I have been left struggling/guessing how to do things.
 
I have perhaps been spoilt by very usable IDEs with exceptional access to help (like Matlab, for instance), which has thorough descriptions about inputs and outputs / function results, together with examples, and makes it easy to find help on a great many functions via a variety of means, including context-sensitive help on functions.
Link to comment
Share on other sites

Our team is always trying to update and enhance our help files.  I will pass this feedback along to them as they are working on the help files and will continue work on them. 
As for the Find Value function block, this was intended to find matches.  Is it possible to read the row from a data, then use a compare function block to compare the column you are monitoring to set a bit? 

Link to comment
Share on other sites

Hi Shane,

 

Yes, I think that I've managed to achieve something that works, but it seems far more complex than the way I'd be used to doing it - in "normal" programming, I'd have put in a loop to iterate through the table until the right data was found (using comparators, as you say), then exit the loop once the data was found and do my data table interpolation at that point, but hanging the ladder up doing a loop like this seems to be against the general principles of ladder programming, where you want to continue scanning all parts of the ladder(s), rather than getting (temporarily) stuck in one part.

 

I’ve even seen someone (IIRC) saying that if you do this it might cause a timeout, and when I tried making something more like a do/while loop, by getting two ladder functions to call each other alternately, and sort of recursively, until the value was found in the table (which also caused a “circular call (loop)” warning) I may have got some kind of timeout, as there was a warning given on the screen that the CPU had stopped.

 

The only thing is that doing it the way I have, with each scan iterating the row index up by one until the correct row is found can take many scans to complete when the data table is large.

 

I can’t use the current “Find Value in DTI Column” function as the data’s not always in regular increments, and the value I’m looking for may fall between the table values (thus the interpolation).

 

It would be very good (and probably much faster than my ladder implementation) to have a function block that could look through a table and find the first row in a certain column where the value is greater than or equal to an input value, and maybe another also greater than a value.

 

Either that, or it’d be great to be able to create functions that could be dropped into the ladder rungs like the existing ones.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...