Modified Motor Driver Firmware to include Flash + Thermal

Dependencies:   FastPWM3 mbed-dev-STM-lean

Committer:
benkatz
Date:
Wed Dec 05 04:07:46 2018 +0000
Revision:
47:e1196a851f76
Parent:
45:26801179208e
Child:
48:74a40481740c
albert revision;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benkatz 20:bf9ea5125d52 1 #ifndef STRUCTS_H
benkatz 20:bf9ea5125d52 2 #define STRUCTS_H
benkatz 20:bf9ea5125d52 3
benkatz 20:bf9ea5125d52 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 float did_dt, diq_dt; // Current reference derivatives
benkatz 45:26801179208e 33 int loop_count; // Degubbing counter
benkatz 45:26801179208e 34 int timeout; // Watchdog counter
benkatz 22:60276ba87ac6 35 int mode;
benkatz 45:26801179208e 36 int ovp_flag; // Over-voltage flag
benkatz 45:26801179208e 37 float p_des, v_des, kp, kd, t_ff; // Desired position, velocity, gians, torque
benkatz 47:e1196a851f76 38 float v_ref, fw_int; // output voltage magnitude, field-weakening integral
benkatz 23:2adf23ee0305 39 float cogging[128];
benkatz 20:bf9ea5125d52 40 } ControllerStruct;
benkatz 20:bf9ea5125d52 41
benkatz 22:60276ba87ac6 42 typedef struct{
benkatz 47:e1196a851f76 43 float h;
benkatz 47:e1196a851f76 44 float k;
benkatz 47:e1196a851f76 45 float phi;
benkatz 47:e1196a851f76 46 float cos_integral;
benkatz 47:e1196a851f76 47 float sin_integral;
benkatz 47:e1196a851f76 48 float afc_out;
benkatz 47:e1196a851f76 49 } AFCStruct;
benkatz 47:e1196a851f76 50
benkatz 22:60276ba87ac6 51
benkatz 20:bf9ea5125d52 52 #endif