Misaligned Data


rhirsch

Recommended Posts

I know the answer is going to be InsertTime(), but I am unsure of how to make this work. have tried a number of ways but what I'm trying to do just isnt working.

I have thermal data. Channels for them. no problem. all is well in the log file

I have a variable that I would like to keep track of its value.

I have a Test channel, with timing set to 0, which is calculated data.

basically the timing of the thermal logging is 1/sec. I have a speed so I know that every second the part has moved a certain distance. I can calculate this in excel afterwards, but that is a pain. I;d rather just log the number since I have a button to clear historical data and I want the distance data to be based on the thermal data since last clear.

so:

i know the problem is here. I log this way.


Logging.logset.AddValue("beltspeed",beltspeed)
Logging.logset.AddValue("distance",dist[0])

[/CODE]

so each log entry logs the latest values for these things. beltspeed is the variable, dist is a channel of type Test with no timing.

I have a sequence always running to update dist. the latest incarnation of this is with my attempt to use inserttime

[CODE]
while(1)
dist.AddValue(inserttime(distance_calculation,systime(),0)
wait(1)
endwhile
[/CODE]

doesnt work. as you can see from the attached picture. Dist and beltspeed have a single timestamp that is unchanging.

How do I do this correctly?

post-1494-0-67022800-1361575302_thumb.pn

Link to comment
Share on other sites

The problem is the alignment threshold is set smaller than the difference in time between the timing loop reading your actual inputs, and the one running in your sequence. Two options:

1) increase the align threshold

2) sync the loops

I prefer #2 by a long shot. If things need to be synced, they should be synced. To do this, simply move your calculations out of the sequence and into the Event for your input channel. Also, instead of using systime() in your addValue(), use the time of the last reading.

dist.addValue(insertTime(distance_calculation, someChannel.time[0],0))

where someChannel is the name of the channel who's event you put this script into. Put your logging.logset.addValue() in there too, though really, you should just log the Test channel directly like you would others (no need for the logging.addvalue() calls), and why not make beltspeed a Test channel too and do the same thing?

Link to comment
Share on other sites

I chose #2. worked great. I get it if you dont want ot waste time solving somethng I'm not doing, but the part I dont understand about the previous method was: why didnt the times update. I get the out of sync issue. But if you look close at the attached file above, the times for the calculated logged valves were not increasing. If they were increasing and out of sync, then playing wth the alignment should have fixed it. But would that have worked if the time was not incrementing?

Link to comment
Share on other sites

Sorry. I didn't look closely at the time stamps. Usually you get that when part of your calculation has time in it and you don't realize it, and that time is used. If you look at the timestamp on dist, is it incrementing? I mean in the actual channel, not the log.

Link to comment
Share on other sites

  • 1 month later...

Because its timestamp is different. You might need a bigger align threshold, or use a different technique to add notes, for example, create a global variable to hold the last entered note. Then, in the event of one of the channels being logged, look at that global variable, and if its not an empty string, put the contents in a Test String channel with the same timestamp as the channel being read's timestamp (the channel event you are in)

Link to comment
Share on other sites

  • 1 month later...

Archived

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