Skip to content

MTC - Scalar Control General Functionality - #71

Open
ImagineWagonsInSky wants to merge 4 commits into
masterfrom
MTC-Vector_Control
Open

MTC - Scalar Control General Functionality#71
ImagineWagonsInSky wants to merge 4 commits into
masterfrom
MTC-Vector_Control

Conversation

@ImagineWagonsInSky

@ImagineWagonsInSky ImagineWagonsInSky commented Feb 12, 2024

Copy link
Copy Markdown

Class for Vector Control, header and main file. This is the initial overview of how vector control will work. We just need it now to merge with CAN messages. All steps are added until the space vector modulation

@lsalhani lsalhani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick look

Comment thread lib/motors/vector_controller.cpp Outdated
Vq = Kp * IqError + integral_term_Iq;
}

void VectorController::parkTransform() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inverse park

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. Changes done in second commit.

@ImagineWagonsInSky

Copy link
Copy Markdown
Author

Probably don't even need to review. We are apparently changing to scalar control now.

@TomLonergan03 TomLonergan03 changed the title Vector Control General Functionality MTC - Vector Control General Functionality Feb 14, 2024
@ImagineWagonsInSky ImagineWagonsInSky changed the title MTC - Vector Control General Functionality MTC - Scalar Control General Functionality Feb 19, 2024

@TomLonergan03 TomLonergan03 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, run clang-format over everything. Also, what is used as the actual PWM duty cycle? Or what values will that be calculated from?

Comment on lines +8 to +20
core::Float Ia;
core::Float Ib;
core::Float Ic;
core::Float rotorVelocity;
core::Float Id;
core::Float Iq;
core::Float Vd;
core::Float Vq;
core::Float IdRef;
core::Float IqRef;
core::Float Kp;
core::Float Ki;
core::Float theta;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Rename most of these to be clear on what they actually are
  2. Variables should be named in lower_snake_case and class data members should have a trailing _, so current_phase_a_ etc.
  3. Move the private block after public.

}


int main() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get rid of the main function

}

// Convert to 2-axis system
void VectorController::convertTo2Axis() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these functions should take parameters and return values instead of doing random stuff to internal variables, cos until the end of this function there will be a Id and Iq which are outdated

Comment on lines +27 to +31
void measureCurrentsAndVelocity(core::Float ia, core::Float ib, core::Float ic, core::Float rotorVelocity);
void convertTo2Axis();
void inverse2Axis();
void piControl();
void inverseParkTransform();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of these should be private, and used by public methods

Pass in the new currents and velocity and do the rest of it internally unless these methods definitely need to be called elsewhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants