Вы находитесь на странице: 1из 4

Using time triggering in SIMPLORER 7

1 Introduction
For version before V7SP5, SIMPLORER supports value triggering only. Time point triggering was not supported. With SP5 the simulator will have a new feature Time Trigger. Using this feature the user can specify synchronization points at which the simulator will be forced to do a calculation. A time trigger event can be scheduled once or periodical.

2 Intention
Imagine a state machine that has to perform certain operations at exactly specified time points, e.g. at t1 = 1 ms, t2 = 2 ms, etc. To trigger these events, the simulator will approach t1 with some step size h. It will ignore t1 until t > t1, then discard the last step and reduce h. The simulator doses some kind of interpolation to find the new h. From then on, h will be successively increased until again t > t1 and the same procedure starts anew. This whole process continues until t1 is being stepped over by hmin. This has many drawbacks. First, the simulation accuracy suffers considerably because t1 is only hit by an error depending on hmin. Second, simulation speed suffers extremely (especially for clocked systems and alike) because SIMPLORER takes a lot of extra steps (e.g. many hundreds depending on h, hmin, and hmax) just to trigger this event roughly. If the model itself knows the point where the condition goes true, it could set the step size to synchronize exactly to this point.

3 Handling
The backplane includes now a trigger list. Its a sorted list with all scheduled events. After a time step, when the simulator calculates the step size for the next time step, it includes this list for the step size calculation. New functions to schedule and unschedule events are available in the system now. The functions can be called from the State graph and the C-Interface. ScheduleTrigger or SCHED - will create a new trigger. DeScheduleTrigger or DESCHED - will remove a trigger Page 1 12/16/2005

Call the function ScheduleTrigger or SCHED with the same name will delete the existing time trigger with that name and schedule a new one. Definition of more than one time triggers for a time point is possible. Unscheduling has no effect as long as one trigger for that time point is active. Only if all triggers removed, the simulator will not synchronize at that time point.

3.1 State Graph Extension


The state graph module is extended by a new action type - a Schedule event action type. An associated transition will switch (i.e. become TRUE) exactly at this time event. The name of this Schedule event action type is SCHED. An action of some state looks like:
SCHED dTEv1 $$ t + 1u

For periodical events add the period length as additional parameter:


SCHED dTEv2 $$ t + 1u, 5u

SCHED sets variable dTEv1 to current simulation time plus 1 microsecond and synchronize at time t + 1u. Whenever a SCHED action type is encountered, ScheduleEvent will be called by the simulator. A new trigger is created in the Backplane and sorted into the trigger list. The Simulator includes these trigger list to calculate the step size for the next time step. A transition condition looks like:
COND: dTEv1

/* transition TRUE if dTEv1 has been reached, simulator triggers exactly on dTEv1 */ or
COND: dTEv1 OR R1.I >= I_Max

/* transition TRUE if dTEv1 has been reached (simulator triggers exactly on dTEv1) or current through R1 greater than or equal to some variable I_Max*/ There will be a DESCHED action type that executes DescheduleEvent. The according action looks like: UNSCHED dTEv1 /* removes the value of dTEv1 from the trigger list */ The $$ will set dTEv1 to the right side value and schedule the event once the state becomes active. Thus, it might also be omitted because the SCHED type seems to form a unique definition. However, the DEL type also goes along with the ##-operator although one seems to suffice. Again: This new action/transition combination corresponds to the delay operator (##), where a certain state graph transition will become TRUE after a certain time has elapsed, e.g.:

Page 2

12/16/2005

DEL lTEl1 ## t + 1.1u

/* lTel1 becomes TRUE after t + 1.1 us has elapsed */


COND: lTEl1 AND R1.I < I_Max

/* switch if time elapsed and current less than its maximum, ... */

3.2 C/C++ Interface Extension


There are two predefined functions that call ScheduleEvent and DescheduleEvent from inside a C-model. Calling the Schedule or DeSchedule function are only allowed in SimInit() or SimValidate(), otherwise a error message occurs. The Sim2000User.h header file is extended and includes 2 new function prototyp:
//functions to schedule user model sync time points void ScheduleTrigger (LPCTSTR pszName, double dAbsSyncTime, dPeriod = 0.0); double

pszName - user defined non-ambiguous name for the time trigger dAbsSyncTime - absolute time of the next trigger time in seconds dPeriod - period length for the trigger in seconds, 0.0 mean no periodical Calling the ScheduleTrigger function twice with the same name will remove the first trigger from the list and insert a new one. For example:
ScheduleTrigger (MyTrig, 1e-3); ScheduleTrigger (MyTrig, 1.5e-3, 0.5e-3);

Only the second trigger at time 1.5ms with a period length of 0.5ms is active. At time 1ms the simulator will not explicitly synchronize.
//functions to deschedule user model sync time points void DeScheduleTrigger (LPCTSTR pszName);

pszName trigger name corresponding with the name used in ScheduleTrigger()

3.2.1 Error Messages


Messages are displayed when user calls Schedule or Deschedule in SIMPREP or SIMSTEP.
Error in deschedule the time trigger <%name>. Descheduling allowed only in SimInit() or SimValidate(). Error in schedule the time trigger <%name>. Scheduling allowed only in SimInit() or SimValidate().

Page 3

12/16/2005

3.3 Library Extensions


New Action type is added to all State graph models in the Basic library. The wizard will display the new action type automatically in the combo box.

Page 4

12/16/2005

Вам также может понравиться