Mysterious delta_Time effect on the logging set


Marcus_tribscan

Recommended Posts

Hello,

I'm trying to log four test channels and one of them is a delta_T channel, the logging is started using a descriptive text component with Expression: "Logging.Results.Running" (Results is the name of my logging set) and two action commands, one is the simple Start / Stop Logging Set and the other contains a quick sequence with TimeZero=systime(), the TimeZero is also globally defined (global TimeZero=sysTime() ) in an autostart sequence when the program is started since it is referenced in an events tab belonging to one of the regular channels:

delta_T.AddValue(insertTime(systime()-TimeZero, systime(), -1))

Now the strange thing is that my .csv file looks ok as long as I don't include the delta_T channel, once I include it the file looks like the example attached to this post. First there's nothing in the delta_T column and the other columns look ok but after a few lines the delta_T starts filling and leaves the other columns with blanks. Any ideas why this i happening?

The mode for the logging set is All data points aligned using an align threshold of 0.5 (I've tried different values but it doesn't seem to help) and the regular channels that collect the data from a LabJack U3 run @ 0.01sec timing and averaging of 5 data points.

Regards

Marcus

post-8092-1329426017_thumb.jpg

Link to comment
Share on other sites

Notice how the time jumps backwards once it starts logging the delta_T channel? This is throwing the logging set off because now the other columns no longer have data at those times (already written).

If you are doing the addValue() in an event of one of the other logged channels, quotient say, then instead of using systime() in the expression, use quotient.time[0]. This should solve the problem.

Link to comment
Share on other sites

Didn't do the trick, I keep getting the same error...

My sequence looks like this:

while(1)

Vertical_force_tared.AddValue(Vertical_force-LoadCellATare)

Horizontal_force_tared.AddValue(-Horizontal_force+loadCellBTare)

Quotient.AddValue(Horizontal_force_tared/Vertical_force_tared)

delay(0.01)

endwhile

In the event for the Horizontal_force (not a test channel) I've got:

delta_T.AddValue(insertTime(Horizontal_force.Time[0]-TimeZero, Horizontal_force.Time[0], -1))

I also have a start sequence looped once upon the launch of the program where the global TimeZero=0 (to define the variable since it is referred in the channel event.

upon the start of logging via the descriptive text component I've got: TimeZero=Horizontal_force.Time[0]

Regards

Marcus

Link to comment
Share on other sites

You know, if you are calculating all these values through a sequence anyway, you'll get a more reliable result by simple using File. functions to log the data directly, rather than use the logging set. You'll also get more control over formatting of the results. Move the delta_T calc into the while loop, then add something like the following before the delay():

try
   private handle = file.open("c:\mydata.csv",0,1,1,1)
   private string out = FormatDateTime("%c",systime()) 
   out += "," + delta_T[0]
   out += "," + quotient[0]
   out += "," + vertical_force_tared[0]
   out += "," + horizontal_force_tared[0]
   file.write(handle,out)
   file.close(handle)
catch()
   ? strLastError
endif

You can optionally move the file.open and file.close outside the while loop for better performance.

Link to comment
Share on other sites

Thanks for the tip on the .File approach, I'll try that... But before I do that I was able to resolve the logging time problem using this approach:

In an autostart sequence I put:

global starttime=systime()

In the event for the Horizontal_force I put:

delta_T.AddValue(gettime(vertical_force)-starttime)

Horizontal_force_tared.AddValue(-Horizontal_force+loadCellBTare)

Vertical_force_tared.AddValue(Vertical_force-LoadCellATare)

Quotient.AddValue(Horizontal_force_tared/Vertical_force_tared)

and in my I Start/Stop logging Descriptive text component I put a quick sequence

starttime=systime()

The align threshold used for the logging set is 0.1

In the attached picture you can see the output.

Now my only problem is that no matter what timing or averaging I use for my real channels I still get a resolution of 0.1 seconds in my log-file... any ideas how to resolve this? I really need to be able to run a 0.01s measurement and that should give me a resolution of 0.01 seonds in my log-file :huh:

post-8092-1329613608_thumb.jpg

Link to comment
Share on other sites

That makes some sense. Starttime wasn't a real value the first time you get to the delta_t.addValue() and that was throwing off the result.

As for your question: By definition, you'll never get resolution higher than the align threshold. The other 9 points within the 0.1 seconds of alignment will align to the same point and be tossed. Set your align threshold to 0.01.

Link to comment
Share on other sites

Setting my align threshold to 0.01 makes the whole horizontal_force_tared column go away in the logged .csv file (still producing Quotient results which is kinda funny since the quotient is dependent upon the horizontal_force) and it gives me a large number of duplicates or empty fields in my dT column, depending on if I have the Empty filed or Duplicate last value options checked... Is adding test channel data under one and the same events tab for one of the real channels not the right approach?

What is the best strategy to get away from these phenomenons?

Link to comment
Share on other sites

Archived

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