zebra joint controller firmware (originally from MIT HKC motor controller by benkatz)

Dependencies:   mbed FastPWM3

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers structs.h Source File

structs.h

00001 #ifndef STRUCTS_H
00002 #define STRUCTS_H
00003 
00004 #include "mbed.h"
00005 #include "FastPWM.h"
00006 
00007 
00008 typedef struct{
00009     DigitalOut *enable;
00010     DigitalOut *led;
00011     FastPWM *pwm_u, *pwm_v, *pwm_w;
00012     } GPIOStruct;
00013     
00014 typedef struct{
00015     
00016     }COMStruct;
00017     
00018 typedef struct{
00019     int adc1_raw, adc2_raw, adc3_raw;                       // Raw ADC Values
00020     float i_a, i_b, i_c;                                    // Phase currents
00021     float v_bus;                                            // DC link voltage
00022     float theta_mech, theta_elec;                           // Rotor mechanical and electrical angle
00023     float dtheta_mech, dtheta_elec, dtheta_elec_filt;       // Rotor mechanical and electrical angular velocit
00024     float i_d, i_q, i_q_filt, i_d_filt;                               // D/Q currents
00025     float v_d, v_q;                                         // D/Q voltages
00026     float dtc_u, dtc_v, dtc_w;                              // Terminal duty cycles
00027     float v_u, v_v, v_w;                                    // Terminal voltages
00028     float k_d, k_q, ki_d, ki_q, alpha;                      // Current loop gains, current reference filter coefficient
00029     float d_int, q_int;                                     // Current error integrals
00030     int adc1_offset, adc2_offset;                           // ADC offsets
00031     float i_d_ref, i_q_ref, i_d_ref_filt, i_q_ref_filt;     // Current references
00032     int loop_count;                                         // Degubbing counter
00033     int timeout;                                            // Watchdog counter
00034     int mode;
00035     int ovp_flag;                                           // Over-voltage flag
00036     float p_des, v_des, kp, kd, t_ff;                       // Desired position, velocity, gians, torque
00037     float v_ref, fw_int;                                     // output voltage magnitude, field-weakening integral
00038     float cogging[128];
00039     } ControllerStruct;
00040 
00041 typedef struct{
00042     double temperature;                                              // Estimated temperature
00043     double temperature2;
00044     float resistance;
00045     }   ObserverStruct;
00046 #endif