Jump to content

Data Table Read Row Always Returns Zero


Recommended Posts

Have a real-time trend that my customer really wants to be able to compare to historic data.  So, I came up with the following plan:

 

- Real-Time Data is stored in a DataTable - call it DataTableCurrent

- Allow User to Save DataTableCurrent contents into a History Data Table called HistOutput1

- When User enables History Trend, every time I write a row to DataTableCurrent, read the row from HistOutput1 with the same Row Number

- Enable Trend Curve for destination Int from HistOutput1

 

And, viola - you get current data overlaying historic data of your choice.

 

Trouble is, every time I run the Read Row From Data Table FB, I get zero as a result.  Here is what I have checked and know for sure:

 

1) HistOutput1 does indeed have the data I want - I can export it to an SD and see exactly what I expect

2) The RowNumber I am trying to read is a valid number - I am using the same variable to write the current row in DataTableCurrent as I am to read the row from history, the two FB's are in the same rung and the variable cannot change

3) There are no data type mismatches - Everything is ML

4) The rung containing the Read Data Table Row is executing as the next FB in line is properly writing data to DataTableCurrent

 

I'm kind of out of ideas as to what I need to check.  From everything I can see, no matter what I do to call this FB I get a zero back.  Screenshot attached of what I have now.  The disabled rung below divides to give me a trend-able number, thought that was the problem but ML403 is always zero.

post-21521-0-71202800-1435261726_thumb.png

Link to comment
Share on other sites

My first instinct is that your row reference is wrong. 

 

Are you taking into account row[0] is your first row? 

Are you absolutely sure that your increment value is on the correct row?

 

Finally, What is stopping you from counting too fast and causing a logic error? That run appears to run every scan.  IF SB399 is on, Check SI 26 for a failure code, if you have 27 or 29 then you have a read, or read line failure respectively.  Reference: Pg 82 (pdf pg 89) of the Visilogic programming manual.

Link to comment
Share on other sites

My first instinct is that your row reference is wrong. 

 

Are you taking into account row[0] is your first row? 

Are you absolutely sure that your increment value is on the correct row?

 

Finally, What is stopping you from counting too fast and causing a logic error? That run appears to run every scan.  IF SB399 is on, Check SI 26 for a failure code, if you have 27 or 29 then you have a read, or read line failure respectively.  Reference: Pg 82 (pdf pg 89) of the Visilogic programming manual.

 

Thanks for the thoughts.  That subroutine is only called when I am writing a new row - to keep scan times as short as possible, only the "check if we are ready to write a new row" logic runs every scan.

 

I'm sure the row number is correct because the DT has 4000 rows and I'm using the same MI54 row number to set the target for the Write Row function.  I will check SI26 to see if anything is there.

Link to comment
Share on other sites

  • 2 weeks later...

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