ModMultiSim help v3.04 - 4.2. Language: Quick Start Guide

Download manual: HTML

4.2. Language: Quick Start Guide

This is a quick overview of features specific to the ModMultiSim language, as well as features common to other languages.

The main variables include slave registers and environment properties. In ModMultiSim, an identifier for a slave register consists of the register address preceded by '$', as in $3058, or the slave id and register address, each preceded by '$', as in $2$7005. (The latter form is used to refer to a register of a specific slave from the statement of an environment property). An identifier for an environment property is the name of the property preceded by '$' as in $ValveOpen.

There is also an alternative form $$ that can be used to refer to 'this register' (the register or property associated with the statement). Note that the 'this register' notation $$ is useful if you want to enter a block of registers with essentially the same behaviour, but where the behaviour varies through a reference to the associated register. It saves having to refer to each register by address.

Conditionals are available in the form if then else and may be nested. All arithmetic and logic operators are available, and, additionally, bit-manipulation operators.

Assignment of a value to a variable (whether a slave register or an environment property) is implicit in the statement that is entered for the slave register or property. That is to say, when the value of the expression for a register is computed, it is automatically assigned to the register or property, for which it has been entered, at the end of each cycle. So, the value of the expression in a statement for register $5010 will be assigned to $5010 (and displayed in the main dialog in the Value column of $5010).

CycleTime and TimeNow are two predefined variables in the language, neither of which can be modified directly from your program. Both values are represented as floating point numbers with millisecond precision. CycleTime is the actual time between runs, that is, the actual time between computing the values of the registers. (The Run Interval is the specified target time between runs.) The value of CycleTime may differ slightly from the Run Interval during the simulation since the operating system may vary in how fast it allocates resources for each run. As we shall see in the Techniques section later, CycleTime can be used to ensure the computation frequency does not influence the outcome. The TimeNow variable holds the current time in seconds (since 1970-01-01), and this, of course, changes throughout the simulation.

This concludes the quick guide, full detail is provided in the reference section ModMultiSim Language