Daggos

Graphing Global Variable

Recommended Posts

Hi Im trying to Graph a global variable, can this be done, not sure as it doesn't have any history only current value.

 

Global flowdiff = (Pond1_5_Flow[0]+Pond6_Flow[0]+Pond8_Flow[0]+Pond9_Flow[0]) - (PS_1_Flow_Outlet [0])

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
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 ?

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

delay (2)
endwhile

 

Thanks for your help.

Share this post


Link to post
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:

smooth(flowdiff5,1801)

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now