robot

Dependencies:   FastPWM3 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers derived.h Source File

derived.h

00001 /*
00002  *derived macros for the controller
00003  *don't change these unless you know what you're doing!
00004  */
00005  
00006 #ifndef __DERIVED_H
00007 #define __DERIVED_H
00008 
00009 #include "hardware.h"
00010 #include "prefs.h"
00011 
00012 /*max modulation depth at which inverter is still linear*/
00013 #define LINEAR_MODULATION_MAX (2.f * LINEAR_DTC_MAX - 1.f)
00014 
00015 /*internally computed loop parameters*/
00016 #define KP_D (_K_LOOP_D / _BUS_VOLTAGE / LINEAR_MODULATION_MAX)
00017 #define KI_D (_KI_BASE_D * _K_LOOP_D / _BUS_VOLTAGE * 5000.0f / _F_SW / LINEAR_MODULATION_MAX)
00018 
00019 #define KP_Q (_K_LOOP_Q / _BUS_VOLTAGE / LINEAR_MODULATION_MAX)
00020 #define KI_Q (_KI_BASE_Q * _K_LOOP_Q / _BUS_VOLTAGE * 5000.0f / _F_SW / LINEAR_MODULATION_MAX)
00021 
00022 #define KP_W (_K_LOOP_W)
00023 #define KI_W (_KI_BASE_W * _K_LOOP_W * 5000.0f / _F_SW)
00024 
00025 #define SLOW_LOOP_COUNTER ((int) (_F_SW / _F_SLOW_LOOP))
00026 
00027 #endif