Motor control for robots. More compact, less object-oriented revision.

Dependencies:   FastPWM3 mbed-dev

Fork of Hobbyking_Cheetah_V1 by Ben Katz

Committer:
benkatz
Date:
Wed Aug 30 18:10:27 2017 +0000
Revision:
33:3ab3cce8b44d
Parent:
26:2b865c00d7e9
Added firmware version number to debug stream.  Fixed duty cycle mistake

Who changed what in which revision?

UserRevisionLine numberNew contents of line
benkatz20:bf9ea5125d52 1#ifndef STRUCTS_H
benkatz20:bf9ea5125d52 2#define STRUCTS_H
benkatz20:bf9ea5125d52 3
benkatz20:bf9ea5125d52 4//#include "CANnucleo.h"
benkatz20:bf9ea5125d52 5#include "mbed.h"
benkatz20:bf9ea5125d52 6#include "FastPWM.h"
benkatz20:bf9ea5125d52 7
benkatz20:bf9ea5125d52 8
benkatz20:bf9ea5125d52 9typedef struct{
benkatz20:bf9ea5125d52 10 DigitalOut *enable;
benkatz20:bf9ea5125d52 11 FastPWM *pwm_u, *pwm_v, *pwm_w;
benkatz20:bf9ea5125d52 12 } GPIOStruct;
benkatz20:bf9ea5125d52 13
benkatz20:bf9ea5125d52 14typedef struct{
benkatz20:bf9ea5125d52 15
benkatz20:bf9ea5125d52 16 }COMStruct;
benkatz20:bf9ea5125d52 17
benkatz20:bf9ea5125d52 18typedef struct{
benkatz20:bf9ea5125d52 19 int adc1_raw, adc2_raw;
benkatz20:bf9ea5125d52 20 float i_a, i_b, i_c;
benkatz20:bf9ea5125d52 21 float v_bus;
benkatz20:bf9ea5125d52 22 float theta_mech, theta_elec;
benkatz20:bf9ea5125d52 23 float dtheta_mech, dtheta_elec;
benkatz20:bf9ea5125d52 24 float i_d, i_q;
benkatz20:bf9ea5125d52 25 float v_d, v_q;
benkatz20:bf9ea5125d52 26 float dtc_u, dtc_v, dtc_w;
benkatz20:bf9ea5125d52 27 float v_u, v_v, v_w;
benkatz20:bf9ea5125d52 28 float d_int, q_int;
benkatz20:bf9ea5125d52 29 int adc1_offset, adc2_offset;
benkatz20:bf9ea5125d52 30 float i_d_ref, i_q_ref;
benkatz22:60276ba87ac6 31 int loop_count;
benkatz28:8c7e29f719c5 32 int timeout;
benkatz22:60276ba87ac6 33 int mode;
benkatz26:2b865c00d7e9 34 float p_des, v_des, kp, kd, t_ff;
benkatz23:2adf23ee0305 35 float cogging[128];
benkatz20:bf9ea5125d52 36 } ControllerStruct;
benkatz20:bf9ea5125d52 37
benkatz22:60276ba87ac6 38typedef struct{
benkatz22:60276ba87ac6 39 float vel_1;
benkatz22:60276ba87ac6 40 float vel_1_old;
benkatz22:60276ba87ac6 41 float vel_1_est;
benkatz22:60276ba87ac6 42 float vel_2;
benkatz22:60276ba87ac6 43 float vel_2_old;
benkatz22:60276ba87ac6 44 float vel_2_est;
benkatz22:60276ba87ac6 45 float ts;
benkatz22:60276ba87ac6 46 float est;
benkatz22:60276ba87ac6 47 } VelocityEstimatorStruct;
benkatz22:60276ba87ac6 48
benkatz20:bf9ea5125d52 49#endif