M: Memory Block. MJMcCann-Consulting Interval recording, delivers previous values Interpolated or Sample and Hold. |
![]() |
Memory Block.
Variables as Used
How far back to go The data is stored in the same way as in a function Generator (G-block). As a result, because the function generator can retrieve values from another block's records, the same memory can be accessed as many times as needed, using G-blocks as extractors. Provide the G-block with, for example, time as input An, the offset as input Bn and point its Pn value to the memory block, and it will seek out the appropriate records and interpolate as needed. Display by V-Visualizer block The visualizer will display the contents graphically. The input track is shown vertically and the basis track horizontally. The scales can be set for full scale deflection and offset, though the basis track will probably be left to automatically span the length of the record. The result is a moving chart recorder effect or, if the basis track is another dynamic variable, an X-Y plot such as a phase plane plot. Initialization The initialization for the memory creates a "fake" record that has constant value, aa all the way though at uniformly spaced basis channel intervals back as far as abs(cc) before the current value of bb. In the default case where Time is the basis signal, bb automatically takes on the value of StartTime. To make the initialization and the subsequent simulation work properly you should load cc with the offset needed and only change it later by extra input via the C connection. This process results in a reasonable plot when used as input to a Visualizer or FunctionGenerator block. The memory block always makes its first sample at the start of the run, so the final step in the initializattion is to pick up the StartTime values from the A and B connections and put them in the most recent data record.
Changing the Offset (Delay)
Trying to go too far back Memory Block Code Activation when Simulation is Running: Procedure ActivateM(ii:integer); var jj, NN: integer; Timely: Boolean; BaseThen, BaseNow, SourceNow : real; begin with B[ii] do begin if OnOff<=0 then begin dd:=dd+Delt; EXIT end ; //delay next sample, not change Output Timely:=(Time+TinyDelt>=dd); SourceNow:= B[An].Vn; BaseNow:=B[Bn].Vn; BaseThen:=BaseNow - abs(B[Cn].Vn+cc); //NN is number data pairs, representing NN-1 segments NN:=High(Store) div 2; if Timely then begin dd:=NextEventTime(B[Pn].Vn +pp); for jj:= 1 to NN-1 do begin //Move data along Store[jj]:=Store[jj+1]; Store[NN+jj]:=Store[NN+jj+1]; end{segs}; //read in new data Store[NN]:=SourceNow; Store[NN+NN]:=BaseNow; end{Timely}; //Every time: if BaseThen <= Store[NN+1] then begin Vn:=Store[1]; EXIT end ; //use oldest available value. if BaseThen >= Store[NN+NN] then begin Vn:=Interpolate(Store[NN+NN],Store[NN],BaseNow,SourceNow,BaseThen); EXIT end; jj:=1; //now start looking inside the records... while BaseThen>Store[NN+jj] do inc(jj); case State of 0:Vn:=Store[jj-1]; 1:Vn:=Interpolate(Store[NN+jj-1],Store[jj-1],Store[NN+jj],Store[jj],BaseThen); end{case}; end{withBii} end; Initialization Step, Gets ready for first sample to be taken immediately and placed in last pair of entries. 'M' : begin if Bn=2 then bb:=StartTime; NN:=High(store) div 2; Vn:=aa; dd:=StartTime; //present value and next sample time for jj:=2 to NN do //preload the records with reasonable values. begin Store[jj]:=aa ; Store[NN+jj]:= (bb-abs(cc))+(jj-2)*abs(cc)/(NN-1) end; end{M}; |
MJMcCann-Consulting
Help Index: Index/Search
Background
Using McSimAPN PetriNet Block Types Analogue Block Types |
Invitation. McCann can help if you have a
design or operational problem that needs some technical support that is outside your
team's experience, some quantitative assessment of what is really the cause of the
difficulties, some design alternatives or just a fresh look by an intelligent
interrogator. If you have a problem with the behaviour of a market sector, plant, process or item of equipment and would like to get a quantitative handle on it to improve yield or optimise performance, then contact us. We are always ready to give a little time to discuss a new puzzle, in confidence, of course. We'll only worry about fees when we have some defined work. We can be flexible about how we work with you. Top |
MJMcCann-Consulting, POB 902, Chadds Ford PA 19317 USA. T: 1 302 654-2953 F: 1 302 429 9458 E: mjmccann@iee.org |
Request. Please let us know how you found this software and your interests by sending an email to mjmccann@iee.org Thank you | Date: 2012.02.26 File: m.htm |