embayweather Posted October 24, 2011 Share Posted October 24, 2011 Howe can I record the maximum values from a channel on a Labjack U3? The device is happily recording windspeed on a graph, and as a value in a separate number output. I would, however, like to record the maximum gust and time. Can someone help me please? Thanks Best wishes Mike Link to comment Share on other sites More sharing options...
AzeoTech Posted October 24, 2011 Share Posted October 24, 2011 There are different ways, depending on whether you have the history for the max range you want. If, for example, you want the daily max, and your history is long enough to cover that period, you can just do: max(windSpeed[0h,systime()]) to get the time of that max, just do: getTime(max(windSpeed[0h,systime()])) If, however, you want, say daily, weekly and monthly maxes, you'll need a variable to store each, initialized to some unattainable minimum (say -1 for wind speed). Then in the event for the windspeed channel, do something like: if (windSpeed[0] > dailyMaxWindSpeed) dailyMaxWindSpeed = windSpeed[0] endif You can then display that variable anywhere, and to get the time, again use getTime(dailyMaxWindSpeed). To reset, just set dailyMaxWindSpeed to -1 again. To do that at the end of the day, do something like before the above script: if (formatDateTime("%d", windSpeed.time[0]) != formatDateTime("%d", windSpeed.time[1])) dailyMaxWindSpeed = -1 endif Use %W for weekly, %m for monthly. Note that these values will reset if you restart DF. Link to comment Share on other sites More sharing options...
embayweather Posted October 24, 2011 Author Share Posted October 24, 2011 Thank yo. I could not have asked for a more clear description. just perfect. Thanks Best wishes Mike Link to comment Share on other sites More sharing options...
embayweather Posted November 27, 2011 Author Share Posted November 27, 2011 After a few weeks of illness I have tried these suggestions and do not get very far. I created a variable box for the gust speed, and entered the expression into the expression box exactly as you indicated. it placed a number into the box which promptly became static despite changing wind speed. I also created a time box using your suggestion, which again did the same thing. Have I put the correct values in the proper places please or is there more to do? I also need to convert the time to Windows format but that may well have to wait until the gust measurement is solved. Thanks once again. Mike Link to comment Share on other sites More sharing options...
AzeoTech Posted November 28, 2011 Share Posted November 28, 2011 Maybe you can post your .ctl document so I can see what you've done? Link to comment Share on other sites More sharing options...
embayweather Posted November 28, 2011 Author Share Posted November 28, 2011 I managed to get the recording maximum value, once I had checked the syntax and discovered a missing bracket. However, i am still struggling to get the time number converted to a standard date format. The date is recorded in a long number, but I need to make it understandable. I have been experimenting with FormatDateTime() but cannot find the right place/syntax for it. I have looked in the manual and it indicates I should use %c to convert to "Windows" time. I have tried allocating the MaxGust to a defined variable T$, but got nowhere with that. Any pointers please on syntax? I am including this in the Expression of a Variable Value Component. Thanks Best wishes Mike PS ctl attachedSolar.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted November 28, 2011 Share Posted November 28, 2011 Its simply: formatTime("%c", getTime(Max(Wind_Speed[0h,SysTime()]))) I'm not really sure what you were doing. First, T$ is not a valid DAQFactory name. Second, the variable value takes an Expression. An Expression is something that would exist on the right side of an = sign. You put a statement. A statement is a line of script, and in your case, includes the = sign. Also, you have max(Wind_speed(0)[0h,systime()]) this is incorrect subsetting. Drop the (0) Link to comment Share on other sites More sharing options...
embayweather Posted November 29, 2011 Author Share Posted November 29, 2011 Not sure really what I was doing either, just experimenting. I think I got lost along the way. I will try your suggestions which I am sure will be fine. Thank you once again Best wishes Mike Link to comment Share on other sites More sharing options...
AzeoTech Posted November 29, 2011 Share Posted November 29, 2011 No worries. Just trying to point you in the right direction Link to comment Share on other sites More sharing options...
embayweather Posted December 1, 2011 Author Share Posted December 1, 2011 Thank you for your help. I made a small change to the expression you gave me and all is well. I wonder if there is a list of the programming phrases and syntax anywhere to help me understand the expression better? Thank you once again. Best wishes Mike Link to comment Share on other sites More sharing options...
AzeoTech Posted December 2, 2011 Share Posted December 2, 2011 Most internal functions are listed at the end of the Expressions chapter of the user's guide. Object specific functions (i.e. system functions, channel functions, component functions, etc) are described with the object, system functions at the end of the Sequences chapter I believe. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.