Hi,
I want to know how i can snapshot ( e.g.,5 values from same analog input ) the analog value to a array.
If you are asking what the format of an expression in an ACT or CALC block on how to save to the array then
'^/ARRAY_PARAM'[ x ][ y ] := VALUE;
where x is Row and y is Column of the array.
In reply to Matt Stoner:
Thank you sir Matt Stoner. I want to assign 10 values from a single analog input to 10 place of an array. After 1 scan one value will capture to '^/ARRAY_PARAM'[ 1 ][1y] := n1(value from analog input); & so on. Is my question clear to you now?
Andre Dicaire
In reply to Rajeev Kumar:
In reply to Andre Dicaire:
Using a Dead Time block could help here. This fb "delays" an analog value by DEAD_TIME seconds. So the easy way could be adding 4 dead time fb, setting their DEAD_TIME parameter to 1,2,3 and 4 seconds. Then outputs of those dead time fb will hold analog last 4 values (fifth value is current analog value). Inside a CALC you may copy into an array parameter (eventually, if array is not required for other reasons, your application may work directly with dead time fb OUT parameters).
The advantage of this approach is that you don't need to care about sampling cycle initialization and reset, even downloading module without getting bad values may be supported.
Next PIC show that implementation. SGGN1 is configured to generate variable with SIN_AMP=60 and SIN_PERIOD=600. PARAMS1 to PARAM% hill hold last 5 values and are copied into ARR_OUT by CALC1.
DISABLE parame is an extra, it allows to "equalize" al 5 values by demand.
In reply to gamella:
gamella said: Using a Dead Time block could help here. This fb "delays" an analog value by DEAD_TIME seconds. So the easy way could be adding 4 dead time fb, setting their DEAD_TIME parameter to 1,2,3 and 4 seconds. Then outputs of those dead time fb will hold analog last 4 values (fifth value is current analog value). Inside a CALC you may copy into an array parameter (eventually, if array is not required for other reasons, your application may work directly with dead time fb OUT parameters). The advantage of this approach is that you don't need to care about sampling cycle initialization and reset, even downloading module without getting bad values may be supported. Next PIC show that implementation. SGGN1 is configured to generate variable with SIN_AMP=60 and SIN_PERIOD=600. PARAMS1 to PARAM% hill hold last 5 values and are copied into ARR_OUT by CALC1. DISABLE parame is an extra, it allows to "equalize" al 5 values by demand.
Next PIC show a module DOWNLOAD effect on this algorithm.
Thanks Matt and Andre for sharing your logic. I like that idea. will keep that in mind. Had the same request before, using a CALC block and a module scan of 1 sec OUT10 := OUT9 OUT9 := OUT8 OUT8 := OUT7 . . . . OUT1 := AI/OUT