For more information on accessing drive parameters in user programs, choose one of the following topics.
The Unidrive M parameters appear as predefined variables to the user program. The parameter names have the following format:
Mmm.Pppp
where
• | mm = the menu number |
• | ppp = the parameter number in the menu |
For example, to set menu 18, parameter 20 to the value 10, the following structured text could be used:
M18.P020 := 10;
The Unidrive M manual will give information on its available parameters, e.g. for accessing I/ O.
For other ways to access parameters see here.
Each drive parameter will have a defined numeric data type.
• | If the parameter has decimal places, the parameter value will be of type LREAL (64-bit floating point type). |
• | If the parameter does not have decimal places, the parameter value will be the smallest integer numeric type suitable, e.g. SINT, INT or DINT, which are respectively 8, 16 and 32-bit integer types. |
For example, on Unidrive M400, the Skip Reference 1 parameter has one decimal place, so the parameter value has type LREAL;
M01.P029 := 1.2; // This is valid, i.e. it is OK to assign a floating-point value to the parameter.
whereas, Application Menu 1, Read-Write Integer 21 has no decimal places, a valid numeric range of -32678 to 32767 and has the type INT:
M18.P021 := 100; // Write an integer value to parameter 18.021
When a user program is compiled, data values will be cast upwards, e.g. from INT to LREAL, but not downwards, e.g. from LREAL to INT. This means that assignments such as the following will fail as the compiler will not automatically cast the value:
M18.P021 := 1.0; // This will not compile.
Instead, write the assignment as:
M18.P021 := 1;
or even cast the value as follows:
M18.P020 := LREAL_TO_INT(1.0);
Note: This example is not meant to be realistic as most programs will assign values of similar types. However, understanding why and when there is a need to cast data types is important as it will be unfamiliar to SYPT Pro and SYPTLite users where all casts happen automatically.
See Also