Nathaniel Honka / Mbed 2 deprecated Motion-Control

Dependencies:   FiniteStateMachine HipControl Knee LinearBlend1 LocalFileSystem_Read dataComm hapticFeedback initExoVars mbed Blend_Generator Brad_poly_gait Gait_Generator MM_gait Encoders IMUdriver

Fork of Motion Control by HEL's Angels

Committer:
perr1940
Date:
Fri Nov 14 22:39:10 2014 +0000
Revision:
0:d38d627c922f
Child:
13:c588cb388240
this is without encoders going to test the knee steppers alone.  They work alone but not with the encoders.  Strange huh?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
perr1940 0:d38d627c922f 1
perr1940 0:d38d627c922f 2
perr1940 0:d38d627c922f 3 #ifndef INIT_H
perr1940 0:d38d627c922f 4 #define INIT_H
perr1940 0:d38d627c922f 5
perr1940 0:d38d627c922f 6 #include "mbed.h"
perr1940 0:d38d627c922f 7 #include "Encoder.h"
perr1940 0:d38d627c922f 8 #include "HipControl.h"
perr1940 0:d38d627c922f 9 #include "knee.h"
perr1940 0:d38d627c922f 10 #include "FSM.h"
perr1940 0:d38d627c922f 11 #define PI (3.141592653589793)
perr1940 0:d38d627c922f 12
perr1940 0:d38d627c922f 13 //#define SAMPLE_TIME .005
perr1940 0:d38d627c922f 14 #define SAMPLE_TIME .001
perr1940 0:d38d627c922f 15 #define TO_RAD(x) (x * 0.01745329252) // *pi/180
perr1940 0:d38d627c922f 16
perr1940 0:d38d627c922f 17 /********************************
perr1940 0:d38d627c922f 18 * Initializing various I/O pins!
perr1940 0:d38d627c922f 19 ********************************/
perr1940 0:d38d627c922f 20 extern DigitalOut mbedLED1;
perr1940 0:d38d627c922f 21 extern DigitalOut mbedLED2;
perr1940 0:d38d627c922f 22 extern DigitalOut mbedLED3;
perr1940 0:d38d627c922f 23 extern DigitalOut motorLED;
perr1940 0:d38d627c922f 24
perr1940 0:d38d627c922f 25 extern SPI dataBedSPI; // mosi, miso, sclk
perr1940 0:d38d627c922f 26 extern DigitalOut DB_cs;
perr1940 0:d38d627c922f 27 extern SPI IMUspi;
perr1940 0:d38d627c922f 28 extern DigitalOut IMUcs;
perr1940 0:d38d627c922f 29 extern Serial pc;
perr1940 0:d38d627c922f 30
perr1940 0:d38d627c922f 31 // Setup stuff
perr1940 0:d38d627c922f 32 // absolutes
perr1940 0:d38d627c922f 33 //extern SPI encoder_L;
perr1940 0:d38d627c922f 34 //extern DigitalOut encoder_cs_L;
perr1940 0:d38d627c922f 35 //extern SPI encoder_R;
perr1940 0:d38d627c922f 36 //extern DigitalOut encoder_cs_R;
perr1940 0:d38d627c922f 37 extern Encoder encoder_L;
perr1940 0:d38d627c922f 38 extern Encoder encoder_R;
perr1940 0:d38d627c922f 39
perr1940 0:d38d627c922f 40 // Incremental Indexes (only for homing!)
perr1940 0:d38d627c922f 41 extern InterruptIn encIdx_R;
perr1940 0:d38d627c922f 42 extern InterruptIn encIdx_L;
perr1940 0:d38d627c922f 43
perr1940 0:d38d627c922f 44 // Right Leg
perr1940 0:d38d627c922f 45 extern PwmOut pwmpin_R;
perr1940 0:d38d627c922f 46 extern DigitalOut dirpin_R;
perr1940 0:d38d627c922f 47
perr1940 0:d38d627c922f 48 //Left Leg
perr1940 0:d38d627c922f 49 //extern PwmOut pwmpin_L;
perr1940 0:d38d627c922f 50 //extern DigitalOut dirpin_L;
perr1940 0:d38d627c922f 51 extern HipControl hip_L;
perr1940 0:d38d627c922f 52 extern HipControl hip_R;
perr1940 0:d38d627c922f 53 extern Knee knee_L;
perr1940 0:d38d627c922f 54 extern Knee knee_R;
perr1940 0:d38d627c922f 55
perr1940 0:d38d627c922f 56 extern FSM fsm;
perr1940 0:d38d627c922f 57
perr1940 0:d38d627c922f 58
perr1940 0:d38d627c922f 59 /*******************************
perr1940 0:d38d627c922f 60 * END OF I/O Initialization
perr1940 0:d38d627c922f 61 *******************************/
perr1940 0:d38d627c922f 62
perr1940 0:d38d627c922f 63 /*******************************
perr1940 0:d38d627c922f 64 * GLOBAL VARS
perr1940 0:d38d627c922f 65 *******************************/
perr1940 0:d38d627c922f 66
perr1940 0:d38d627c922f 67 // Global Timers!
perr1940 0:d38d627c922f 68 extern Timer sysClk; // system clock (primarily for datalogging)
perr1940 0:d38d627c922f 69 extern Timer tState; // time in FSM state
perr1940 0:d38d627c922f 70 extern Timer t_HCl; // time when high current begins
perr1940 0:d38d627c922f 71 extern Timer t_HCr;
perr1940 0:d38d627c922f 72 extern Timer t_BetweenStepCommand;
perr1940 0:d38d627c922f 73
perr1940 0:d38d627c922f 74 const unsigned int enc_ticks=pow(2.,14.)-1; //the number of ticks that the encoder has, 2^14 for our encoder, -1 for 0 state
perr1940 0:d38d627c922f 75 const float enc2deg = 360./enc_ticks; // converts encoder reading from 0-16383 (14 bit) to 0-360deg (360 / 16383);
perr1940 0:d38d627c922f 76 const float control_lim_high=90; //soft stop on the controller
perr1940 0:d38d627c922f 77 const float control_lim_low=-55;//soft stop on the controller
perr1940 0:d38d627c922f 78 extern float TimeSinceLastStep;
perr1940 0:d38d627c922f 79
perr1940 0:d38d627c922f 80 //Control Variables
perr1940 0:d38d627c922f 81 // Control variables
perr1940 0:d38d627c922f 82 // Gain Scheduling!
perr1940 0:d38d627c922f 83 extern const float Kp_Swing;
perr1940 0:d38d627c922f 84 extern const float Kp_Stance;
perr1940 0:d38d627c922f 85 extern const float Kp_DoubleStance;//.01;
perr1940 0:d38d627c922f 86 extern const float Kp_Standing;//.01; //0.0025
perr1940 0:d38d627c922f 87 extern const float Kp_StandUp;
perr1940 0:d38d627c922f 88 extern const float Kp_SitDown ;
perr1940 0:d38d627c922f 89 extern const float Kp_Seated;
perr1940 0:d38d627c922f 90
perr1940 0:d38d627c922f 91 extern const float Kp;
perr1940 0:d38d627c922f 92 extern const float Kd;
perr1940 0:d38d627c922f 93 extern const float sat;
perr1940 0:d38d627c922f 94 extern const float Kp_mag;
perr1940 0:d38d627c922f 95 extern const float Kp_freq;
perr1940 0:d38d627c922f 96 extern const float Kp_offset;
perr1940 0:d38d627c922f 97
perr1940 0:d38d627c922f 98 #endif
perr1940 0:d38d627c922f 99
perr1940 0:d38d627c922f 100 extern void initializeExoIOs();