4.11. Miscellaneous

A few other modules don’t have anything directly to do with the behavior of the MCAF but contribute to areas like math routines.

4.11.1. Implementation Notes

4.11.1.1. Modules

Module

Files

Description

Comments

filter
filter.h
filter_types.h

First order low-pass and high-pass filters

math_asm
math_asm.h
math_asm.s

Utility math routines

This contains an assembly implementation of a Q15 fixed-point square root Q15SQRT() which is likely to be replaced by one of two alternatives:

  • not using a square root at all (at present it is involved in saturation-handling logic in the vector current loop)

  • using the _Q15sqrt() function found in the standard libq library in the 16-Bit Language Tools Libraries

motor_control_function_mapping
motor_control_function_mapping.h

timing
timing.h

Utility routines for timing

units
units.h

C typedef indirections indicating engineering unit types (voltage, current, etc.)

util
util.h

Miscellaneous utility and math functions

Contains numerous inline utility functions with the prefix UTIL_ for things like squaring of Q15 numbers with a fixup for -32768, limiting a value between a minimum and maximum, etc.

Essentially all small functions that had potential for reuse were refactored and placed in this module.

parameters/motor_params
parameters/motor_params.h

Motor parameters (including R, L, Ke, J, etc.)

parameters/operating_params
parameters/operating_params.h

Operating parameters such as speed ranges and slew rates

parameters/timing_params
parameters/timing_params.h

Various timing parameters