Overview
Every WMX3 parameter belongs to one of the following categories. Each category has an associated struct that holds the parameters for that category.
Category |
Struct |
Description |
|---|---|---|
These parameters affect feedback processing and statuses. |
||
These parameters affect homing. |
||
These parameters affect limit switches and soft limits. |
||
These parameters affect motion commands. |
||
These parameters affect amp alarms and other alarms. |
||
These parameters affect sync control. |
||
These parameters affect the flight recorder function. |
||
These parameters affect the emergency stop function. |
||
These parameters affect the basic operation of the axis. |
In addition to the structs listed above, the SystemParam struct is used for reading and writing parameter settings. This struct contains parameters of all categories except for Axis parameters.
Every parameter has an associated type, which includes double-precision floating point, signed and unsigned integers, and enumerator types that are defined by WMX3.
Writing Parameters
When the WMX3 engine is started, the default parameter settings are applied. See the parameter tables for the default values of each parameter.
To change the parameters from the default values, use one of the API functions for writing parameter settings. Whenever the WMX3 engine is restarted, the parameter settings will revert to the default values, and must be set again.
The WMX3 engine always holds one set of parameter settings, regardless of the number of devices created with the CreateDevice function. All devices that communicate with the WMX3 engine share the same parameter settings.
Every parameter has a range of valid values. See the parameter tables for the range of valid inputs for each parameter.
When one or more invalid parameter values are specified, the API function will return the ParameterSettingsInvalid error code and abort writing any of the parameters that were passed to that function.
Functions that write more than one parameter have an optional pParamError argument that is used to identify which parameter settings were invalid. If a pointer is passed to this argument, for each parameter in the passed object, 0 is written if pParam contained a valid value for that parameter and 1 is written if pParam contained an invalid value for that parameter. If no value is passed to this argument or if NULL is passed to this argument, the function will ignore this argument. The 0 or 1 is written using the same type as the parameter (e.g. parameters that use the double type will return 0.0 or 1.0 represented as a double type).
The following functions can be used to write the parameter settings. Some of these functions are overloaded, and share the same function name. Overloaded functions are differentiated by the function arguments that are passed to it.
Reading Parameters
To read the parameter settings that are currently set, use one of the API functions for reading parameter settings.
To set a specific parameter without changing the other parameter settings in the parameter category, read the current parameter settings, modify the value of the specific parameter, and then write back the parameter settings.
These functions can also be used to check if another WMX3 application has modified the parameter settings.
The following functions can be used to read the parameter settings. Some of these functions are overloaded, and share the same function name. Overloaded functions are differentiated by the function arguments that are passed to it.
Function |
Parameters Affected |
Axes Affected |
|---|---|---|
1 |
||
1 |
||
GetGearRatio(int axis, double *pNumerator, double *pDenominator) |
AxisParam.gearRatioNumerator, AxisParam.gearRatioDenominator |
1 |
GetSingleTurn(int axis, bool *pEnable, unsigned int *pEncoderCount) |
1 |
|
GetMovingAverageProfileTime(int axis, double *pMilliseconds) |
1 |
|
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
1 |
||
In addition to the above functions, the GetDefaultParam and GetDefaultAxisParam functions can be used to obtain the default values of each parameter. These functions are useful for resetting parameter settings to the default values.
Saving and Loading Parameters From File
The WMX3 engine does not save parameter settings when it is closed. To restore the parameter settings the next time the WMX3 engine is started, the parameter settings must be saved by the user.
Several functions are available for facilitating saving and loading parameter settings to and from file. In addition to these functions, it is always possible for the user to save the parameter settings using a different method of their choosing.
Export functions are used to save parameter settings to file. Parameter settings that are not specified as arguments to the Export function are not saved to the file.
Several overloaded Export functions accept an axis argument. Only the parameter settings for the specified axis are saved to file. Parameter settings for other axes are not saved to file.
Parameter settings that are passed to the Export function must first be read from the WMX3 engine using the functions for reading parameter settings. The GetAndExportAll function simplifies this procedure by reading the current parameter settings from the WMX3 engine and saving them to file with one function call.
Import functions are used to load parameter settings from files generated with the Export functions.
The parameter settings in the file are copied to the parameter structs passed as arguments to the Import function. Parameter settings that do not exist in the file are not copied to the parameter structs, and the parameter structs will retain the same values as when the Import was called.
Parameter settings that are loaded by the Import function must be written to the WMX3 engine using the functions for writing parameter settings. The ImportAndSetAll function simplifies this procedure by loading parameter settings from file and writing them to the WMX3 engine with one function call.
Several overloaded Import functions that accept an axis argument have an optional copyParamToAxes argument. If a pointer to an object of the AxisSelection class is passed to this argument, the function will also copy the imported axis parameters to the parameter structs of the other axes that are specified by the AxisSelection object. If no value is passed to the copyParamToAxes argument or if NULL is passed, the function will ignore this argument. The imported axis parameters are always copied to the parameter struct of the axis specified in the axis argument, regardless of the value of copyParamToAxes.
The following functions can be used to save parameter settings to file or load parameter settings from file. Some of these functions are overloaded, and share the same function name. Overloaded functions are differentiated by the function arguments that are passed to it. Each of these functions have overloaded versions that either accept the file path as a char string or as a wchar_t string. Only the version that accepts the file path as a char string is listed in this table for brevity.
Tutorials
The tutorial at Tutorial 3-8: Setting parameters contains an example of how to read and write parameters.
The tutorial at Tutorial 3-9: Saving and loading parameters from file contains an example of how to save and load parameters from file.