HRI board firmware v2.1 Microcontroller firmware of the board used during the HRI labs.

Macros | Functions | Variables
torque_regulator.c File Reference
`#include "communication.h"`
`#include "drivers/adc.h"`
`#include "drivers/dac.h"`
`#include "drivers/debug_gpio.h"`
`#include "drivers/incr_encoder.h"`
`#include "drivers/hall.h"`
`#include "drivers/h_bridge.h"`
`#include "drivers/callback_timers.h"`
`#include "lib/basic_filter.h"`
`#include "lib/pid.h"`
`#include "lib/utils.h"`
`#include "torque_regulator.h"`

## Macros
#define | KP_CURRENT_DEFAULT_VAL 100.0f
#define | KI_CURRENT_DEFAULT_VAL 500000.0f
#define | KD_CURRENT_DEFAULT_VAL 0.0f
#define | FF_CURRENT_DEFAULT_VAL MOTOR_RESISTANCE
#define | CURRENT_INTEGRATOR_SAT_DEFAULT_VAL 10.0f
#define | CURRENT_LOOP_PWM_MAX_DUTY_CYCLE 0.98f
#define | CURRENT_LOOP_PERIOD 50
#define | SOFTER_PID_DURATION 0.005f

## Functions
void | torq_RegulateCurrent ()
| Current regulation "loop" function. More...
void | torq_Init (void)
| Initialize the position and current controllers. More...
void | torq_StartCurrentLoop (void)
| Start the current regulation. More...
void | torq_SetTorque (float32_t torque)
| Sets the target motor torque. More...

## Variables
volatile float32_t | torq_targetCurrent
volatile pid_Pid | torq_currentPid
bool | torq_regulateCurrent
float32_t | torq_pidSoftModeTime

## Macro Definition Documentation

## ◆ CURRENT_INTEGRATOR_SAT_DEFAULT_VAL

#define CURRENT_INTEGRATOR_SAT_DEFAULT_VAL 10.0f

## ◆ CURRENT_LOOP_PERIOD

#define CURRENT_LOOP_PERIOD 50

## ◆ CURRENT_LOOP_PWM_MAX_DUTY_CYCLE

#define CURRENT_LOOP_PWM_MAX_DUTY_CYCLE 0.98f

## ◆ FF_CURRENT_DEFAULT_VAL

#define FF_CURRENT_DEFAULT_VAL MOTOR_RESISTANCE

## ◆ KD_CURRENT_DEFAULT_VAL

#define KD_CURRENT_DEFAULT_VAL 0.0f

## ◆ KI_CURRENT_DEFAULT_VAL

#define KI_CURRENT_DEFAULT_VAL 500000.0f

## ◆ KP_CURRENT_DEFAULT_VAL

#define KP_CURRENT_DEFAULT_VAL 100.0f

## ◆ SOFTER_PID_DURATION

#define SOFTER_PID_DURATION 0.005f

## Function Documentation

## ◆ torq_RegulateCurrent()

void torq_RegulateCurrent | ( | void |  | ) |

Current regulation "loop" function.

## Variable Documentation

## ◆ torq_currentPid

volatile pid_Pid torq_currentPid

## ◆ torq_pidSoftModeTime

float32_t torq_pidSoftModeTime

## ◆ torq_regulateCurrent

bool torq_regulateCurrent

## ◆ torq_targetCurrent

volatile float32_t torq_targetCurrent