Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Possible issue found in accesing stored data in table from another table


Collado Nov 12, 2019 11:13 PM

Hi all!

Recently we at work were programming a CR310-WiFi (OS ver Std.9.02), where we stored data at two tables: a 1-minute data, and a 10-minute data.  This second one is populated from 1 minute table, with some output instructions as Sample, Average, Maximum and so on.  Some data were stored as FP2, and others as IEEE4. 

First attempt to perform this was: a) calling table 1-minute, b) extracting values from this table to public (intermediate) variables, and c) calling table 10-minute reading that intermediate variables.   Well, this approach worked fine.

Later, we considered that those intermediate variables were not necessary, and we try to populate the second table directly from the first one, using the "TableName.FieldName()" syntax. For example:

    Average (1,Table1min.data_Avg(1,1),FP2,False)

Surprisingly, some values were output to 10-min table as -7999, 0, INF, etc., and we are sure that no NaN, INF, or similar stuff was introduced as input values.  And some other values were output as expected.

So, we developed a test CRbasic program with two tables, combining two types of input data (Long, IEEE4), three types of stored data (Long, FP2 and IEEE4), two types of output instructions (Sample and Average).  The code is at the end of this post.

We discovered the following: when a value at first table, stored as FP2, is taken as source for an output instruction different from "Sample" in the second table, the final result is calculated as NaN, NaN equivalent for integers (-7999, 2147483647 and so on), zero or other meaningless values. But if source value is stored as Long or Float (IEEE4), calculations are made correctly.

Is this an issue or have we made any mistake?

Thank you in advance.

Regards,

Jose Luis

--------------CODE--------------

'CR300 Series Datalogger
'TestTable2FromTable1.CR300
'--------------------------------------------------------------------

Public n As Long
Public f As Float

DataTable (Table1,1,-1) 'Set table size to # of records, or -1 to autoallocate.
  DataInterval (0,4,Sec,10)
  Sample (1,n,Long)
  FieldNames("n_Long")
  Average (1,n,Long,False)
  FieldNames("n_Long_Avg")
  Sample (1,n,FP2)
  FieldNames("n_FP2")
  Average (1,n,FP2,False)
  FieldNames("n_FP2_Avg")
  Sample (1,n,IEEE4)
  FieldNames("n_IEEE4")
  Average (1,n,IEEE4,False)
  FieldNames("n_IEEE4_Avg")
  Sample (1,f,Long)
  FieldNames("f_Long")
  Average (1,f,Long,False)
  FieldNames("f_Long_Avg")
  Sample (1,f,FP2)
  FieldNames ("f_FP2")
  Average (1,f,FP2,False)
  FieldNames("f_FP2_Avg")
  Sample (1,f,IEEE4)
  FieldNames("f_IEEE4")
  Average (1,f,IEEE4,False)
  FieldNames("f_IEEE4_Avg")
EndTable


DataTable (Table2,1,-1)
  DataInterval (0,20,sec,10)

  Sample (1,Table1.n_Long(1,1),Long)
  FieldNames("n_Long_Long")
  Average (1,Table1.n_Long(1,1),Long,False)
  FieldNames("n_Long_Long_Avg")
  Sample (1,Table1.n_Long(1,1),FP2)
  FieldNames("n_Long_FP2")
  Average (1,Table1.n_Long(1,1),FP2,False)
  FieldNames("n_Long_FP2_Avg")
  Sample (1,Table1.n_Long(1,1),IEEE4)
  FieldNames("n_Long_IEEE4")
  Average (1,Table1.n_Long(1,1),IEEE4,False)
  FieldNames("n_Long_IEEE4_Avg")

  Sample (1,Table1.n_Long_Avg(1,1),Long)
  FieldNames("n_Long_Avg_Long")
  Average (1,Table1.n_Long_Avg(1,1),Long,False)
  FieldNames("n_Long_Avg_Long_Avg")
  Sample (1,Table1.n_Long_Avg(1,1),FP2)
  FieldNames("n_Long_Avg_FP2")
  Average (1,Table1.n_Long_Avg(1,1),FP2,False)
  FieldNames("n_Long_Avg_FP2_Avg")
  Sample (1,Table1.n_Long_Avg(1,1),IEEE4)
  FieldNames("n_Long_Avg_IEEE4")
  Average (1,Table1.n_Long_Avg(1,1),IEEE4,False)
  FieldNames("n_Long_Avg_IEEE4_Avg")

  Sample (1,Table1.n_FP2(1,1),Long)
  FieldNames("n_FP2_Long")
  Average (1,Table1.n_FP2(1,1),Long,False)
  FieldNames("n_FP2_Long_Avg")
  Sample (1,Table1.n_FP2(1,1),FP2)
  FieldNames("n_FP2_FP2")
  Average (1,Table1.n_FP2(1,1),FP2,False)
  FieldNames("n_FP2_FP2_Avg")
  Sample (1,Table1.n_FP2(1,1),IEEE4)
  FieldNames("n_FP2_IEEE4")
  Average (1,Table1.n_FP2(1,1),IEEE4,False)
  FieldNames("n_FP2_IEEE4_Avg")

  Sample (1,Table1.n_FP2_Avg(1,1),Long)
  FieldNames("n_FP2_Avg_Long")
  Average (1,Table1.n_FP2_Avg(1,1),Long,False)
  FieldNames("n_FP2_Avg_Long_Avg")
  Sample (1,Table1.n_FP2_Avg(1,1),FP2)
  FieldNames("n_FP2_Avg_FP2")
  Average (1,Table1.n_FP2_Avg(1,1),FP2,False)
  FieldNames("n_FP2_Avg_FP2_Avg")
  Sample (1,Table1.n_FP2_Avg(1,1),IEEE4)
  FieldNames("n_FP2_Avg_IEEE4")
  Average (1,Table1.n_FP2_Avg(1,1),IEEE4,False)
  FieldNames("n_FP2_Avg_IEEE4_Avg")

  Sample (1,Table1.n_IEEE4(1,1),Long)
  FieldNames("n_IEEE4_Long")
  Average (1,Table1.n_IEEE4(1,1),Long,False)
  FieldNames("n_IEEE4_Long_Avg")
  Sample (1,Table1.n_IEEE4(1,1),FP2)
  FieldNames("n_IEEE4_FP2")
  Average (1,Table1.n_IEEE4(1,1),FP2,False)
  FieldNames("n_IEEE4_FP2_Avg")
  Sample (1,Table1.n_IEEE4(1,1),IEEE4)
  FieldNames("n_IEEE4_IEEE4")
  Average (1,Table1.n_IEEE4(1,1),IEEE4,False)
  FieldNames("n_IEEE4_IEEE4_Avg"

  Sample (1,Table1.n_IEEE4_Avg(1,1),Long)
  FieldNames("n_IEEE4_Avg_Long")
  Average (1,Table1.n_IEEE4_Avg(1,1),Long,False)
  FieldNames("n_IEEE4_Avg_Long_Avg")
  Sample (1,Table1.n_IEEE4_Avg(1,1),FP2)
  FieldNames("n_IEEE4_Avg_FP2")
  Average (1,Table1.n_IEEE4_Avg(1,1),FP2,False)
  FieldNames("n_IEEE4_Avg_FP2_Avg")
  Sample (1,Table1.n_IEEE4_Avg(1,1),IEEE4)
  FieldNames("n_IEEE4_Avg_IEEE4")
  Average (1,Table1.n_IEEE4_Avg(1,1),IEEE4,False)
  FieldNames("n_IEEE4_Avg_IEEE4_Avg")

  Sample (1,Table1.f_Long(1,1),Long)
  FieldNames("f_Long_Long")
  Average (1,Table1.f_Long(1,1),Long,False)
  FieldNames("f_Long_Long_Avg")
  Sample (1,Table1.f_Long(1,1),FP2)
  FieldNames("f_Long_FP2")
  Average (1,Table1.f_Long(1,1),FP2,False)
  FieldNames("f_Long_FP2_Avg")
  Sample (1,Table1.f_Long(1,1),IEEE4)
  FieldNames("f_Long_IEEE4")
  Average (1,Table1.f_Long(1,1),IEEE4,False)
  FieldNames("f_Long_IEEE4_Avg")

  Sample (1,Table1.f_Long_Avg(1,1),Long)
  FieldNames("f_Long_Avg_Long")
  Average (1,Table1.f_Long_Avg(1,1),Long,False)
  FieldNames("f_Long_Avg_Long_Avg")
  Sample (1,Table1.f_Long_Avg(1,1),FP2)
  FieldNames("f_Long_Avg_FP2")
  Average (1,Table1.f_Long_Avg(1,1),FP2,False)
  FieldNames("f_Long_Avg_FP2_Avg")
  Sample (1,Table1.f_Long_Avg(1,1),IEEE4)
  FieldNames("f_Long_Avg_IEEE4")
  Average (1,Table1.f_Long_Avg(1,1),IEEE4,False)
  FieldNames("f_Long_Avg_IEEE4_Avg")

  Sample (1,Table1.f_FP2(1,1),Long)
  FieldNames("f_FP2_Long")
  Average (1,Table1.f_FP2(1,1),Long,False)
  FieldNames("f_FP2_Long_Avg")
  Sample (1,Table1.f_FP2(1,1),FP2)
  FieldNames("f_FP2_FP2")
  Average (1,Table1.f_FP2(1,1),FP2,False)
  FieldNames("f_FP2_FP2_Avg")
  Sample (1,Table1.f_FP2(1,1),IEEE4)
  FieldNames("f_FP2_IEEE4")
  Average (1,Table1.f_FP2(1,1),IEEE4,False)
  FieldNames("f_FP2_IEEE4_Avg")

  Sample (1,Table1.f_FP2_Avg(1,1),Long)
  FieldNames("f_FP2_Avg_Long")
  Average (1,Table1.f_FP2_Avg(1,1),Long,False)
  FieldNames("f_FP2_Avg_Long_Avg")
  Sample (1,Table1.f_FP2_Avg(1,1),FP2)
  FieldNames("f_FP2_Avg_FP2")
  Average (1,Table1.f_FP2_Avg(1,1),FP2,False)
  FieldNames("f_FP2_Avg_FP2_Avg")
  Sample (1,Table1.f_FP2_Avg(1,1),IEEE4)
  FieldNames("f_FP2_Avg_IEEE4")
  Average (1,Table1.f_FP2_Avg(1,1),IEEE4,False)
  FieldNames("f_FP2_Avg_IEEE4_Avg")

  Sample (1,Table1.f_IEEE4(1,1),Long)
  FieldNames("f_IEEE4_Long")
  Average (1,Table1.f_IEEE4(1,1),Long,False)
  FieldNames("f_IEEE4_Long_Avg")
  Sample (1,Table1.f_IEEE4(1,1),FP2)
  FieldNames("f_IEEE4_FP2")
  Average (1,Table1.f_IEEE4(1,1),FP2,False)
  FieldNames("f_IEEE4_FP2_Avg")
  Sample (1,Table1.f_IEEE4(1,1),IEEE4)
  FieldNames("f_IEEE4_IEEE4")
  Average (1,Table1.f_IEEE4(1,1),IEEE4,False)
  FieldNames("f_IEEE4_IEEE4_Avg"

  Sample (1,Table1.f_IEEE4_Avg(1,1),Long)
  FieldNames("f_IEEE4_Avg_Long")
  Average (1,Table1.f_IEEE4_Avg(1,1),Long,False)
  FieldNames("f_IEEE4_Avg_Long_Avg")
  Sample (1,Table1.f_IEEE4_Avg(1,1),FP2)
  FieldNames("f_IEEE4_Avg_FP2")
  Average (1,Table1.f_IEEE4_Avg(1,1),FP2,False)
  FieldNames("f_IEEE4_Avg_FP2_Avg")
  Sample (1,Table1.f_IEEE4_Avg(1,1),IEEE4)
  FieldNames("f_IEEE4_Avg_IEEE4")
  Average (1,Table1.f_IEEE4_Avg(1,1),IEEE4,False)
  FieldNames("f_IEEE4_Avg_IEEE4_Avg")

EndTable


BeginProg

  n=0

  Scan (1,Sec,0,0)

    n=n+1
    f=n
    If n>32767 Then n=0

    CallTable Table1
    CallTable Table2

  NextScan

EndProg

Log in or register to post/reply in the forum.