Merge pull request #513 from TechAUmNu/Openloop-faults

Add fault check to openloop commands
This commit is contained in:
Benjamin Vedder 2022-07-24 22:25:04 +02:00 committed by GitHub
commit 0f40933c8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -844,6 +844,11 @@ void mcpwm_foc_set_handbrake(float current) {
* The RPM to use.
*/
void mcpwm_foc_set_openloop(float current, float rpm) {
// Check for an active fault
if (mc_interface_get_fault() != FAULT_CODE_NONE) {
return;
}
utils_truncate_number(&current, -get_motor_now()->m_conf->l_current_max * get_motor_now()->m_conf->l_current_max_scale,
get_motor_now()->m_conf->l_current_max * get_motor_now()->m_conf->l_current_max_scale);
@ -871,6 +876,11 @@ void mcpwm_foc_set_openloop(float current, float rpm) {
* The phase to use in degrees, range [0.0 360.0]
*/
void mcpwm_foc_set_openloop_phase(float current, float phase) {
// Check for an active fault
if (mc_interface_get_fault() != FAULT_CODE_NONE) {
return;
}
utils_truncate_number(&current, -get_motor_now()->m_conf->l_current_max * get_motor_now()->m_conf->l_current_max_scale,
get_motor_now()->m_conf->l_current_max * get_motor_now()->m_conf->l_current_max_scale);
@ -952,6 +962,11 @@ void mcpwm_foc_get_voltage_offsets_undriven(
* The RPM to use.
*/
void mcpwm_foc_set_openloop_duty(float dutyCycle, float rpm) {
// Check for an active fault
if (mc_interface_get_fault() != FAULT_CODE_NONE) {
return;
}
get_motor_now()->m_control_mode = CONTROL_MODE_OPENLOOP_DUTY;
get_motor_now()->m_duty_cycle_set = dutyCycle;
get_motor_now()->m_openloop_speed = RPM2RADPS_f(rpm);
@ -972,6 +987,11 @@ void mcpwm_foc_set_openloop_duty(float dutyCycle, float rpm) {
* The phase to use in degrees, range [0.0 360.0]
*/
void mcpwm_foc_set_openloop_duty_phase(float dutyCycle, float phase) {
// Check for an active fault
if (mc_interface_get_fault() != FAULT_CODE_NONE) {
return;
}
get_motor_now()->m_control_mode = CONTROL_MODE_OPENLOOP_DUTY_PHASE;
get_motor_now()->m_duty_cycle_set = dutyCycle;
get_motor_now()->m_openloop_phase = DEG2RAD_f(phase);