Displaying Time In Seconds From Start Of Graphing


cadcoke5

Recommended Posts

I would prefer that my graph time axis show the elapsed time in seconds, from the time the graph started recording.  I know I can show seconds by choosing "Lin", but it defaults to the number of elapsed seconds since 1970, and 10 digits are a little difficult for us humans to handle.  I know I can choose the Date and Time mode, and it will show me hours and minutes, but I also need to see seconds indicated on the axis..

 

Is it possible to display elapsed seconds since data recording was started?

 

Thank you for the advice,

 

-Joe

Link to comment
Share on other sites

Elapsed seconds requires a start time.  If you are just plotting against Time, you are going to get seconds since 1970.  To plot against elapsed time, you need a variable with the start time, then you have to subtract that from the time of the channel:

 

X Expression:    getTime(myChannel) - startTime

Link to comment
Share on other sites

I just implemented your suggestion.  But, there must be some stuff I am omitting.  The first thing I figured out is that I need to substitute the "myChannel" with an existing channel that I am recording data for, and add the [0] suffix.

 

I created a script that automatically runs, with the following statements;

 

Global StartTime = 0

StartTime = SysTime()

 

 

Note that I have an existing channel called Thermister1

Then, on my graph I set the X expression as

 

  getTime(Thermister1[0]) - StartTime

 

But, the numbers along the X-axis still show the elapsed seconds since 1970.  As an experiment, I created a Test display with the same statement copied and pasted as the expression.  That DOES work. It just doesn't work in the graph. Next, note that I have three traces on the same graph.  I saw that the X-expression is specific to each of the traces I have on the graph.  Apparently, if the X is set as Time on any of them, that overrides any other X-axis expression.

 

So, the problem seems solved, but perhaps the issue in the sentence above should be reported as a bug.

 

-Joe

Link to comment
Share on other sites

That's because you can't use [0].  The expression you used with [0] results in a scalar, becuase thermister1[0] is a scalar, and startTime is a scalar.  To do a graph you need an array, both in X and Y.  Drop the [0] and it should work fine.  Start with a fresh graph and only one trace.  Trying to do multiple traces at once is making it more complicated for you.

Link to comment
Share on other sites

Your suggestion worked, but for some reason my first attempt without the [0] did work.  But, that could have been some sort of typo.

 

I do however, have another puzzle.  I need the getTime(Thermister1) - StartTime expression on 2 of the three traces. I can leave one of the traces as Time, but the system time does not display.

 

I tried to see if the first one is the one that controls the rest, but that is not the case. is it majority rule?

 

Here are my traces, listed in order.

 

Channel Type   Name             X-Expression

      A-to-D | ExternalButton | getTime(Thermister1) - StartTime

 Digital Out | PowerSwitch    | Time

      A-to-D | Thermister1    | getTime(Thermister1) - StartTime

 

Thank you for the ongoing help,

-Joe

Link to comment
Share on other sites

I have to show at least 6 sensors at once on a graph.  That is why I would like  multiple traces on a graph.

 

Is it possible to use the getTime(Thermister1) - StartTime expression and have multiple traces?  How would I accomplish that?

 

If it is very involved, you don't necessarily need to give me detailed instructions. But, just point me down the correct path, so that I know where to focus my learning.

 

-Joe

Link to comment
Share on other sites

DAQFactory supports only one X axis per graph, so you can't have one trace with an X expression that is relative time (getTime - starttime), and another that is absolute time.  The scaling is just going to be off because relative time is going to be on the order of maybe 10,000's (assuming you run for hours), and absolute time is on the order of 1.4 billion.  If you need to do both, you really need to create two graphs.

 

Yes, you can use relative time on multiple traces.  They just all need to be relative time.  Also, it probably should be getTime(channel in Y expression), not getTime(Thermister1) for the other traces.  So, for externalButton you'd do:

 

getTime(externalButton) - starttime

 

This ensures that it all lines up.  To DAQFactory its just an XY graph.

Link to comment
Share on other sites

Archived

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