Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTC - Scalar Control General Functionality #71

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ImagineWagonsInSky
Copy link

@ImagineWagonsInSky ImagineWagonsInSky commented Feb 12, 2024

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

Copy link
Contributor

@lsalhani lsalhani left a comment

Choose a reason for hiding this comment

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

Quick look

Vq = Kp * IqError + integral_term_Iq;
}

void VectorController::parkTransform() {
Copy link
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
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
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
Copy link
Contributor

@TomLonergan03 TomLonergan03 left a comment

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
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
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
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
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