ModSlaveSim help v3.07 - 4.4.1. Making a simulation independent of Run Interval

Download manual: HTML

4.4.1. Making a simulation independent of Run Interval

In ModSlaveSim simulations, values are changed in discrete steps roughly every Run Interval seconds. If a value is incremented by a fixed amount at each step, then the value will change faster if the Run Interval is reduced. To make a simulation of a changing value independent of the Run Interval, the increment has to be adjusted appropriately.

In most cases, a statement that is used to adjust a register value will use a "rate of change" in the calculation, where the rate of change measures how much something changes in a second. For example, in a simulation of a tank being filled by water flowing from an inlet pipe, the level of water in the tank would be increased by the flow rate (measured, for example, in litres per second) divided by the cross-sectional area of the tank. In such cases, the rate has to be multipled by CycleTime to determine the change per simulation cycle, and this will make the simulation independent of the Run Interval.

In general, any statement that computes an increment for a register value should involve a multiplication by CycleTime, and the "rate" component of the statement will need to be identified in order to tell where to put the multiplication.