-
Notifications
You must be signed in to change notification settings - Fork 4
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
Launch control + Internal speed controller #31
base: launch-control
Are you sure you want to change the base?
Changes from 7 commits
5b01836
9eec3fb
b3966b2
006034d
03e951e
c10deee
db4525c
2d7e90d
8da3f67
b4d0d6b
2622873
4a10cb6
f4f3404
eca848d
890393f
27aa862
4c1a06f
cfc25f6
82cea62
a57023e
0f9ef25
edf9a9f
cf4b8db
608e157
0ac25e8
595b8ff
bf496d3
236b71a
5290511
5d62ad6
4f1f29b
8a2ae6a
f293b5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#ifndef __SPEED_CONTROLLER | ||
#define __SPEED_CONTROLLER | ||
|
||
#include "stm32f2xx_hal.h" | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
#include "can_handles.h" | ||
|
||
extern can0_VCUSpeedCntrlKpTimes1000_T kp_times_1000_frame; | ||
extern can0_VCUSpeedCntrlKiTimes1000_T ki_times_1000_frame; | ||
extern can0_VCUSpeedCntrlKdTimes1000_T kd_times_1000_frame; | ||
extern can0_VCUSpeedCntrlIWindupMax_T i_windup_max_frame; | ||
extern can0_VCUSpeedCntrlIWindupMin_T i_windup_min_frame; | ||
extern can0_VCUSpeedCntrlMinOutputValue_T min_output_value_frame; | ||
extern can0_VCUSpeedCntrlMaxOutputValue_T max_output_value_frame; | ||
extern can0_VCUSpeedCntrlMinInputValue_T min_input_value_frame; | ||
extern can0_VCUSpeedCntrlMaxInputValue_T max_input_value_frame; | ||
extern can0_VCUSpeedCntrlErrorUpdateTimeout_T error_update_timeout_frame; | ||
extern can0_VCUSpeedCntrlDt_T dt_frame; | ||
extern can0_VCUSpeedCntrlEnabled_T enabled_frame; | ||
extern can0_VCUSpeedCntrlOutOfInputRangeThrottled_T out_of_input_range_throttled_frame; | ||
extern can0_VCUSpeedCntrlOutOfOutputRangeThrottled_T out_of_output_range_throttled_frame; | ||
extern can0_VCUSpeedCntrlErrorUpdateTimedOut_T error_update_timed_out_frame; | ||
extern can0_VCUSpeedCntrlRPMSetpoint_T rpm_setpoint_frame; | ||
extern can0_VCUSpeedCntrlCommandedTorque_T commanded_torque_frame; | ||
extern can0_VCUSpeedCntrlRPMError_T rpm_error_frame; | ||
extern can0_VCUSpeedCntrlLastRPMError_T last_rpm_error_frame; | ||
extern can0_VCUSpeedCntrlDerivRPMError_T deriv_rpm_error_frame; | ||
extern can0_VCUSpeedCntrlRPMErrorAccumulated_T rpm_error_accumulated_frame; | ||
extern can0_VCUSpeedCntrlLastErrorUpdateTimestamp_T last_error_update_timestamp_frame; | ||
|
||
// PUBLIC STRUCTS | ||
typedef struct { | ||
int32_t kp_times_1000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small thing but this indentation is annoying |
||
int32_t ki_times_1000; | ||
int32_t kd_times_1000; | ||
int32_t i_windup_max; | ||
int32_t i_windup_min; | ||
int32_t min_output_value; | ||
int32_t max_output_value; | ||
int32_t min_input_value; | ||
int32_t max_input_value; | ||
int32_t dt; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe should be unsigned |
||
uint32_t error_update_timeout; | ||
} SpeedControllerParams; | ||
|
||
typedef struct { | ||
bool enabled; | ||
bool out_of_input_range_throttled; | ||
bool out_of_output_range_throttled; | ||
bool error_update_timed_out; | ||
int32_t rpm_setpoint; | ||
int32_t commanded_torque; | ||
int32_t rpm_error; | ||
int32_t last_rpm_error; | ||
int32_t deriv_rpm_error; | ||
int32_t rpm_error_accumulated; | ||
uint32_t last_error_update_timestamp; | ||
} SpeedControllerInternalVars; | ||
|
||
// PUBLIC FUNCTIONS | ||
void init_speed_controller_defaults(int32_t max_input_speed, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another annoying indentation inconsistency |
||
int32_t max_output_torque, uint32_t update_period_millis); | ||
void enable_speed_controller(void); | ||
void disable_speed_controller(void); | ||
void set_speed_controller_setpoint(int32_t rpm); | ||
void update_speed_controller_error(int32_t actual_rpm, | ||
uint32_t actual_rpm_msg_timestamp); | ||
int32_t get_speed_controller_torque_command(void); | ||
bool get_speed_controller_enabled(void); | ||
|
||
#endif // ifndef __SPEED_CONTROLLER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 space after
:
gore