ediff iitb / Mbed 2 deprecated HIL_FMEA_oursteering

Dependencies:   mbed

Committer:
ediff_iitbracing
Date:
Wed Mar 06 19:20:02 2013 +0000
Revision:
2:eb4101b574bc
Parent:
1:fec1d091fa34
Test publish

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ediff_iitbracing 0:30ff725706d2 1 #ifndef DEFINEVARIABLES_H
ediff_iitbracing 0:30ff725706d2 2 #define DEFINEVARIABLES_H
ediff_iitbracing 0:30ff725706d2 3
ediff_iitbracing 0:30ff725706d2 4 #include "mbed.h"
ediff_iitbracing 0:30ff725706d2 5 #include "steering.h"
ediff_iitbracing 0:30ff725706d2 6 #define wheel_Left_pin p25
ediff_iitbracing 0:30ff725706d2 7 #define wheel_Right_pin p23
ediff_iitbracing 0:30ff725706d2 8
ediff_iitbracing 0:30ff725706d2 9 #define throttle_Left_pwm_pin p22
ediff_iitbracing 0:30ff725706d2 10 #define throttle_Right_pwm_pin p21
ediff_iitbracing 0:30ff725706d2 11
ediff_iitbracing 0:30ff725706d2 12 #define algoperiod 100000 //entire algo (pid + steering
ediff_iitbracing 0:30ff725706d2 13 #define fmeatime
ediff_iitbracing 0:30ff725706d2 14
ediff_iitbracing 0:30ff725706d2 15 //car parameters
ediff_iitbracing 0:30ff725706d2 16 extern const float trackwidth;
ediff_iitbracing 0:30ff725706d2 17 extern const float wheelradius;
ediff_iitbracing 0:30ff725706d2 18 extern const float rear_wheelbase;
ediff_iitbracing 0:30ff725706d2 19
ediff_iitbracing 0:30ff725706d2 20 //constant parameters
ediff_iitbracing 0:30ff725706d2 21 extern const float full_throttle;
ediff_iitbracing 0:30ff725706d2 22 extern const float dead_steering;
ediff_iitbracing 0:30ff725706d2 23 extern const float dead_rpm;
ediff_iitbracing 0:30ff725706d2 24 extern const float integral_saturation;
ediff_iitbracing 0:30ff725706d2 25
ediff_iitbracing 0:30ff725706d2 26 //steering and throttle inputs
ediff_iitbracing 0:30ff725706d2 27 extern float steering; //input steering angle
ediff_iitbracing 0:30ff725706d2 28 extern float throttle; //throttle input from pedal
ediff_iitbracing 0:30ff725706d2 29
ediff_iitbracing 0:30ff725706d2 30 //delta_Left, delta_Right, turnradius and wratio_desired calculated realtime from delta (delta_Left and delta_Right are Left and Right tyre angles)
ediff_iitbracing 0:30ff725706d2 31 extern float delta_Left; //Left wheel Steer angle
ediff_iitbracing 0:30ff725706d2 32 extern float delta_Right; //Right wheel Steer angle
ediff_iitbracing 0:30ff725706d2 33 extern float turnradius;
ediff_iitbracing 0:30ff725706d2 34 extern float wratio_desired; //Right/Left
ediff_iitbracing 0:30ff725706d2 35
ediff_iitbracing 0:30ff725706d2 36 // output values
ediff_iitbracing 0:30ff725706d2 37 // assumed range of output 0-5V
ediff_iitbracing 0:30ff725706d2 38 extern float throttle_Left, throttle_Right, throttle_Left_pulsewidth, throttle_Right_pulsewidth;
ediff_iitbracing 0:30ff725706d2 39
ediff_iitbracing 0:30ff725706d2 40 extern Ticker check;
ediff_iitbracing 0:30ff725706d2 41 //Serial pc(USBTX, USBRX);
ediff_iitbracing 0:30ff725706d2 42
ediff_iitbracing 0:30ff725706d2 43 //rpm counts
ediff_iitbracing 0:30ff725706d2 44 extern volatile int cnt_Left, cnt_Right;
ediff_iitbracing 0:30ff725706d2 45
ediff_iitbracing 0:30ff725706d2 46 //RPM feedback pins
ediff_iitbracing 0:30ff725706d2 47 extern AnalogIn steeringread;
ediff_iitbracing 0:30ff725706d2 48 extern AnalogIn throttleread;
ediff_iitbracing 0:30ff725706d2 49
ediff_iitbracing 0:30ff725706d2 50 //Left and Right rear RPMs feedback-input
ediff_iitbracing 0:30ff725706d2 51 extern float rpm_Left;
ediff_iitbracing 0:30ff725706d2 52 extern float rpm_Right;
ediff_iitbracing 0:30ff725706d2 53
ediff_iitbracing 2:eb4101b574bc 54 //Openloop Flag
ediff_iitbracing 2:eb4101b574bc 55 extern volatile bool openloop;
ediff_iitbracing 2:eb4101b574bc 56 extern const float rpm_openloop_limit;
ediff_iitbracing 2:eb4101b574bc 57
ediff_iitbracing 0:30ff725706d2 58 //PID constants
ediff_iitbracing 0:30ff725706d2 59 extern float kp;
ediff_iitbracing 0:30ff725706d2 60 extern float kd;
ediff_iitbracing 0:30ff725706d2 61 extern float ki;
ediff_iitbracing 1:fec1d091fa34 62 extern float c;
ediff_iitbracing 0:30ff725706d2 63
ediff_iitbracing 0:30ff725706d2 64 //For PID
ediff_iitbracing 0:30ff725706d2 65 extern const float timeint;
ediff_iitbracing 0:30ff725706d2 66 extern float integral;
ediff_iitbracing 0:30ff725706d2 67 extern float derivative;
ediff_iitbracing 0:30ff725706d2 68 extern float error_prev; //error at t0
ediff_iitbracing 0:30ff725706d2 69 extern float error_new; //error at t
ediff_iitbracing 0:30ff725706d2 70 extern float wratio_actual;
ediff_iitbracing 0:30ff725706d2 71 extern float w_ratio; //ratio of controller voltages - Right/Left
ediff_iitbracing 0:30ff725706d2 72
ediff_iitbracing 0:30ff725706d2 73 //virtual sensors
ediff_iitbracing 0:30ff725706d2 74 extern float steering2, throttle2, yaw_rate;
ediff_iitbracing 0:30ff725706d2 75 extern float yaw_rate_desired;
ediff_iitbracing 0:30ff725706d2 76
ediff_iitbracing 0:30ff725706d2 77 //fmea output
ediff_iitbracing 0:30ff725706d2 78 extern bool shutdown;
ediff_iitbracing 0:30ff725706d2 79 extern bool Dash;
ediff_iitbracing 0:30ff725706d2 80
ediff_iitbracing 0:30ff725706d2 81 #endif