BallardHill Posted November 22, 2016 Share Posted November 22, 2016 Our application collects load cell data from multiple sensor channels, offsets and scales it, then displays the maximum pound force to date in a Variable Value Component named AllStrapsMax. The data is processed in this Sequence: (((max(StrapLeftHead[0h, systime()]) - 1.250) / (0.00375375 * 201)) + ((max(StrapLeftShoulder[0h,systime()]) - 1.250) / (.003928 * 201)) + ((max(StrapLeftHip[0h,systime()]) - 1.250) / (0.003969 * 201)) + ((max(StrapLeftKnee[0h,systime()]) - 1.250) / (0.00394988 * 201))) * 1000 (Yes, the constant calculations could be pre-calculated to increase efficiency.) The displayed maximum value reverts to a lower LBF once the peak data has passed through the channel histories, whereas we need that maximum to persist in another Variable Value Component (MaxPersistent) until some Control action occurs, such as clearing the Log. We need some way to conditionally copy the AllStrapsMax value to MaxPersistent (perhaps using the evaluate(component.myComponent.strExpression) technique you educated me about a year ago), but this needs to trigger each time the AllStrapsMax value changes, or at worst after each set of channel samples. Can you provide some guidance? Link to comment Share on other sites More sharing options...
AzeoTech Posted November 22, 2016 Share Posted November 22, 2016 First, precalcing the constants is going to do next to nothing to the efficiency of the calculation. Its much better to use a formula that makes sense and maybe has a few extra numbers in it. As for your question, I would put the formula in a V channel, maybe call it AllStrapsMax. Then in your component the expression would just be: V.AllStrapsMax Then, in say a sequence, or perhaps in the Event of one of those four channels, you should check V.AllStrapsMax against MaxPersist and if its bigger, update MaxPersist with V.AllStrapsMax. MaxPersist would likely be a global variable, but you could also use a Test D to A channel with Persist = History ( = 1 probably) so that the value persists between DAQFactory restarts. To reset the max, just set MaxPersist to 0 and the next iteration of the sequence or event will update it. The use of a V channel in this way makes it so you don't have to enter the formula in more than one place. The formula is only evaluated when the V channel is referenced. Its not acting as a variable, but as a sort of shorthand for the formula. Link to comment Share on other sites More sharing options...
BallardHill Posted February 20, 2017 Author Share Posted February 20, 2017 There are now Load Cell Channels defined, connected to transducers, and working for Strap0 through Strap3, History=1000 (known working because graph is displaying correctly and application is exporting log results into a usable dataset on command). There is on the Page MonitorLog the Component VariableValue named MaxPersistent, with Propeties set to show a 2-decimal float value. There is a Virtual Channel VAllStrapsMax defined with Expression: (((max(Strap0[0h, systime()]) - 1.250) / (0.00375375 * 201)) + ((max(Strap1[0h,systime()]) - 1.250) / (.003928 * 201)) + ((max(Strap2[0h,systime()]) - 1.250) / (0.003969 * 201)) + ((max(Strap3[0h,systime()]) - 1.250) / (0.00394988 * 201))) * 1000. Setting the MaxPersistent Expression to: MaxPersistent = iff((V.VAllStrapsMax[0] > MaxPersistent), V.VAllStrapsMax[0], MaxPersistent) results in the 'pinkeye' ExpressionEditorBox regardless of how much qualification is done on the Component(e.g., Page.MonitorLog.) HAVE pored over manual.pdf, HAVE queried forum, cannot find reference or example pointing out what simple error(s) I'm overlooking. Can you advise? Thanks for your consideration! Link to comment Share on other sites More sharing options...
AzeoTech Posted February 21, 2017 Share Posted February 21, 2017 The function is iif(), not iff(). Think "Inline IF", IIF. Link to comment Share on other sites More sharing options...
BallardHill Posted February 22, 2017 Author Share Posted February 22, 2017 Timely response - thanks! Even with that silly mistake corrected, still get pinkeye, error message: C1070: Not enough parameters for the given operator I've been too spoiled by spell-checkers, syntax checkers, and other lazy-making tools - can't figure out which operator is meant, the " or >, and why some parameter is not valid. Link to comment Share on other sites More sharing options...
AzeoTech Posted February 22, 2017 Share Posted February 22, 2017 Are you sure its that line? And can you post your corrected line just to be sure there isn't another typo? Link to comment Share on other sites More sharing options...
BallardHill Posted February 22, 2017 Author Share Posted February 22, 2017 Supporting images attached. Please let me know if further documentation would be useful. AzeoTech has always provided absolutely flawless support - haven't needed it much since the product has always worked so well! Thanks for all your help. Link to comment Share on other sites More sharing options...
AzeoTech Posted February 22, 2017 Share Posted February 22, 2017 You can't have = in an expression. = is assignment and only valid in script. Just drop the MaxPersistent = part. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.