The subsystem design/basis for the final project
Dependencies: mbed-rtos mbed-src pixylib
global.h@18:501f1007a572, 2016-04-07 (annotated)
- Committer:
- balsamfir
- Date:
- Thu Apr 07 13:19:29 2016 +0000
- Revision:
- 18:501f1007a572
- Parent:
- 17:47e107f9587b
- Child:
- 19:05b8123905fb
Added compatibility with new PS3 control app
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 | 18:501f1007a572 | 13 | #define SPEED_MAX 40 // 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 | 18:501f1007a572 | 26 | #define STEERING_KP 0.10 |
balsamfir | 14:2d609d465f00 | 27 | #define STEERING_KI 0 |
balsamfir | 5:f655435d0782 | 28 | |
balsamfir | 18:501f1007a572 | 29 | #define SPEED_KP 0.6 |
balsamfir | 14:2d609d465f00 | 30 | #define SPEED_KI 0 |
balsamfir | 6:52686c25e4af | 31 | |
balsamfir | 17:47e107f9587b | 32 | #define MOTOR_SAMPLES 300 |
balsamfir | 17:47e107f9587b | 33 | #define NAVIGATION_SAMPLES 240 |
balsamfir | 17:47e107f9587b | 34 | |
balsamfir | 5:f655435d0782 | 35 | |
balsamfir | 5:f655435d0782 | 36 | // Global variables |
balsamfir | 5:f655435d0782 | 37 | // ---------------------------------------------------------------- |
balsamfir | 2:2bc519e14bae | 38 | // IO Port |
balsamfir | 2:2bc519e14bae | 39 | extern DigitalOut led1; |
balsamfir | 2:2bc519e14bae | 40 | extern DigitalOut led2; |
balsamfir | 2:2bc519e14bae | 41 | extern DigitalOut led3; |
balsamfir | 2:2bc519e14bae | 42 | extern DigitalOut led4; |
balsamfir | 2:2bc519e14bae | 43 | extern DigitalOut leftDir; |
balsamfir | 2:2bc519e14bae | 44 | extern DigitalOut rightDir; |
balsamfir | 2:2bc519e14bae | 45 | extern DigitalOut spiReset; |
balsamfir | 2:2bc519e14bae | 46 | extern DigitalOut ioReset; |
balsamfir | 2:2bc519e14bae | 47 | |
balsamfir | 2:2bc519e14bae | 48 | // Comunication |
balsamfir | 2:2bc519e14bae | 49 | extern SPI deSpi; |
balsamfir | 3:dfb6733ae397 | 50 | extern Pixy pixy; |
balsamfir | 2:2bc519e14bae | 51 | extern Serial pc; // PC serial channel |
balsamfir | 2:2bc519e14bae | 52 | |
balsamfir | 5:f655435d0782 | 53 | // Control |
balsamfir | 6:52686c25e4af | 54 | extern PeriodicPI leftMotorPI; |
balsamfir | 6:52686c25e4af | 55 | extern PeriodicPI rightMotorPI; |
balsamfir | 6:52686c25e4af | 56 | extern PeriodicPI heightPI; |
balsamfir | 6:52686c25e4af | 57 | extern PeriodicPI xPI; |
balsamfir | 5:f655435d0782 | 58 | |
balsamfir | 3:dfb6733ae397 | 59 | // Other |
balsamfir | 3:dfb6733ae397 | 60 | extern PwmOut leftPwm; |
balsamfir | 3:dfb6733ae397 | 61 | extern PwmOut rightPwm; |
balsamfir | 3:dfb6733ae397 | 62 | extern InterruptIn bumper; // External interrupt pin declared as Bumper |
balsamfir | 3:dfb6733ae397 | 63 | |
balsamfir | 2:2bc519e14bae | 64 | // Method prototypes |
balsamfir | 15:caa5a93a31d7 | 65 | char flushBuffer(void); |
balsamfir | 3:dfb6733ae397 | 66 | float QE2RadsPerSec(short counts, short time); |