MikahB Posted June 25, 2015 Report Share Posted June 25, 2015 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. Link to comment Share on other sites More sharing options...
cantcliff Posted June 26, 2015 Report Share Posted June 26, 2015 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 More sharing options...
MikahB Posted June 28, 2015 Author Report Share Posted June 28, 2015 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 More sharing options...
Paul Rylatt Posted July 7, 2015 Report Share Posted July 7, 2015 Try putting the read and write functions on different rungs/rows. It may be possible that you are getting a timing race by having both functions on the same rung. Allow one function to fully complete before running a different function. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now