Bayley Wang / Mbed 2 deprecated foc-ed_in_the_bot_compact

Dependencies:   FastPWM3 mbed

BREMS/derived.h

Committer:
bwang
Date:
2018-02-10
Revision:
189:760cd81a7633
Parent:
188:43f50a4cc040
Child:
190:01674f19f9ce

File content as of revision 189:760cd81a7633:

/*
 *derived macros for the controller
 *don't change these unless you know what you're doing!
 */
 
#ifndef __DERIVED_H
#define __DERIVED_H

#include "layout.h"
#include "defaults.h"
#include "prefs.h"

/*max modulation depth at which inverter is still linear*/
#define LINEAR_MODULATION_MAX (2.f * LINEAR_DTC_MAX - 1.f)

/*internally computed loop parameters*/
#define KP_D (K_LOOP_D / BUS_VOLTAGE / LINEAR_MODULATION_MAX)
#define KI_D (KI_BASE_D * K_LOOP_D / BUS_VOLTAGE * 5000.0f / F_SW / LINEAR_MODULATION_MAX)

#define KP_Q (K_LOOP_Q / BUS_VOLTAGE / LINEAR_MODULATION_MAX)
#define KI_Q (KI_BASE_Q * K_LOOP_Q / BUS_VOLTAGE * 5000.0f / F_SW / LINEAR_MODULATION_MAX)

#define SLOW_LOOP_COUNTER ((int) (_F_SW / _F_SLOW_LOOP))

#endif