The subsystem design/basis for the final project

Dependencies:   mbed-rtos mbed-src pixylib

Committer:
balsamfir
Date:
Mon Apr 24 21:37:50 2017 +0000
Revision:
19:05b8123905fb
Parent:
18:501f1007a572
Commit before share

Who changed what in which revision?

UserRevisionLine numberNew contents of line
balsamfir 2:2bc519e14bae 1 #include "mbed.h"
balsamfir 2:2bc519e14bae 2 #include "rtos.h"
balsamfir 3:dfb6733ae397 3 #include "Pixy.h"
balsamfir 6:52686c25e4af 4 #include "PeriodicPI.h"
balsamfir 2:2bc519e14bae 5
balsamfir 2:2bc519e14bae 6 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 7 // Contains common defintions share between modes
balsamfir 2:2bc519e14bae 8 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 9
balsamfir 15:caa5a93a31d7 10
balsamfir 5:f655435d0782 11 // Preprocessor Definitions
balsamfir 5:f655435d0782 12 // ----------------------------------------------------------------
balsamfir 19:05b8123905fb 13 #define SPEED_MAX 2 // rads/s
balsamfir 5:f655435d0782 14 #define MAX_BLOCKS 1
balsamfir 15:caa5a93a31d7 15 #define X_SETPOINT 160
balsamfir 19:05b8123905fb 16 #define HEIGHT_SETPOINT 120
balsamfir 19:05b8123905fb 17 #define TARGET_DECIMAL 1
balsamfir 19:05b8123905fb 18
balsamfir 19:05b8123905fb 19 // #define DEBUG 1
balsamfir 6:52686c25e4af 20
balsamfir 5:f655435d0782 21 #define PWM_PERIOD 0.001
balsamfir 19:05b8123905fb 22 #define MOTOR_PERIOD 0.01
balsamfir 5:f655435d0782 23 #define NAVIGATION_PERIOD 0.0167 // 60 times/sec
balsamfir 5:f655435d0782 24
balsamfir 19:05b8123905fb 25 #define MOTOR_KP 0.0001 // 0.0001
balsamfir 19:05b8123905fb 26 #define MOTOR_KI 0.0005 // 0.0001 //0.00001 //0.0000001
balsamfir 5:f655435d0782 27
balsamfir 18:501f1007a572 28 #define STEERING_KP 0.10
balsamfir 14:2d609d465f00 29 #define STEERING_KI 0
balsamfir 5:f655435d0782 30
balsamfir 19:05b8123905fb 31 #define SPEED_KP 0.1
balsamfir 14:2d609d465f00 32 #define SPEED_KI 0
balsamfir 6:52686c25e4af 33
balsamfir 17:47e107f9587b 34 #define MOTOR_SAMPLES 300
balsamfir 19:05b8123905fb 35 #define NAVIGATION_SAMPLES 200
balsamfir 17:47e107f9587b 36
balsamfir 5:f655435d0782 37
balsamfir 5:f655435d0782 38 // Global variables
balsamfir 5:f655435d0782 39 // ----------------------------------------------------------------
balsamfir 2:2bc519e14bae 40 // IO Port
balsamfir 2:2bc519e14bae 41 extern DigitalOut led1;
balsamfir 2:2bc519e14bae 42 extern DigitalOut led2;
balsamfir 2:2bc519e14bae 43 extern DigitalOut led3;
balsamfir 2:2bc519e14bae 44 extern DigitalOut led4;
balsamfir 2:2bc519e14bae 45 extern DigitalOut leftDir;
balsamfir 2:2bc519e14bae 46 extern DigitalOut rightDir;
balsamfir 2:2bc519e14bae 47 extern DigitalOut spiReset;
balsamfir 2:2bc519e14bae 48 extern DigitalOut ioReset;
balsamfir 2:2bc519e14bae 49
balsamfir 2:2bc519e14bae 50 // Comunication
balsamfir 2:2bc519e14bae 51 extern SPI deSpi;
balsamfir 3:dfb6733ae397 52 extern Pixy pixy;
balsamfir 2:2bc519e14bae 53 extern Serial pc; // PC serial channel
balsamfir 2:2bc519e14bae 54
balsamfir 5:f655435d0782 55 // Control
balsamfir 6:52686c25e4af 56 extern PeriodicPI leftMotorPI;
balsamfir 6:52686c25e4af 57 extern PeriodicPI rightMotorPI;
balsamfir 6:52686c25e4af 58 extern PeriodicPI heightPI;
balsamfir 6:52686c25e4af 59 extern PeriodicPI xPI;
balsamfir 5:f655435d0782 60
balsamfir 3:dfb6733ae397 61 // Other
balsamfir 3:dfb6733ae397 62 extern PwmOut leftPwm;
balsamfir 3:dfb6733ae397 63 extern PwmOut rightPwm;
balsamfir 3:dfb6733ae397 64
balsamfir 2:2bc519e14bae 65 // Method prototypes
balsamfir 19:05b8123905fb 66 void FlushBuffer(void);
balsamfir 19:05b8123905fb 67 float RadsPerSec(short counts, short time);