73 uint8_t encoder_ordinal,
74 bool activate_health_monitoring,
bool measurement_only,
75 uint32_t external_encoder_type_,
76 int32_t velocity_base_value_rpm = 0);
80 std::optional<MotionMasterError>
execute(uint64_t pending_signals)
override;
92 enum class CalibrationStage {
105 uint8_t encoder_ordinal_;
106 bool activate_health_monitoring_;
107 bool measurement_only_;
108 uint32_t external_encoder_type_;
109 int32_t velocity_base_value_rpm_;
111 int32_t hardware_id_;
112 int32_t multiturn_resolution_;
113 uint8_t default_msb_out_;
115 bool biss_reset_required_ =
false;
119 double calibration_velocity_base_value_rpm_;
120 double calibration_velocity_rpm_;
123 int32_t min_software_position_limit_;
124 int32_t max_software_position_limit_;
125 uint32_t position_encoder_singleturn_resolution_;
126 int32_t starting_position_;
127 double profile_acceleration_rpm_;
128 double start_recording_demand_velocity_rpm_;
130 double max_motor_speed_rpm_;
132 double feed_constant_;
136 bool commutation_offset_measurement_possible_ =
false;
138 MU_Handle mu_handle_;
140 MU_Calibration* mu_calibration_ =
nullptr;
142 MU_CalibrationAnalyzeResult* mu_analyze_result_ =
nullptr;
145 bool master_track_calibration_successful_ =
false;
146 bool nonius_track_calibration_successful_ =
false;
147 int32_t iteration_number_ = 0;
148 int32_t max_iterations_ = 13;
149 size_t number_of_samples_ = 6000;
150 size_t number_of_hrd_data_files_;
152 CalibrationStage calibration_stage_ = CalibrationStage::kInit;
154 bool validation_iteration_ =
false;
156 std::optional<std::future<MotionMasterError>> future_;
160 std::unique_ptr<SiUnitVelocity> si_unit_velocity_;
162 static constexpr float coarse_gain_values_[4] = {4.4f, 7.8f, 12.4f, 20.7f};
165 std::vector<std::pair<CalibrationParameters, CalibrationParameters>>
166 calibration_parameter_store_;
168 const std::vector<std::map<CirculoEncoderType, std::pair<int32_t, int32_t>>>
169 magnet_distance_amplification_limits_ = {
186 const std::vector<std::map<CirculoEncoderType, std::vector<double>>>
187 magnet_distance_polynomial_coefficients_ = {
190 {-1.93733026150236881113e-01, 1.84893973187097715449e-02,
191 -1.27277290997118431833e-04, 4.27826067036225706997e-07,
192 -5.20368296543940458560e-10, 0, 0}},
194 {-1.87769498023411640641e-01, 1.27635840217653444284e-02,
195 6.14758921668711374314e-04, -1.34096326750597602447e-05,
196 7.56425020103532749652e-08, 0, 0}},
198 {-1.04397317851772072905e-01, 1.70625714417142575197e-02,
199 -8.13961183382052607229e-05, -4.74936939216182293326e-07,
200 7.04504263424913605881e-09, -2.76371817076000863454e-11,
201 3.64854567222488168656e-14}},
203 {-2.84403156637705600840e-01, 3.12795823555360244517e-02,
204 -3.25259935985799334551e-04, 1.81647913872471759832e-06,
205 -4.91288513836093814287e-09, 5.10776292998975389867e-12, 0}}},
208 {-1.39784903650814168463e-01, 1.45325823633666237344e-02,
209 -7.50005188278302195896e-05, 1.61253405153954890157e-07,
210 -4.89306413790261647012e-11, 0, 0}},
212 {-1.81692029808327909501e-01, 3.02858503823710337177e-02,
213 1.23175956046672112430e-04, -8.59123594643554747716e-06,
214 6.60504319801355069769e-08, 0, 0}},
216 {-3.00602095387669798754e-01, 2.34428435042899098451e-02,
217 -2.62627767128114210458e-04, 1.69123403634972594129e-06,
218 -5.27050975872971237842e-09, 5.33125270236813597257e-12,
219 3.18588067695482955623e-15}},
221 {-1.66308923049894613611e-01, 1.82202872259577333680e-02,
222 3.95115033121136774701e-04, -1.41407239990230904438e-05,
223 1.61906309244842605822e-07, -8.18318393262045254823e-10,
224 1.54906578095712552649e-12}}},
227 {-1.93733026150236881113e-01, 1.84893973187097715449e-02,
228 -1.27277290997118431833e-04, 4.27826067036225706997e-07,
229 -5.20368296543940458560e-10, 0, 0}},
231 {-1.87769498023411640641e-01, 1.27635840217653444284e-02,
232 6.14758921668711374314e-04, -1.34096326750597602447e-05,
233 7.56425020103532749652e-08, 0, 0}},
235 {-1.04397317851772072905e-01, 1.70625714417142575197e-02,
236 -8.13961183382052607229e-05, -4.74936939216182293326e-07,
237 7.04504263424913605881e-09, -2.76371817076000863454e-11,
238 3.64854567222488168656e-14}},
240 {-2.84403156637705600840e-01, 3.12795823555360244517e-02,
241 -3.25259935985799334551e-04, 1.81647913872471759832e-06,
242 -4.91288513836093814287e-09, 5.10776292998975389867e-12, 0}}}};
262 void set_default_msb_out();
299 MU_Error analyze_and_compute_analog_adjustments(
300 const uint16_t* master_data,
const uint16_t* nonius_data,
327 std::pair<MotionMasterError, MU_Error> write_master_track_analog_parameters();
355 std::pair<MotionMasterError, MU_Error> write_nonius_track_analog_parameters();
398 static bool is_master_analog_within_tolerance(
418 static bool is_nonius_analog_within_tolerance(
440 std::pair<MotionMasterError, MU_Error> write_nonius_sync_table();
514 void print_calibration_summary();
516 void write_final_nonius_data_debug_file();
536 MU_Error apply_optimized_nonius_table();
555 void log_all_calibration_parameters();
578 void log_internal_calibration_state();
584 void limit_calibration_velocity(
double max_calibration_velocity_rpm,
585 bool notify =
false);
593 bool commutation_offset_measurement_possible();
595 int32_t convert_angle_to_position_units(
double angle)
const;