![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
derp
config.h@0:bac9c3a3a6ca, 2016-03-09 (annotated)
- Committer:
- bwang
- Date:
- Wed Mar 09 06:44:51 2016 +0000
- Revision:
- 0:bac9c3a3a6ca
- Child:
- 1:7b61790f6be9
open loop, working; motor draws ~400mA at 30V; pre-center aligned PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 0:bac9c3a3a6ca | 1 | #ifndef __CONFIG_H |
bwang | 0:bac9c3a3a6ca | 2 | #define __CONFIG_H |
bwang | 0:bac9c3a3a6ca | 3 | |
bwang | 0:bac9c3a3a6ca | 4 | #define set_dtc(phase, value) phase = 1.0f - (value) |
bwang | 0:bac9c3a3a6ca | 5 | |
bwang | 0:bac9c3a3a6ca | 6 | #define PWMA PA_8 |
bwang | 0:bac9c3a3a6ca | 7 | #define PWMB PA_9 |
bwang | 0:bac9c3a3a6ca | 8 | #define PWMC PA_10 |
bwang | 0:bac9c3a3a6ca | 9 | #define EN PB_15 |
bwang | 0:bac9c3a3a6ca | 10 | |
bwang | 0:bac9c3a3a6ca | 11 | #define IA PA_4 |
bwang | 0:bac9c3a3a6ca | 12 | #define IB PB_0 |
bwang | 0:bac9c3a3a6ca | 13 | #define TEST_DAC PA_5 |
bwang | 0:bac9c3a3a6ca | 14 | |
bwang | 0:bac9c3a3a6ca | 15 | #define PI 3.141593f |
bwang | 0:bac9c3a3a6ca | 16 | #define CPR 4096 |
bwang | 0:bac9c3a3a6ca | 17 | #define POS_OFFSET 5.3f |
bwang | 0:bac9c3a3a6ca | 18 | |
bwang | 0:bac9c3a3a6ca | 19 | #define I_SCALE_RAW 25.0f //mv/A |
bwang | 0:bac9c3a3a6ca | 20 | #define R_UP 12000.0f //ohms |
bwang | 0:bac9c3a3a6ca | 21 | #define R_DOWN 3600.0f //ohms |
bwang | 0:bac9c3a3a6ca | 22 | #define R_BIAS 3600.0f //ohms |
bwang | 0:bac9c3a3a6ca | 23 | #define AVDD 3300.0f //mV |
bwang | 0:bac9c3a3a6ca | 24 | |
bwang | 0:bac9c3a3a6ca | 25 | #define I_OFFSET (AVDD * R_DOWN * R_UP / (R_DOWN * R_UP + R_BIAS * (R_DOWN + R_UP))) |
bwang | 0:bac9c3a3a6ca | 26 | #define I_SCALE (R_BIAS * R_DOWN * I_SCALE_RAW / (R_DOWN * R_UP + R_BIAS * (R_DOWN + R_UP))) |
bwang | 0:bac9c3a3a6ca | 27 | |
bwang | 0:bac9c3a3a6ca | 28 | #define K_LOOP 5.0f |
bwang | 0:bac9c3a3a6ca | 29 | #define KI_BASE 0.01f |
bwang | 0:bac9c3a3a6ca | 30 | #define BUS_VOLTAGE 20.0f |
bwang | 0:bac9c3a3a6ca | 31 | |
bwang | 0:bac9c3a3a6ca | 32 | #define KP (K_LOOP / BUS_VOLTAGE) |
bwang | 0:bac9c3a3a6ca | 33 | #define KI (KI_BASE * K_LOOP / BUS_VOLTAGE) |
bwang | 0:bac9c3a3a6ca | 34 | |
bwang | 0:bac9c3a3a6ca | 35 | #endif |