T: Timer Block.
MJMcCann-Consulting

Triggerable, Randomizable Clock with On/Off periods (Multivibrator),
also MonoStable (One-shot), FlipFlop (Bistable) or Manual Pulse generator.
MJMcCann-Consulting Logo

Timer Block.
The default device [Mode 0] is a free running clock that has an ON period (Vn=1) and an OFF period (Vn=0).
As with other timed blocks, giving it positive time values produces regular operation, giving it negative time values gives random length periods, with the corresponding mean.
With regular timing it can control activities (e.g. operating shifts in a factory) or serve as a pulse generator.
The random mode provides for simulating breakdowns and failures using the ON time as the MTBF (mean time between failures) and the OFF time as the mean time for repair.
The Pn connection provides relay control, On/Off, for one other block. More blocks can be controlled ON/OFF via R:Relay blocks.
It isn't necessary for both time periods to be random or both constant. So a random MTBF can be combined with a fixed repair time.

Trigger Signal Detection.
The Timer block always (except in manual Mode 3) checks its An input to watch for a sudden change, i.e. going positive by 1 unit or more in one time step.
It ignores changes in a negative direction. Thus the change of level as a logic block goes ON will be detected.

Mode 1: Monostable (One-shot)
In Monostable mode it stays off till triggered. Then it stays on for the ON time (regular or random) and then reverts back to waiting for another trigger. (See also Manual mode 3.)
If it gets a trigger signal while ON then it is re-triggered, ie. the ON time starts anew and is extended without interruption.
The Pn connection provides relay control On/Off for another block

Mode 2: BiStable, FlipFlop
In bistable mode it flips state ON to OFF or OFF to ON whenever it gets a trigger signal. The time values are ignored.
Thus a chain of such devices will act as a binary counter because each will detect the OFF to ON transition of the preceding block as a trigger.

Mode 3: Manual Mode, One-Shot (single Pulse)
In manual mode, the device is normally off and is initialized OFF with zero output (Vn).
When it is triggered by a left click (as used to switch other blocks On/off) it comes on, with output Vn=1, for a period defined by the on-time and then switches itself off, setting its output back to zero.
In this manual mode it does not respond to trigger signals on the An input.
It can be used as a single pulse generator to trigger any event or as temporary input to a integrator to make an incremental move.
The Pn connection provides relay control On/Off for another block.

Tricks
The mode 0 clock can be triggered from OFF to ON. This allows events to synchronize.
Set the clock to run a bit slower than the trigger input and it can lock in to the triggering.
Just like you getting locked in to a daily cycle becaue your internal clock normally runs a bit slower than a 24 hour period. It isn't necesary to give a trigger every cycle, so sub-harmonic signals can get coordinated.

Beware
The Timer block really needs two things to be RESET when going back to Initial conditions, the High or Low condition and the Next Event Time. All algebraic (instant response) blocks, including the timer are activated immediately on Reset so that they show the correct values. A timer block may reset its Next Event Time and change its condition. A second RESET click can fix this to bring it back into the desired starting condition.


Timer Block Code
Procedure ActivateT(ii:integer);
   //Timer, retriggerable, one shot, flip flop options
   //timing can use random values like other timed blocks.
var Timely, Trigger:Boolean;
    InitialVn : Integer;
begin with B[ii] do begin
  if Vn=0 then B[Pn].OnOff:=0 else B[Pn].OnOff:=1;
  if OnOff<=0 then EXIT;
  Timely:= (Time>=pp-TinyDelt);
     //pp is used for timing,Vn can be used as input elsewhere.
  Trigger:= (B[An].Vn>=aa+1-TinyNumber);
  aa:=B[An].Vn;  //check for jump and remember current value.
  InitialVn:=max(0,min(Round(Vn),1)); //Vn is output and serves as logic level.
  Case State of
    0: begin //multivibrator, repetitive, synchronizable by trigger when Vn low
       if InitialVn=0 then
          if Timely OR Trigger then begin
             pp:=NextEventTime(B[Bn].Vn+bb); Vn:=1.0; B[Pn].OnOff:=1   end;
       if (InitialVn=1) and Timely then begin
          pp:=NextEventTime(B[Cn].Vn+cc);  Vn:=0.0; B[Pn].OnOff:=0 end;
       end;
    1: begin //One shot, monostable, retriggerable when Vn high
       if Trigger then begin pp:=NextEventTime(B[Bn].Vn+bb);
          Vn:=1.0; B[Pn].OnOff:=1; Timely:=False end;
       if Timely then begin Vn:=0.0; B[Pn].OnOff:=0 end
       end;
    2: begin // Bistable flip-flop, trigger forces transition either way.
       if Trigger then if InitialVn=1 then begin Vn:=0.0; B[Pn].OnOff:=0 end
                       else begin Vn:=1.0; B[Pn].OnOff:=1 end;
       end;
    3: begin // Monostable triggered by left click (which toggles other blocks)
       if (InitialVn=1) and Timely then
            begin Vn:=0; B[Pn].OnOff:=0; OnOff:=0;  exit end;//end pulse
       if (InitialVn=0) then
            begin pp:=NextEventTime(B[Bn].Vn+bb);
            Vn:=1.0; B[Pn].OnOff:=1 end; //Just been set ON
       end;
    end{cases};
  if (Round(Vn)<>InitialVn) and Animation then DisplayT(ii);
end{with Bii}
end;

MJMcCann-Consulting

Help Index:
Index/Search

Background
Simulation Concepts
Continuous Systems
Discrete Systems
McSimAPN Structure
McSimAPN Operation

Using McSimAPN
Start McSimAPN
Save Model,data
Create Blocks
Run-Hold-Reset
Link Excel+VBA

PetriNet Block Types
A activity/action
B belt conveyor
C container/constant
D diverter(random)

Analogue Block Types
E exponents
F flux/flow
G function Generator
H hysteresis
I integrator
J inductor
K logic element
L logarithms
M memory
N note/label
O oscilloscope/graph
p not assigned
Q quantizer/rounding
R relay on/off
S sin/asin/atan
T timer/clock
U user link Excel
V visual voltmeter
W sWitch selector/MUX
X multiply
y not assigned
Z random (fuZZ)
& signed summation
% division/difference
@ access/move values

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: t.htm