Graphing Global Variable


Recommended Posts

You can't plot something without history.  That would just be a point.  You have to create history.  You can do that by using addvalue():

flowdiff.addValue(insertTime((Pond1_5_Flow[0]+Pond6_Flow[0]+Pond8_Flow[0]+Pond9_Flow[0]) - (PS_1_Flow_Outlet [0])),systime(),0)

Note flowdiff will need to be declared global somewhere else.  The insertTime() is just to enture that you get a fresh timestamp for each update.  Call the above line in a loop somewhere at whatever rate the various flow readings update at.

Note: if the 5 channels you are using in the expression are being updated at the same rate, you can either create a calculated V channel or simply use the expression straight up in the graph without all the [0]'s.  Then you wouldn't need to update some global variable.


Link to comment
Share on other sites

Thanks for that, working now but i was actually trying to make it work with an average.

the below fails with improper number of parameters.

flowdiff5.addValue(insertTime(mean(Pond9_Flow [0,1800]) - mean(PS_1_Flow_Outlet [0,1800])),systime(),0)

but this works without the systime do i need it ?

   delay (2)
flowdiff5.addValue(mean(Pond9_Flow [0,1800]) - mean(PS_1_Flow_Outlet [0,1800]))

delay (2)


Thanks for your help.

Link to comment
Share on other sites

The improper # of parameters is probably because of mismatched ( ).  I didn't check and the forum editor doesn't give me the nice highlighting the DAQFactory editor does.  You only need it to ensure you get the right timestamp.  You may not need it at all.

Also note that you can use the smooth() function to achieve almost the same thing.  So:


when using:

flowdiff5.addValue(Pond9_Flow[0] - PS_1_Flow_Outlet[0])

is the same as:

flowdiff5.addValue(mean(Pond9_Flow[0,1800] - PS_1_Flow_Outlet[0,1800]))

which is not quite the same as what you have, where you take the mean first, then the average.

Also, separate comment: make sure the [ comes right after the channel name with no space.  It works both ways, but DAQFactory optimizes better with it right after.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.