Skip to content

Commit

Permalink
Made changes for compatible definitions and constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shobuj-Paul committed Feb 22, 2024
1 parent 21eaf7e commit d0bb9c7
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/math/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class integrator
float output, input_prev, Ts;

public:
integrator();
integrator(float initial_value = 0);
float loop(float input, float Ts);
};

Expand Down
18 changes: 11 additions & 7 deletions include/observers/bemf_observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ struct BemfOutput

class BemfObserver
{
DQUpdate dq_update;
Tracker tracker;
float speed_prev, angle_prev, Vbus_prev;

public:
DQUpdate dq_update;
Tracker tracker;

BemfObserver();
BemfOutput loop(math::FrameABC line_currents, math::FrameABC line_voltages, math::FrameABC duties, float Vbus,
const float Ts, const SetBemfParams& set_bemf_params, const SetTrackerParams& set_tracker_params,
const ExtBemfParams& ext_bemf_params, const ExtTrackerParams& ext_tracker_params,
uint8_t pos_obs_mode, uint8_t idle_mode, uint8_t opmode, const uint8_t num_rotor_poles,
const uint8_t freq_mode, bool force_bemf, bool en_dis_6_step_comm);
BemfOutput loop(const math::FrameABC& line_currents, const math::FrameABC& line_voltages,
const math::FrameABC& duties, float Vbus, const float Ts,
const SetBemfParams& set_bemf_params,
const SetTrackerParams& set_tracker_params,
const ExtBemfParams& ext_bemf_params,
const ExtTrackerParams& ext_tracker_params, const uint8_t pos_obs_mode,
const uint8_t idle_mode, const uint8_t opmode, const uint8_t num_rotor_poles,
const uint8_t freq_mode, const bool force_bemf, const bool en_dis_6_step_comm);
};
} // namespace observers
3 changes: 2 additions & 1 deletion include/observers/dq_update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ class DQUpdate
controllers::PIController d_axis, q_axis;

public:
DQUpdate();
controllers::PIConfig config;
BemfGains gains;

DQUpdate();
DQUpdate(controllers::PIConfig config, BemfGains gains);
float loop(math::FrameAlphaBeta currents, math::FrameAlphaBeta voltages, float angular_velocity, float rotor_angle,
const SetBemfParams& set_params = SetBemfParams(), const ExtBemfParams& ext_params = ExtBemfParams());
math::FrameDQ get_emfs() const;
Expand Down
2 changes: 2 additions & 0 deletions include/observers/tracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class Tracker

public:
controllers::PIConfig config;

Tracker() = default;
Tracker(controllers::PIConfig config);
float loop(float phase_error, const SetTrackerParams& params = SetTrackerParams(),
const ExtTrackerParams& ext_params = ExtTrackerParams());
float speed_tracker(float angle_est, float Ts);
Expand Down
2 changes: 1 addition & 1 deletion src/math/operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ float math::differentiator::loop(float input, float Ts)
return output;
}

math::integrator::integrator() : output(0), input_prev(0)
math::integrator::integrator(float initial_value) : output(0), input_prev(initial_value)
{
}

Expand Down
10 changes: 5 additions & 5 deletions src/observers/bemf_observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ observers::BemfObserver::BemfObserver() : speed_prev(0), angle_prev(0)
{
}

observers::BemfOutput observers::BemfObserver::loop(math::FrameABC line_currents, math::FrameABC line_voltages,
math::FrameABC duties, float Vbus, const float Ts,
observers::BemfOutput observers::BemfObserver::loop(const math::FrameABC& line_currents, const math::FrameABC& line_voltages,
const math::FrameABC& duties, float Vbus, const float Ts,
const SetBemfParams& set_bemf_params,
const SetTrackerParams& set_tracker_params,
const ExtBemfParams& ext_bemf_params,
const ExtTrackerParams& ext_tracker_params, uint8_t pos_obs_mode,
uint8_t idle_mode, uint8_t opmode, const uint8_t num_rotor_poles,
const uint8_t freq_mode, bool force_bemf, bool en_dis_6_step_comm)
const ExtTrackerParams& ext_tracker_params, const uint8_t pos_obs_mode,
const uint8_t idle_mode, const uint8_t opmode, const uint8_t num_rotor_poles,
const uint8_t freq_mode, const bool force_bemf, const bool en_dis_6_step_comm)
{
observers::BemfOutput output;

Expand Down
4 changes: 4 additions & 0 deletions src/observers/dq_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ observers::DQUpdate::DQUpdate() : I_prev(0, 0), X_prev(0, 0), E(0, 0)
{
}

observers::DQUpdate::DQUpdate(controllers::PIConfig config, BemfGains gains) : I_prev(0, 0), X_prev(0, 0), E(0, 0), config(config), gains(gains)
{
}

float observers::DQUpdate::loop(math::FrameAlphaBeta currents, math::FrameAlphaBeta voltages, float angular_velocity,
float rotor_angle, const SetBemfParams& set_params, const ExtBemfParams& ext_params)
{
Expand Down
6 changes: 5 additions & 1 deletion src/observers/tracker.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <observers/tracker.hpp>

float observers::Tracker::loop(float phase_error, controllers::PIConfig config, const SetTrackerParams& set_params,
float observers::Tracker::loop(float phase_error, const SetTrackerParams& set_params,
const ExtTrackerParams& ext_params)
{
if (set_params.error)
Expand All @@ -12,6 +12,10 @@ float observers::Tracker::loop(float phase_error, controllers::PIConfig config,
return angle_est;
}

observers::Tracker::Tracker(controllers::PIConfig config) : config(config)
{
}

float observers::Tracker::speed_tracker(float angle_est, float Ts)
{
return angle_integrator.loop(angle_est, Ts);
Expand Down

0 comments on commit d0bb9c7

Please sign in to comment.