The subsystem design/basis for the final project
Dependencies: mbed-rtos mbed-src pixylib
global.h@16:73db7ef2deb6, 2016-03-28 (annotated)
- Committer:
- balsamfir
- Date:
- Mon Mar 28 21:39:06 2016 +0000
- Revision:
- 16:73db7ef2deb6
- Parent:
- 15:caa5a93a31d7
- Child:
- 17:47e107f9587b
First working ps3 manual control
Who changed what in which revision?
User | Revision | Line number | New 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 | 16:73db7ef2deb6 | 13 | #define SPEED_MAX 30 // rads/s |
balsamfir | 5:f655435d0782 | 14 | #define MAX_BLOCKS 1 |
balsamfir | 15:caa5a93a31d7 | 15 | #define X_SETPOINT 160 |
balsamfir | 15:caa5a93a31d7 | 16 | #define HEIGHT_SETPOINT 90 |
balsamfir | 15:caa5a93a31d7 | 17 | #define TARGET_DECIMAL 10 |
balsamfir | 6:52686c25e4af | 18 | |
balsamfir | 5:f655435d0782 | 19 | #define PWM_PERIOD 0.001 |
balsamfir | 5:f655435d0782 | 20 | #define MOTOR_PERIOD 0.001 |
balsamfir | 5:f655435d0782 | 21 | #define NAVIGATION_PERIOD 0.0167 // 60 times/sec |
balsamfir | 5:f655435d0782 | 22 | |
balsamfir | 5:f655435d0782 | 23 | #define MOTOR_KP 0.000120 |
balsamfir | 6:52686c25e4af | 24 | #define MOTOR_KI 0.0000001 |
balsamfir | 5:f655435d0782 | 25 | |
balsamfir | 14:2d609d465f00 | 26 | #define STEERING_KP 0.06 |
balsamfir | 14:2d609d465f00 | 27 | #define STEERING_KI 0 |
balsamfir | 5:f655435d0782 | 28 | |
balsamfir | 14:2d609d465f00 | 29 | #define SPEED_KP 0.4 |
balsamfir | 14:2d609d465f00 | 30 | #define SPEED_KI 0 |
balsamfir | 6:52686c25e4af | 31 | |
balsamfir | 5:f655435d0782 | 32 | |
balsamfir | 5:f655435d0782 | 33 | // Global variables |
balsamfir | 5:f655435d0782 | 34 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 35 | // IO Port |
balsamfir | 2:2bc519e14bae | 36 | extern DigitalOut led1; |
balsamfir | 2:2bc519e14bae | 37 | extern DigitalOut led2; |
balsamfir | 2:2bc519e14bae | 38 | extern DigitalOut led3; |
balsamfir | 2:2bc519e14bae | 39 | extern DigitalOut led4; |
balsamfir | 2:2bc519e14bae | 40 | extern DigitalOut leftDir; |
balsamfir | 2:2bc519e14bae | 41 | extern DigitalOut rightDir; |
balsamfir | 2:2bc519e14bae | 42 | extern DigitalOut spiReset; |
balsamfir | 2:2bc519e14bae | 43 | extern DigitalOut ioReset; |
balsamfir | 2:2bc519e14bae | 44 | |
balsamfir | 2:2bc519e14bae | 45 | // Comunication |
balsamfir | 2:2bc519e14bae | 46 | extern SPI deSpi; |
balsamfir | 3:dfb6733ae397 | 47 | extern Pixy pixy; |
balsamfir | 2:2bc519e14bae | 48 | extern Serial pc; // PC serial channel |
balsamfir | 2:2bc519e14bae | 49 | extern Serial bt; // Bluetooth serial channel |
balsamfir | 2:2bc519e14bae | 50 | |
balsamfir | 5:f655435d0782 | 51 | // Control |
balsamfir | 6:52686c25e4af | 52 | extern PeriodicPI leftMotorPI; |
balsamfir | 6:52686c25e4af | 53 | extern PeriodicPI rightMotorPI; |
balsamfir | 6:52686c25e4af | 54 | extern PeriodicPI heightPI; |
balsamfir | 6:52686c25e4af | 55 | extern PeriodicPI xPI; |
balsamfir | 5:f655435d0782 | 56 | |
balsamfir | 3:dfb6733ae397 | 57 | // Other |
balsamfir | 3:dfb6733ae397 | 58 | extern PwmOut leftPwm; |
balsamfir | 3:dfb6733ae397 | 59 | extern PwmOut rightPwm; |
balsamfir | 3:dfb6733ae397 | 60 | extern InterruptIn bumper; // External interrupt pin declared as Bumper |
balsamfir | 3:dfb6733ae397 | 61 | |
balsamfir | 2:2bc519e14bae | 62 | // Method prototypes |
balsamfir | 15:caa5a93a31d7 | 63 | char flushBuffer(void); |
balsamfir | 3:dfb6733ae397 | 64 | float QE2RadsPerSec(short counts, short time); |