Difference between revisions of "SimpleMotion parameter valid value range"

From Granite Devices Knowledge Wiki
Jump to: navigation, search
[checked revision][checked revision]
Line 6: Line 6:
  
 
To identify the limits of the parameter, one can use following method with SimpleMotion API:
 
To identify the limits of the parameter, one can use following method with SimpleMotion API:
<syntaxhighlight lang="c" line>
+
<syntaxhighlight lang="c" line="">
 
//read the actual value, minimum valid value and maximum valid value of SMP_TRAJ_PLANNER_VEL parameter
 
//read the actual value, minimum valid value and maximum valid value of SMP_TRAJ_PLANNER_VEL parameter
 
smint32 value, min, max;
 
smint32 value, min, max;
 
smRead3Parameters( busHandle, deviceAddress, SMP_TRAJ_PLANNER_VEL ,&value, SMP_TRAJ_PLANNER_VEL|SMP_MIN_VALUE_MASK,&min, SMP_TRAJ_PLANNER_VEL|SMP_MAX_VALUE_MASK, &max);
 
smRead3Parameters( busHandle, deviceAddress, SMP_TRAJ_PLANNER_VEL ,&value, SMP_TRAJ_PLANNER_VEL|SMP_MIN_VALUE_MASK,&min, SMP_TRAJ_PLANNER_VEL|SMP_MAX_VALUE_MASK, &max);
</syntaxhighlight>
+
</syntaxhighlight>The technique here is to read parameter value where address of parameter has been masked with SMP_MIN_VALUE_MASK or SMP_MAX_VALUE_MASK. Masked parameter addresses will return the minimum or maximum value that the parameter accepts.
  
 
==Complex value range==
 
==Complex value range==

Revision as of 12:03, 6 March 2018

Each writable SimpleMotion parameter has a value range that is accepted. In most cases the value range is just linear range between minimum and maximum values. In some cases value might have special binary format and valid values are more complexly defined.

Linear value range

There are two types of linear range parameters

  • parameters with no upper/lower bounds, except the bit length of the transmittable value
  • parameters with defined upper/lower bounds

To identify the limits of the parameter, one can use following method with SimpleMotion API:

  1. //read the actual value, minimum valid value and maximum valid value of SMP_TRAJ_PLANNER_VEL parameter
  2. smint32 value, min, max;
  3. smRead3Parameters( busHandle, deviceAddress, SMP_TRAJ_PLANNER_VEL ,&value, SMP_TRAJ_PLANNER_VEL|SMP_MIN_VALUE_MASK,&min, SMP_TRAJ_PLANNER_VEL|SMP_MAX_VALUE_MASK, &max);
The technique here is to read parameter value where address of parameter has been masked with SMP_MIN_VALUE_MASK or SMP_MAX_VALUE_MASK. Masked parameter addresses will return the minimum or maximum value that the parameter accepts.

Complex value range

Some parameters, such as SMP_SERIAL_ENC_BITS accepts a special binary format as value thus the valid range can't be defined with min-max method. In these cases, refer to simplemotion_defs.h for valid input values.