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

Add comments and suggestions #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

joaoantoniocardoso
Copy link
Member

No description provided.

@joaoantoniocardoso joaoantoniocardoso marked this pull request as draft August 4, 2023 04:06
Comment on lines +225 to +229
if (position_setpoint > STR_MAX_ANGLE) position_setpoint = STR_MAX_ANGLE; // STR_MAX_ANGLE should be +135
if (position_setpoint < STR_MIN_ANGLE) position_setpoint = STR_MIN_ANGLE; // STR_MIN_ANGLE should be -135

if (position_setpoint > STR_MAX_ANGLE) position_setpoint = STR_MAX_ANGLE;
if (position_setpoint < STR_MIN_ANGLE) position_setpoint = STR_MIN_ANGLE;
if (angle > STR_MAX_ANGLE) angle = STR_MAX_ANGLE; // STR_MAX_ANGLE should be +135
if (angle < STR_MIN_ANGLE) angle = STR_MIN_ANGLE; // STR_MIN_ANGLE should be -135
Copy link
Member Author

Choose a reason for hiding this comment

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

This is important to reduce the error accumulation of the PI integrator. If the values entering the PI are not in the same range/scale, it will cause a bias on the error variable, which can end up being unfixable in runtime, since we never reset the integrator.

Comment on lines +292 to +294
if (measurements.batvoltage_avg_sum_count++ > ULONG_MAX -1) {
average_measurements()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

here we prevent the overflow, although it would not happen even in a million years

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.

1 participant