libximc 3.0.2
Working with user units

In addition to working in basic units(steps, encoder value), the library allows you to work with user units. For this purpose are used:

  • The structure of the conversion units calibration_t
  • The functions of which have doubles for working with user units, data structures for these functions
  • Coordinate correction table for more accurate positioning

The structure of the conversion units calibration_t

To specify conversion of the basic units in the user and back, calibration_t structure is used. With the help of coefficients A and MicrostepMode, specified in this structure, steps and microsteps which are integers are converted into the user value of the real type and back.

Conversion formulas:

  • The conversion to user units.
         user_value = A*(step + mstep/pow(2,MicrostepMode-1))
    
  • Conversion from user units.
         step = (int)(user_value/A)
         mstep = (user_value/A - step)*pow(2,MicrostepMode-1)
    

Alternative functions for working with user units and data structures for them

Structures and functions for working with user units have the _calb postfix. The user using these functions can perform all actions in their own units without worrying about the computations of the controller. The data format of _calb structures is described in detail. For _calb functions particular descriptions are not used. They perform the same actions as the basic functions do. The difference between them and the basic functions is in the position, velocity, and acceleration of the data types defined as user-defined. If clarification for _calb functions is necessary, they are provided as notes in the description of the basic functions.

Coordinate correction table for more accurate positioning

Some functions for working with user units support coordinate transformation using a correction table. To load a table from a file, the set_correction_table() function is used. Its description contains the functions and their data supporting correction.

Note
For data fields which are corrected in case of loading of the table in the description of the field is written - corrected by the table.

File format:

  • two columns separated by tabs;
  • column headers are string;
  • real type data, point is a separator;
  • the first column is the coordinate, the second is the deviation caused by a mechanical error;
  • the deviation between coordinates is calculated linearly;
  • constant is equal to the deviation at the boundary beyond the range;
  • maximum length of the table is 100 lines.

Sample file:

     X  dX
     0  0
     5.0        0.005
     10.0       -0.01