Test the set param mode

Dependencies:   FastPWM3

Committer:
benkatz
Date:
Wed Jun 27 03:44:44 2018 +0000
Revision:
45:26801179208e
Parent:
37:c0f352d6e8e3
Child:
47:e1196a851f76
Lots of changes, seems to have broken calibration

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 "CANnucleo.h"
benkatz 20:bf9ea5125d52 5 #include "mbed.h"
benkatz 20:bf9ea5125d52 6 #include "FastPWM.h"
benkatz 20:bf9ea5125d52 7
benkatz 20:bf9ea5125d52 8
benkatz 20:bf9ea5125d52 9 typedef struct{
benkatz 20:bf9ea5125d52 10 DigitalOut *enable;
benkatz 37:c0f352d6e8e3 11 DigitalOut *led;
benkatz 20:bf9ea5125d52 12 FastPWM *pwm_u, *pwm_v, *pwm_w;
benkatz 20:bf9ea5125d52 13 } GPIOStruct;
benkatz 20:bf9ea5125d52 14
benkatz 20:bf9ea5125d52 15 typedef struct{
benkatz 20:bf9ea5125d52 16
benkatz 20:bf9ea5125d52 17 }COMStruct;
benkatz 20:bf9ea5125d52 18
benkatz 20:bf9ea5125d52 19 typedef struct{
benkatz 45:26801179208e 20 int adc1_raw, adc2_raw, adc3_raw; // Raw ADC Values
benkatz 45:26801179208e 21 float i_a, i_b, i_c; // Phase currents
benkatz 45:26801179208e 22 float v_bus; // DC link voltage
benkatz 45:26801179208e 23 float theta_mech, theta_elec; // Rotor mechanical and electrical angle
benkatz 45:26801179208e 24 float dtheta_mech, dtheta_elec, dtheta_elec_filt; // Rotor mechanical and electrical angular velocit
benkatz 45:26801179208e 25 float i_d, i_q, i_q_filt; // D/Q currents
benkatz 45:26801179208e 26 float v_d, v_q; // D/Q voltages
benkatz 45:26801179208e 27 float dtc_u, dtc_v, dtc_w; // Terminal duty cycles
benkatz 45:26801179208e 28 float v_u, v_v, v_w; // Terminal voltages
benkatz 45:26801179208e 29 float k_d, k_q, ki_d, ki_q, alpha; // Current loop gains, current reference filter coefficient
benkatz 45:26801179208e 30 float d_int, q_int; // Current error integrals
benkatz 45:26801179208e 31 int adc1_offset, adc2_offset; // ADC offsets
benkatz 45:26801179208e 32 float i_d_ref, i_q_ref, i_d_ref_filt, i_q_ref_filt; // Current references
benkatz 45:26801179208e 33 float did_dt, diq_dt; // Current reference derivatives
benkatz 45:26801179208e 34 int loop_count; // Degubbing counter
benkatz 45:26801179208e 35 int timeout; // Watchdog counter
benkatz 22:60276ba87ac6 36 int mode;
benkatz 45:26801179208e 37 int ovp_flag; // Over-voltage flag
benkatz 45:26801179208e 38 float p_des, v_des, kp, kd, t_ff; // Desired position, velocity, gians, torque
benkatz 23:2adf23ee0305 39 float cogging[128];
benkatz 20:bf9ea5125d52 40 } ControllerStruct;
benkatz 20:bf9ea5125d52 41
benkatz 22:60276ba87ac6 42 typedef struct{
benkatz 37:c0f352d6e8e3 43 float theta_m, theta_est;
benkatz 37:c0f352d6e8e3 44 float thetadot_m, thetadot_est;
benkatz 37:c0f352d6e8e3 45 float i_d_m, i_d_est;
benkatz 37:c0f352d6e8e3 46 float i_q_m, i_q_est;
benkatz 37:c0f352d6e8e3 47 float i_d_dot, i_q_dot;
benkatz 37:c0f352d6e8e3 48 float e_d, e_q;
benkatz 37:c0f352d6e8e3 49 float e_d_int, e_q_int;
benkatz 37:c0f352d6e8e3 50 } ObserverStruct;
benkatz 22:60276ba87ac6 51
benkatz 20:bf9ea5125d52 52 #endif