3 memory access through memset, memget statements, Programming – Lenze PM94P01C User Manual
Page 42
PM94P01C
40
Programming
In the RAM memory access program example, the values of PE (position error) are stored sequentially in the RAM
file every 100ms for 10 seconds. (100 samples). After collection is done the data is read from the file one by one and
compared with limit.
Variable VAR_MEM_INDEX is incremented every read or write by the value stored in VAR_MEM_INDEX_INCREMENT.
That value could be any value from -32767 to 32767. This way backwards reading is also possible. If the value is 0
(zero) no increment/decrement is produced. VAR_MEM_INDEX wraps around its min/max values. I.e. if the next read
or write will result in a value more (less) than 32767 (-32767), the index will be adjusted by modulo 32767. This allows
for the creation of circular arrays. This feature can be used for diagnostics when certain parameter(s) are stored in the
memory continuously and then if the system fails the data array can be examined to simplify diagnostics.
2.7.3 Memory Access Through MEMSET, MEMGET Statements
The memory access statements MEMSET and MEMGET are provided for simplified storage of data in the RAM memory
to/from the user variables V0-V31. Using these statements any combinations of variables V0-V31 can be stored/retrieved
with a single statement. This allows for efficient access to the RAM memory area. For example, in reading 10 variables
of the user’s program. Indeed for reading 10 variables V0-V10 it would normally require 10 read statements (Vx=VAR_
MEM_VALUE). With the MEMGET statement all V0-V10 can be read in one step. The format of MEMSET/MEMGET is
as follows:
MEMSET
MEMGET
any valid expression that evaluates to a number between -32767 to 32767
It specifies the offset in the RAM file where data will be stored or retrieved.
any combinations of variables V0-V31
Examples for
constant
10+23+1
constant expression
V0
variable
Must hold values in -32767 to 32767 range
V0+V1+3
expression
Must evaluate to -32767 to 32767 range
Example:
RAM file memory
0
1
2
3
4
5
6
... address increase
data
data
data
data
data
data
data
Examples for
single variable will be stored/retreived
[V0,V3,V2]
variables V0,V3,V2 will be stored/retrieved
[V3-V7]
variables V3 to V7 inclusively will be stored
[V0,V2,V4-V8] variables V0,V2, V4 through V8 will be stored
Storage/Retrieval order with MEMSET/MEMGET
Variables in the list are always stored in order: the variable with smallest index first and the variables with highest index
last regardless of the order they appear in the
Example: [V0,V3, V5-V7] will be stored in memory in the order of increasing memory index as follows:
RAM file memory
V0
V3
V5
V6
V7
...
...
... index increase
For comparison: [V5-V7, V0, V3] will have the same storage order as the above list regardless of the order in which the
variables are listed.