72 uint8_t encoder_ordinal,
73 bool activate_health_monitoring,
bool measurement_only,
74 uint32_t external_encoder_type_,
75 int32_t velocity_base_value_rpm = 0);
79 std::optional<MotionMasterError>
execute(uint64_t pending_signals)
override;
91 enum class CalibrationStage {
104 uint8_t encoder_ordinal_;
105 bool activate_health_monitoring_;
106 bool measurement_only_;
107 uint32_t external_encoder_type_;
108 int32_t velocity_base_value_rpm_;
110 int32_t hardware_id_;
111 int32_t multiturn_resolution_;
112 uint8_t default_msb_out_;
114 bool biss_reset_required_ =
false;
118 double calibration_velocity_base_value_rpm_;
119 double calibration_velocity_rpm_;
122 int32_t min_software_position_limit_;
123 int32_t max_software_position_limit_;
124 uint32_t position_encoder_singleturn_resolution_;
125 int32_t starting_position_;
126 double profile_acceleration_rpm_;
127 double start_recording_demand_velocity_rpm_;
129 double max_motor_speed_rpm_;
131 double feed_constant_;
135 bool commutation_offset_measurement_possible_ =
false;
137 MU_Handle mu_handle_;
139 MU_Calibration* mu_calibration_ =
nullptr;
141 MU_CalibrationAnalyzeResult* mu_analyze_result_ =
nullptr;
144 bool master_track_calibration_successful_ =
false;
145 bool nonius_track_calibration_successful_ =
false;
146 int32_t iteration_number_ = 0;
147 int32_t max_iterations_ = 13;
148 size_t number_of_samples_ = 6000;
150 CalibrationStage calibration_stage_ = CalibrationStage::kInit;
152 bool validation_iteration_ =
false;
154 std::optional<std::future<MotionMasterError>> future_;
160 std::string stage_failure_reason_;
163 std::string failure_reason_;
166 std::optional<uint8_t> hardware_revision_;
167 std::optional<calibration_history::Quality> quality_;
168 bool eeprom_written_ =
false;
170 std::unique_ptr<SiUnitVelocity> si_unit_velocity_;
172 static constexpr float coarse_gain_values_[4] = {4.4f, 7.8f, 12.4f, 20.7f};
175 std::vector<std::pair<CalibrationParameters, CalibrationParameters>>
176 calibration_parameter_store_;
178 const std::vector<std::map<CirculoEncoderType, std::pair<int32_t, int32_t>>>
179 magnet_distance_amplification_limits_ = {
196 const std::vector<std::map<CirculoEncoderType, std::vector<double>>>
197 magnet_distance_polynomial_coefficients_ = {
200 {-1.93733026150236881113e-01, 1.84893973187097715449e-02,
201 -1.27277290997118431833e-04, 4.27826067036225706997e-07,
202 -5.20368296543940458560e-10, 0, 0}},
204 {-1.87769498023411640641e-01, 1.27635840217653444284e-02,
205 6.14758921668711374314e-04, -1.34096326750597602447e-05,
206 7.56425020103532749652e-08, 0, 0}},
208 {-1.04397317851772072905e-01, 1.70625714417142575197e-02,
209 -8.13961183382052607229e-05, -4.74936939216182293326e-07,
210 7.04504263424913605881e-09, -2.76371817076000863454e-11,
211 3.64854567222488168656e-14}},
213 {-2.84403156637705600840e-01, 3.12795823555360244517e-02,
214 -3.25259935985799334551e-04, 1.81647913872471759832e-06,
215 -4.91288513836093814287e-09, 5.10776292998975389867e-12, 0}}},
218 {-1.39784903650814168463e-01, 1.45325823633666237344e-02,
219 -7.50005188278302195896e-05, 1.61253405153954890157e-07,
220 -4.89306413790261647012e-11, 0, 0}},
222 {-1.81692029808327909501e-01, 3.02858503823710337177e-02,
223 1.23175956046672112430e-04, -8.59123594643554747716e-06,
224 6.60504319801355069769e-08, 0, 0}},
226 {-3.00602095387669798754e-01, 2.34428435042899098451e-02,
227 -2.62627767128114210458e-04, 1.69123403634972594129e-06,
228 -5.27050975872971237842e-09, 5.33125270236813597257e-12,
229 3.18588067695482955623e-15}},
231 {-1.66308923049894613611e-01, 1.82202872259577333680e-02,
232 3.95115033121136774701e-04, -1.41407239990230904438e-05,
233 1.61906309244842605822e-07, -8.18318393262045254823e-10,
234 1.54906578095712552649e-12}}},
237 {-1.93733026150236881113e-01, 1.84893973187097715449e-02,
238 -1.27277290997118431833e-04, 4.27826067036225706997e-07,
239 -5.20368296543940458560e-10, 0, 0}},
241 {-1.87769498023411640641e-01, 1.27635840217653444284e-02,
242 6.14758921668711374314e-04, -1.34096326750597602447e-05,
243 7.56425020103532749652e-08, 0, 0}},
245 {-1.04397317851772072905e-01, 1.70625714417142575197e-02,
246 -8.13961183382052607229e-05, -4.74936939216182293326e-07,
247 7.04504263424913605881e-09, -2.76371817076000863454e-11,
248 3.64854567222488168656e-14}},
250 {-2.84403156637705600840e-01, 3.12795823555360244517e-02,
251 -3.25259935985799334551e-04, 1.81647913872471759832e-06,
252 -4.91288513836093814287e-09, 5.10776292998975389867e-12, 0}}}};
272 void set_default_msb_out();
309 MU_Error analyze_and_compute_analog_adjustments(
310 const uint16_t* master_data,
const uint16_t* nonius_data,
337 std::pair<MotionMasterError, MU_Error> write_master_track_analog_parameters();
365 std::pair<MotionMasterError, MU_Error> write_nonius_track_analog_parameters();
408 static bool is_master_analog_within_tolerance(
428 static bool is_nonius_analog_within_tolerance(
450 std::pair<MotionMasterError, MU_Error> write_nonius_sync_table();
534 const std::string& reason);
549 void note_failure_reason(
const std::string& reason);
558 const std::string& reason,
const char* file,
570 void print_calibration_summary();
572 void write_final_nonius_data_debug_file();
592 MU_Error apply_optimized_nonius_table();
611 void log_all_calibration_parameters();
634 void log_internal_calibration_state();
640 void limit_calibration_velocity(
double max_calibration_velocity_rpm,
641 bool notify =
false);
649 bool commutation_offset_measurement_possible();
651 int32_t convert_angle_to_position_units(
double angle)
const;