Graphing Variables (how to assign times to variables)


Recommended Posts

So I have a variable that is calculated in a looping sequence from a number of different channel inputs (temps, pressures etc), and is stored in a global variable, which I can happily display on the screen.

I know that for variables to be used on graphs, you need to be able to assign time to each data entry also (to create a history), I just can't seem to get it to work.

I've read the guide and it talks about using inserttime() or gettime() etc, I'm just confused as to how to add this into the array - along with the "addvalue()" command?

When I use the following in the command line:

? mass_flow_rate_history

it prints back an array, {0, 0, 19.4, 19.5, 20, 0, 0} etc, so that's half the battle no? At least it's getting the variable into the array, I just want to be able to add time to it so I can plot these variables.

Thanks in advance,

Daniel D

Link to comment
Share on other sites

The easiest thing to do is use a Test D to A channel. Then you can just do:

mass_flow_rate_History = x

to add the value x to the channel and thus create history and a time stamp. However, with variables, just use insertTime() and addvalue():

mass_flow_rate_history.addvalue(insertTime(x, systime(),0))

Link to comment
Share on other sites

I can't use a channel for this, as I don't have many left for I/O requirements, so that's why I want to be able to do this using variables.

I'm using the following code:-

syngas_MassFlow_SCFM_SType_Hist.addvalue(insertTime(syngas_MassFlow_SCFM_SType, systime() , 0))

Unfortunately that method doesn't work perfectly, it's giving charts that look saw-tooth in nature (I'll try an attach a screenshot). What is the "0" in your recommended code for? Is that what's dropping the chart back to zero each time.

Update (Chart 2): I don't know what's happening, I changed the graph to show negative values (on y-axis) and now it's showing the other attachment, and it's not even showing the correct value (upper points on saw-tooth chart 1).

You'll also notice the first chart only displays a few seconds (~20s) of data, I've tried increasing the history length using:

syngas_MassFlow_SCFM_SType_Hist.HistoryLength = 10000

I read in the manual that "Data will build up until the history length for the variable is reached. The default history length for a variable is 3600. To change, set the HistoryLength parameter of the variable to the new value, fox example: MyVariable.HistoryLength = 100" So I'm assuming I need to increase the allowable history length, but you wouldn't have thought it would use-up 10,000 slots in the array in 20 seconds!



Link to comment
Share on other sites


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