MotorWare f2806x Module API Documentation

- Main Page
- Modules
- Data Structures
- Files

Modules | Data Structures | Macros | Typedefs | Functions
MATH

## Modules
| Module overview

## Data Structures
struct | _MATH_vec2_
| Defines a two element vector. More...
struct | _MATH_vec3_
| Defines a three element vector. More...

## Macros
#define | MATH_Nm_TO_lbin_SF (8.8507457913)
| Defines conversion scale factor from N*m to lb*in. More...
#define | MATH_FOUR_OVER_THREE (1.33333333333333333333333333333333)
| Defines 4/3. More...
#define | MATH_TWO_OVER_THREE (0.66666666666666666666666666666667)
| Defines 2/3. More...
#define | MATH_ONE_OVER_THREE (0.33333333333333333333333333333333)
| Defines 1/3. More...
#define | MATH_ONE_OVER_PI (0.318309886183791)
| Defines 1/(pi) More...
#define | MATH_ONE_OVER_SQRT_THREE (0.57735026918962576450914878050196)
| Defines 1/sqrt(3) More...
#define | MATH_ONE_OVER_FOUR_PI (0.07957747154594767)
| Defines 1/(4*pi) More...
#define | MATH_ONE_OVER_TWO_PI (0.1591549430918954)
| Defines 1/(2*pi) More...
#define | MATH_PI (3.1415926535897932384626433832795)
| Defines pi. More...
#define | MATH_PI_PU (0.5)
| Defines pi per unit. More...
#define | MATH_TWO_PI (6.283185307179586)
| Defines 2*pi. More...
#define | MATH_TWO_PI_PU (1.0)
| Defines 2*pi per unit. More...
#define | MATH_FOUR_PI (12.56637061435917)
| Defines 4*pi. More...
#define | MATH_FOUR_PI_PU (2.0)
| Defines 4*pi per unit. More...
#define | MATH_PI_OVER_TWO (1.570796326794897)
| Defines pi/2. More...
#define | MATH_PI_OVER_TWO_PU (0.25)
| Defines pi/2 per unit. More...
#define | MATH_PI_OVER_FOUR (0.785398163397448)
| Defines pi/4. More...
#define | MATH_PI_OVER_FOUR_PU (0.125)
| Defines pi/4 per unit. More...
#define | rshft(A, n)
#define | rshft_1(A) (((A) + 0x1)>>1)
#define | rshft_2(A) (((A) + 0x2)>>2)
#define | rshft_3(A) (((A) + 0x4)>>3)
#define | rshft_4(A) (((A) + 0x8)>>4)
#define | rshft_5(A) (((A) + 0x10)>>5)
#define | rshft_6(A) (((A) + 0x20)>>6)
#define | rshft_7(A) (((A) + 0x40)>>7)
#define | rshft_8(A) (((A) + 0x80)>>8)
#define | rshft_9(A) (((A) + 0x100)>>9)
#define | rshft_10(A) (((A) + 0x200)>>10)
#define | rshft_11(A) (((A) + 0x400)>>11)
#define | rshft_12(A) (((A) + 0x800)>>12)
#define | rshft_13(A) (((A) + 0x1000)>>13)
#define | rshft_14(A) (((A) + 0x2000)>>14)
#define | rshft_15(A) (((A) + 0x4000)>>15)
#define | rshft_16(A) (((A) + 0x8000)>>16)
#define | rshft_17(A) (((A) + 0x10000)>>17)
#define | rshft_18(A) (((A) + 0x20000)>>18)
#define | rshft_19(A) (((A) + 0x40000)>>19)
#define | rshft_20(A) (((A) + 0x80000)>>20)
#define | rshft_21(A) (((A) + 0x100000)>>21)
#define | rshft_22(A) (((A) + 0x200000)>>22)
#define | rshft_23(A) (((A) + 0x400000)>>23)
#define | rshft_24(A) (((A) + 0x800000)>>24)
#define | rshft_25(A) (((A) + 0x1000000)>>25)
#define | rshft_26(A) (((A) + 0x2000000)>>26)
#define | rshft_27(A) (((A) + 0x4000000)>>27)
#define | rshft_28(A) (((A) + 0x8000000)>>28)
#define | rshft_29(A) (((A) + 0x10000000)>>29)
#define | rshft_30(A) (((A) + 0x20000000)>>30)
#define | rshft_31(A) (((A) + 0x40000000)>>31)
#define | rshft_32(A) (((A) + 0x80000000)>>32)
#define | lshft(A, n) ((A)<<(n))
#define | lshft_1(A) ((A)<<1)
#define | lshft_2(A) ((A)<<2)
#define | lshft_3(A) ((A)<<3)
#define | lshft_4(A) ((A)<<4)
#define | lshft_5(A) ((A)<<5)
#define | lshft_6(A) ((A)<<6)
#define | lshft_7(A) ((A)<<7)
#define | lshft_8(A) ((A)<<8)
#define | lshft_9(A) ((A)<<9)
#define | lshft_10(A) ((A)<<10)
#define | lshft_11(A) ((A)<<11)
#define | lshft_12(A) ((A)<<12)
#define | lshft_13(A) ((A)<<13)
#define | lshft_14(A) ((A)<<14)
#define | lshft_15(A) ((A)<<15)
#define | lshft_16(A) ((A)<<16)
#define | lshft_17(A) ((A)<<17)
#define | lshft_18(A) ((A)<<18)
#define | lshft_19(A) ((A)<<19)
#define | lshft_20(A) ((A)<<20)
#define | lshft_21(A) ((A)<<21)
#define | lshft_22(A) ((A)<<22)
#define | lshft_23(A) ((A)<<23)
#define | lshft_24(A) ((A)<<24)
#define | lshft_25(A) ((A)<<25)
#define | lshft_26(A) ((A)<<26)
#define | lshft_27(A) ((A)<<27)
#define | lshft_28(A) ((A)<<28)
#define | lshft_29(A) ((A)<<29)
#define | lshft_30(A) ((A)<<30)
#define | lshft_31(A) ((A)<<31)
#define | lshft_32(A) ((A)<<32)
#define | MATH_Nm_TO_lbin_SF ((float_t)(8.8507457913))
| Defines conversion scale factor from N*m to lb*in. More...
#define | MATH_TWO_OVER_THREE ((float_t)(0.66666666666666666666666666666667))
| Defines 2/3. More...
#define | MATH_ONE_OVER_THREE ((float_t)(0.33333333333333333333333333333333))
| Defines 1/3. More...
#define | MATH_ONE_OVER_PI ((float_t)(0.318309886183791))
| Defines 1/(pi) More...
#define | MATH_ONE_OVER_SQRT_THREE ((float_t)(0.57735026918962576450914878050196))
| Defines 1/sqrt(3) More...
#define | MATH_ONE_OVER_FOUR_PI ((float_t)(0.07957747154594767))
| Defines 1/(4*pi) More...
#define | MATH_ONE_OVER_TWO_PI ((float_t) (0.1591549430918954))
| Defines 1/(2*pi) More...
#define | MATH_PI ((float_t)(3.1415926535897932384626433832795))
| Defines pi. More...
#define | MATH_PI_PU ((float_t)(0.5))
| Defines pi per unit. More...
#define | MATH_TWO_PI ((float_t)(6.283185307179586))
| Defines 2*pi. More...
#define | MATH_TWO_PI_PU ((float_t)(1.0))
| Defines 2*pi per unit. More...
#define | MATH_FOUR_PI ((float_t)(12.56637061435917))
| Defines 4*pi. More...
#define | MATH_FOUR_PI_PU ((float_t)(2.0))
| Defines 4*pi per unit. More...
#define | MATH_PI_OVER_TWO ((float_t)(1.570796326794897))
| Defines pi/2. More...
#define | MATH_PI_OVER_TWO_PU ((float_t)(0.25))
| Defines pi/2 per unit. More...
#define | MATH_PI_OVER_FOUR ((float_t)(0.785398163397448))
| Defines pi/4. More...
#define | MATH_PI_OVER_FOUR_PU ((float_t)(0.125))
| Defines pi/4 per unit. More...

## Typedefs
typedef struct _MATH_vec2_ | MATH_vec2
| Defines a two element vector. More...
typedef struct _MATH_vec3_ | MATH_vec3
| Defines a three element vector. More...
typedef struct _MATH_vec2_ | MATH_vec2
| Defines a two element vector. More...
typedef struct _MATH_vec3_ | MATH_vec3
| Defines a three element vector. More...

## Functions
static float_t | MATH_abs (const float_t in)
| Finds the absolute value. More...
static float_t | MATH_incrAngle (const float_t angle_rad, const float_t angleDelta_rad)
| Increments an angle value and handles wrap-around. More...
static float_t | MATH_sat (const float_t in, const float_t max, const float_t min)
| Saturates the input value between the minimum and maximum values. More...

## Detailed Description

## Data Structure Documentation

struct _MATH_vec2_

Defines a two element vector.

Definition at line 248 of file 32b/math.h.

Data Fields
float_t | value[2] |
_iq | value[2] |

struct _MATH_vec3_

Defines a three element vector.

Definition at line 258 of file 32b/math.h.

Data Fields
float_t | value[3] |
_iq | value[3] |

## Macro Definition Documentation

#define lshft | ( |  | A,
|  |  | n
| ) |  | ((A)<<(n))

Definition at line 207 of file 32b/math.h.

#define lshft_1 | ( |  | A | ) | ((A)<<1)

Definition at line 209 of file 32b/math.h.

Referenced by CLARKE_run().

#define lshft_10 | ( |  | A | ) | ((A)<<10)

Definition at line 218 of file 32b/math.h.

#define lshft_11 | ( |  | A | ) | ((A)<<11)

Definition at line 219 of file 32b/math.h.

#define lshft_12 | ( |  | A | ) | ((A)<<12)

Definition at line 220 of file 32b/math.h.

#define lshft_13 | ( |  | A | ) | ((A)<<13)

Definition at line 221 of file 32b/math.h.

#define lshft_14 | ( |  | A | ) | ((A)<<14)

Definition at line 222 of file 32b/math.h.

#define lshft_15 | ( |  | A | ) | ((A)<<15)

Definition at line 223 of file 32b/math.h.

#define lshft_16 | ( |  | A | ) | ((A)<<16)

Definition at line 224 of file 32b/math.h.

#define lshft_17 | ( |  | A | ) | ((A)<<17)

Definition at line 225 of file 32b/math.h.

#define lshft_18 | ( |  | A | ) | ((A)<<18)

Definition at line 226 of file 32b/math.h.

#define lshft_19 | ( |  | A | ) | ((A)<<19)

Definition at line 227 of file 32b/math.h.

#define lshft_2 | ( |  | A | ) | ((A)<<2)

Definition at line 210 of file 32b/math.h.

#define lshft_20 | ( |  | A | ) | ((A)<<20)

Definition at line 228 of file 32b/math.h.

#define lshft_21 | ( |  | A | ) | ((A)<<21)

Definition at line 229 of file 32b/math.h.

#define lshft_22 | ( |  | A | ) | ((A)<<22)

Definition at line 230 of file 32b/math.h.

#define lshft_23 | ( |  | A | ) | ((A)<<23)

Definition at line 231 of file 32b/math.h.

#define lshft_24 | ( |  | A | ) | ((A)<<24)

Definition at line 232 of file 32b/math.h.

#define lshft_25 | ( |  | A | ) | ((A)<<25)

Definition at line 233 of file 32b/math.h.

#define lshft_26 | ( |  | A | ) | ((A)<<26)

Definition at line 234 of file 32b/math.h.

#define lshft_27 | ( |  | A | ) | ((A)<<27)

Definition at line 235 of file 32b/math.h.

#define lshft_28 | ( |  | A | ) | ((A)<<28)

Definition at line 236 of file 32b/math.h.

#define lshft_29 | ( |  | A | ) | ((A)<<29)

Definition at line 237 of file 32b/math.h.

#define lshft_3 | ( |  | A | ) | ((A)<<3)

Definition at line 211 of file 32b/math.h.

#define lshft_30 | ( |  | A | ) | ((A)<<30)

Definition at line 238 of file 32b/math.h.

#define lshft_31 | ( |  | A | ) | ((A)<<31)

Definition at line 239 of file 32b/math.h.

#define lshft_32 | ( |  | A | ) | ((A)<<32)

Definition at line 240 of file 32b/math.h.

#define lshft_4 | ( |  | A | ) | ((A)<<4)

Definition at line 212 of file 32b/math.h.

#define lshft_5 | ( |  | A | ) | ((A)<<5)

Definition at line 213 of file 32b/math.h.

#define lshft_6 | ( |  | A | ) | ((A)<<6)

Definition at line 214 of file 32b/math.h.

#define lshft_7 | ( |  | A | ) | ((A)<<7)

Definition at line 215 of file 32b/math.h.

#define lshft_8 | ( |  | A | ) | ((A)<<8)

Definition at line 216 of file 32b/math.h.

#define lshft_9 | ( |  | A | ) | ((A)<<9)

Definition at line 217 of file 32b/math.h.

#define MATH_FOUR_OVER_THREE (1.33333333333333333333333333333333)

Defines 4/3.

Definition at line 73 of file 32b/math.h.

#define MATH_FOUR_PI ((float_t)(12.56637061435917))

Defines 4*pi.

Definition at line 111 of file float/math.h.

#define MATH_FOUR_PI (12.56637061435917)

Defines 4*pi.

Definition at line 117 of file 32b/math.h.

#define MATH_FOUR_PI_PU ((float_t)(2.0))

Defines 4*pi per unit.

Definition at line 115 of file float/math.h.

#define MATH_FOUR_PI_PU (2.0)

Defines 4*pi per unit.

Definition at line 121 of file 32b/math.h.

#define MATH_Nm_TO_lbin_SF ((float_t)(8.8507457913))

Defines conversion scale factor from N*m to lb*in.

Definition at line 67 of file float/math.h.

#define MATH_Nm_TO_lbin_SF (8.8507457913)

Defines conversion scale factor from N*m to lb*in.

Definition at line 69 of file 32b/math.h.

Referenced by USER_computeTorque_lbin().

#define MATH_ONE_OVER_FOUR_PI ((float_t)(0.07957747154594767))

Defines 1/(4*pi)

Definition at line 87 of file float/math.h.

#define MATH_ONE_OVER_FOUR_PI (0.07957747154594767)

Defines 1/(4*pi)

Definition at line 93 of file 32b/math.h.

#define MATH_ONE_OVER_PI ((float_t)(0.318309886183791))

Defines 1/(pi)

Definition at line 79 of file float/math.h.

#define MATH_ONE_OVER_PI (0.318309886183791)

Defines 1/(pi)

Definition at line 85 of file 32b/math.h.

#define MATH_ONE_OVER_SQRT_THREE ((float_t)(0.57735026918962576450914878050196))

Defines 1/sqrt(3)

Definition at line 83 of file float/math.h.

#define MATH_ONE_OVER_SQRT_THREE (0.57735026918962576450914878050196)

Defines 1/sqrt(3)

Definition at line 89 of file 32b/math.h.

Referenced by CTRL_setupClarke_I(), and CTRL_setupClarke_V().

#define MATH_ONE_OVER_THREE ((float_t)(0.33333333333333333333333333333333))

Defines 1/3.

Definition at line 75 of file float/math.h.

#define MATH_ONE_OVER_THREE (0.33333333333333333333333333333333)

Defines 1/3.

Definition at line 81 of file 32b/math.h.

Referenced by CTRL_setupClarke_I(), and CTRL_setupClarke_V().

#define MATH_ONE_OVER_TWO_PI ((float_t) (0.1591549430918954))

Defines 1/(2*pi)

Definition at line 91 of file float/math.h.

#define MATH_ONE_OVER_TWO_PI (0.1591549430918954)

Defines 1/(2*pi)

Definition at line 97 of file 32b/math.h.

#define MATH_PI ((float_t)(3.1415926535897932384626433832795))

Defines pi.

Definition at line 95 of file float/math.h.

Referenced by MATH_incrAngle().

#define MATH_PI (3.1415926535897932384626433832795)

Defines pi.

Definition at line 101 of file 32b/math.h.

Referenced by USER_checkForErrors(), USER_computeFlux_pu_to_Wb_sf(), and USER_computeTorque_Flux_Iq_pu_to_Nm_sf().

#define MATH_PI_OVER_FOUR ((float_t)(0.785398163397448))

Defines pi/4.

Definition at line 127 of file float/math.h.

#define MATH_PI_OVER_FOUR (0.785398163397448)

Defines pi/4.

Definition at line 133 of file 32b/math.h.

#define MATH_PI_OVER_FOUR_PU ((float_t)(0.125))

Defines pi/4 per unit.

Definition at line 131 of file float/math.h.

#define MATH_PI_OVER_FOUR_PU (0.125)

Defines pi/4 per unit.

Definition at line 137 of file 32b/math.h.

#define MATH_PI_OVER_TWO ((float_t)(1.570796326794897))

Defines pi/2.

Definition at line 119 of file float/math.h.

#define MATH_PI_OVER_TWO (1.570796326794897)

Defines pi/2.

Definition at line 125 of file 32b/math.h.

#define MATH_PI_OVER_TWO_PU ((float_t)(0.25))

Defines pi/2 per unit.

Definition at line 123 of file float/math.h.

#define MATH_PI_OVER_TWO_PU (0.25)

Defines pi/2 per unit.

Definition at line 129 of file 32b/math.h.

#define MATH_PI_PU ((float_t)(0.5))

Defines pi per unit.

Definition at line 99 of file float/math.h.

#define MATH_PI_PU (0.5)

Defines pi per unit.

Definition at line 105 of file 32b/math.h.

#define MATH_TWO_OVER_THREE ((float_t)(0.66666666666666666666666666666667))

Defines 2/3.

Definition at line 71 of file float/math.h.

#define MATH_TWO_OVER_THREE (0.66666666666666666666666666666667)

Defines 2/3.

Definition at line 77 of file 32b/math.h.

Referenced by CTRL_setParams().

#define MATH_TWO_PI ((float_t)(6.283185307179586))

Defines 2*pi.

Definition at line 103 of file float/math.h.

Referenced by MATH_incrAngle().

#define MATH_TWO_PI (6.283185307179586)

Defines 2*pi.

Definition at line 109 of file 32b/math.h.

Referenced by CTRL_setParams(), and USER_setParams().

#define MATH_TWO_PI_PU ((float_t)(1.0))

Defines 2*pi per unit.

Definition at line 107 of file float/math.h.

#define MATH_TWO_PI_PU (1.0)

Defines 2*pi per unit.

Definition at line 113 of file 32b/math.h.

#define rshft | ( |  | A,
|  |  | n
| ) |  |

Definition at line 140 of file 32b/math.h.

#define rshft_1 | ( |  | A | ) | (((A) + 0x1)>>1)

Definition at line 174 of file 32b/math.h.

#define rshft_10 | ( |  | A | ) | (((A) + 0x200)>>10)

Definition at line 183 of file 32b/math.h.

#define rshft_11 | ( |  | A | ) | (((A) + 0x400)>>11)

Definition at line 184 of file 32b/math.h.

#define rshft_12 | ( |  | A | ) | (((A) + 0x800)>>12)

Definition at line 185 of file 32b/math.h.

#define rshft_13 | ( |  | A | ) | (((A) + 0x1000)>>13)

Definition at line 186 of file 32b/math.h.

#define rshft_14 | ( |  | A | ) | (((A) + 0x2000)>>14)

Definition at line 187 of file 32b/math.h.

#define rshft_15 | ( |  | A | ) | (((A) + 0x4000)>>15)

Definition at line 188 of file 32b/math.h.

#define rshft_16 | ( |  | A | ) | (((A) + 0x8000)>>16)

Definition at line 189 of file 32b/math.h.

#define rshft_17 | ( |  | A | ) | (((A) + 0x10000)>>17)

Definition at line 190 of file 32b/math.h.

#define rshft_18 | ( |  | A | ) | (((A) + 0x20000)>>18)

Definition at line 191 of file 32b/math.h.

#define rshft_19 | ( |  | A | ) | (((A) + 0x40000)>>19)

Definition at line 192 of file 32b/math.h.

#define rshft_2 | ( |  | A | ) | (((A) + 0x2)>>2)

Definition at line 175 of file 32b/math.h.

#define rshft_20 | ( |  | A | ) | (((A) + 0x80000)>>20)

Definition at line 193 of file 32b/math.h.

#define rshft_21 | ( |  | A | ) | (((A) + 0x100000)>>21)

Definition at line 194 of file 32b/math.h.

#define rshft_22 | ( |  | A | ) | (((A) + 0x200000)>>22)

Definition at line 195 of file 32b/math.h.

#define rshft_23 | ( |  | A | ) | (((A) + 0x400000)>>23)

Definition at line 196 of file 32b/math.h.

#define rshft_24 | ( |  | A | ) | (((A) + 0x800000)>>24)

Definition at line 197 of file 32b/math.h.

#define rshft_25 | ( |  | A | ) | (((A) + 0x1000000)>>25)

Definition at line 198 of file 32b/math.h.

#define rshft_26 | ( |  | A | ) | (((A) + 0x2000000)>>26)

Definition at line 199 of file 32b/math.h.

#define rshft_27 | ( |  | A | ) | (((A) + 0x4000000)>>27)

Definition at line 200 of file 32b/math.h.

#define rshft_28 | ( |  | A | ) | (((A) + 0x8000000)>>28)

Definition at line 201 of file 32b/math.h.

#define rshft_29 | ( |  | A | ) | (((A) + 0x10000000)>>29)

Definition at line 202 of file 32b/math.h.

#define rshft_3 | ( |  | A | ) | (((A) + 0x4)>>3)

Definition at line 176 of file 32b/math.h.

#define rshft_30 | ( |  | A | ) | (((A) + 0x20000000)>>30)

Definition at line 203 of file 32b/math.h.

#define rshft_31 | ( |  | A | ) | (((A) + 0x40000000)>>31)

Definition at line 204 of file 32b/math.h.

#define rshft_32 | ( |  | A | ) | (((A) + 0x80000000)>>32)

Definition at line 205 of file 32b/math.h.

#define rshft_4 | ( |  | A | ) | (((A) + 0x8)>>4)

Definition at line 177 of file 32b/math.h.

#define rshft_5 | ( |  | A | ) | (((A) + 0x10)>>5)

Definition at line 178 of file 32b/math.h.

#define rshft_6 | ( |  | A | ) | (((A) + 0x20)>>6)

Definition at line 179 of file 32b/math.h.

#define rshft_7 | ( |  | A | ) | (((A) + 0x40)>>7)

Definition at line 180 of file 32b/math.h.

#define rshft_8 | ( |  | A | ) | (((A) + 0x80)>>8)

Definition at line 181 of file 32b/math.h.

#define rshft_9 | ( |  | A | ) | (((A) + 0x100)>>9)

Definition at line 182 of file 32b/math.h.

## Typedef Documentation

typedef struct _MATH_vec2_ MATH_vec2

Defines a two element vector.

typedef struct _MATH_vec2_ MATH_vec2

Defines a two element vector.

typedef struct _MATH_vec3_ MATH_vec3

Defines a three element vector.

typedef struct _MATH_vec3_ MATH_vec3

Defines a three element vector.

## Function Documentation

static float_t MATH_abs | ( | const float_t | in | ) |
| inline static

Finds the absolute value.

Parameters

  [in] | in | The input value

Returns
  The absolute value

Definition at line 164 of file float/math.h.

static float_t MATH_incrAngle | ( | const float_t | angle_rad,
|  | const float_t | angleDelta_rad
| ) |  |
| inline static

Increments an angle value and handles wrap-around.

Parameters

  [in] | angle_rad | The angle value, rad
  [in] | angleDelta_rad | The angle increment value, rad

Returns
  The incremented angle value, rad

Definition at line 185 of file float/math.h.

References MATH_PI, and MATH_TWO_PI.

static float_t MATH_sat | ( | const float_t | in,
|  | const float_t | max,
|  | const float_t | min
| ) |  |
| inline static

Saturates the input value between the minimum and maximum values.

Parameters

  [in] | in | The input value
  [in] | max | The maximum value allowed
  [in] | min | The minimum value allowed

Returns
  The saturated value

Definition at line 218 of file float/math.h.

Referenced by HAL_writeDacData(), HAL_writePwmData(), PI_run_parallel(), PI_run_series(), PID_run_parallel(), PID_run_series(), and TRAJ_run().