Modified Motor Driver Firmware to include Flash + Thermal
Dependencies: FastPWM3 mbed-dev-STM-lean
structs.h@78:4f481ff040ee, 21 months ago (annotated)
- Committer:
- adimmit
- Date:
- Fri Nov 11 16:58:43 2022 +0000
- Revision:
- 78:4f481ff040ee
- Parent:
- 69:ba1c89835a54
changes w/ filter @ high speed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
benkatz | 20:bf9ea5125d52 | 1 | #ifndef STRUCTS_H |
benkatz | 20:bf9ea5125d52 | 2 | #define STRUCTS_H |
benkatz | 20:bf9ea5125d52 | 3 | |
saloutos | 63:10604c39666f | 4 | #include "mbed.h" |
benkatz | 20:bf9ea5125d52 | 5 | #include "FastPWM.h" |
benkatz | 20:bf9ea5125d52 | 6 | |
benkatz | 20:bf9ea5125d52 | 7 | |
benkatz | 20:bf9ea5125d52 | 8 | typedef struct{ |
benkatz | 20:bf9ea5125d52 | 9 | DigitalOut *enable; |
benkatz | 37:c0f352d6e8e3 | 10 | DigitalOut *led; |
benkatz | 20:bf9ea5125d52 | 11 | FastPWM *pwm_u, *pwm_v, *pwm_w; |
benkatz | 20:bf9ea5125d52 | 12 | } GPIOStruct; |
benkatz | 20:bf9ea5125d52 | 13 | |
benkatz | 20:bf9ea5125d52 | 14 | typedef struct{ |
benkatz | 20:bf9ea5125d52 | 15 | |
benkatz | 20:bf9ea5125d52 | 16 | }COMStruct; |
benkatz | 20:bf9ea5125d52 | 17 | |
benkatz | 20:bf9ea5125d52 | 18 | typedef struct{ |
benkatz | 45:26801179208e | 19 | int adc1_raw, adc2_raw, adc3_raw; // Raw ADC Values |
benkatz | 45:26801179208e | 20 | float i_a, i_b, i_c; // Phase currents |
benkatz | 45:26801179208e | 21 | float v_bus; // DC link voltage |
benkatz | 45:26801179208e | 22 | float theta_mech, theta_elec; // Rotor mechanical and electrical angle |
benkatz | 45:26801179208e | 23 | float dtheta_mech, dtheta_elec, dtheta_elec_filt; // Rotor mechanical and electrical angular velocit |
benkatz | 47:e1196a851f76 | 24 | float i_d, i_q, i_q_filt, i_d_filt; // D/Q currents |
benkatz | 45:26801179208e | 25 | float v_d, v_q; // D/Q voltages |
benkatz | 45:26801179208e | 26 | float dtc_u, dtc_v, dtc_w; // Terminal duty cycles |
benkatz | 45:26801179208e | 27 | float v_u, v_v, v_w; // Terminal voltages |
benkatz | 45:26801179208e | 28 | float k_d, k_q, ki_d, ki_q, alpha; // Current loop gains, current reference filter coefficient |
benkatz | 45:26801179208e | 29 | float d_int, q_int; // Current error integrals |
benkatz | 45:26801179208e | 30 | int adc1_offset, adc2_offset; // ADC offsets |
benkatz | 45:26801179208e | 31 | float i_d_ref, i_q_ref, i_d_ref_filt, i_q_ref_filt; // Current references |
benkatz | 45:26801179208e | 32 | int loop_count; // Degubbing counter |
benkatz | 45:26801179208e | 33 | int timeout; // Watchdog counter |
benkatz | 22:60276ba87ac6 | 34 | int mode; |
benkatz | 45:26801179208e | 35 | int ovp_flag; // Over-voltage flag |
benkatz | 45:26801179208e | 36 | float p_des, v_des, kp, kd, t_ff; // Desired position, velocity, gians, torque |
benkatz | 47:e1196a851f76 | 37 | float v_ref, fw_int; // output voltage magnitude, field-weakening integral |
benkatz | 23:2adf23ee0305 | 38 | float cogging[128]; |
benkatz | 55:c4c9fec8539c | 39 | int current_sector; |
benkatz | 55:c4c9fec8539c | 40 | int otw_flag; // Over-temp warning |
benkatz | 55:c4c9fec8539c | 41 | float i_max; |
benkatz | 55:c4c9fec8539c | 42 | float inverter_tab[128]; |
elijahsj | 69:ba1c89835a54 | 43 | float velocity_sum; |
benkatz | 55:c4c9fec8539c | 44 | int oc_flag; |
benkatz | 20:bf9ea5125d52 | 45 | } ControllerStruct; |
benkatz | 20:bf9ea5125d52 | 46 | |
benkatz | 22:60276ba87ac6 | 47 | typedef struct{ |
benkatz | 48:74a40481740c | 48 | double temperature; // Estimated temperature |
benkatz | 55:c4c9fec8539c | 49 | float temp_measured; |
benkatz | 55:c4c9fec8539c | 50 | float q_in, q_out; |
benkatz | 48:74a40481740c | 51 | float resistance; |
benkatz | 55:c4c9fec8539c | 52 | float k; |
benkatz | 55:c4c9fec8539c | 53 | float trust; |
benkatz | 55:c4c9fec8539c | 54 | float delta_t; |
benkatz | 48:74a40481740c | 55 | } ObserverStruct; |
benkatz | 20:bf9ea5125d52 | 56 | #endif |