The subsystem design/basis for the final project
Dependencies: mbed-rtos mbed-src pixylib
global.cpp@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 "global.h" |
balsamfir | 2:2bc519e14bae | 2 | |
balsamfir | 2:2bc519e14bae | 3 | // IO Port |
balsamfir | 2:2bc519e14bae | 4 | DigitalOut led1(LED1); |
balsamfir | 2:2bc519e14bae | 5 | DigitalOut led2(LED2); |
balsamfir | 2:2bc519e14bae | 6 | DigitalOut led3(LED3); |
balsamfir | 2:2bc519e14bae | 7 | DigitalOut led4(LED4); |
balsamfir | 6:52686c25e4af | 8 | DigitalOut leftDir(p24); // |
balsamfir | 6:52686c25e4af | 9 | DigitalOut rightDir(p22); // |
balsamfir | 6:52686c25e4af | 10 | DigitalOut spiReset(p8); //changed |
balsamfir | 6:52686c25e4af | 11 | DigitalOut ioReset(p14); // |
balsamfir | 2:2bc519e14bae | 12 | |
balsamfir | 2:2bc519e14bae | 13 | // Comunication |
balsamfir | 2:2bc519e14bae | 14 | SPI deSpi(p5, p6, p7); |
balsamfir | 3:dfb6733ae397 | 15 | Pixy pixy(Pixy::SPI, p11, p12, p13); |
balsamfir | 16:73db7ef2deb6 | 16 | Serial pc(USBTX, USBRX); // PC serial channel |
balsamfir | 16:73db7ef2deb6 | 17 | Serial bt(p28, p27); // Bluetooth serial channel |
balsamfir | 2:2bc519e14bae | 18 | |
balsamfir | 5:f655435d0782 | 19 | // Control |
balsamfir | 6:52686c25e4af | 20 | PeriodicPI leftMotorPI(MOTOR_PERIOD, MOTOR_KP, MOTOR_KI); |
balsamfir | 6:52686c25e4af | 21 | PeriodicPI rightMotorPI(MOTOR_PERIOD, MOTOR_KP, MOTOR_KI); |
balsamfir | 6:52686c25e4af | 22 | PeriodicPI heightPI(NAVIGATION_PERIOD, SPEED_KP, SPEED_KI); |
balsamfir | 6:52686c25e4af | 23 | PeriodicPI xPI(NAVIGATION_PERIOD, STEERING_KP, STEERING_KI); |
balsamfir | 5:f655435d0782 | 24 | |
balsamfir | 3:dfb6733ae397 | 25 | // Other |
balsamfir | 6:52686c25e4af | 26 | PwmOut leftPwm(p23); // |
balsamfir | 6:52686c25e4af | 27 | PwmOut rightPwm(p21); // |
balsamfir | 6:52686c25e4af | 28 | InterruptIn bumper(p25); |
balsamfir | 3:dfb6733ae397 | 29 | |
balsamfir | 2:2bc519e14bae | 30 | // Converts measurements from the QE2 to rads/sec |
balsamfir | 7:5ef312aa2678 | 31 | float QE2RadsPerSec(short counts, short time) { |
balsamfir | 7:5ef312aa2678 | 32 | return ((float)counts*122.62)/time; |
balsamfir | 15:caa5a93a31d7 | 33 | } |
balsamfir | 15:caa5a93a31d7 | 34 | |
balsamfir | 15:caa5a93a31d7 | 35 | // Returns the last character |
balsamfir | 15:caa5a93a31d7 | 36 | char flushBuffer(void) { |
balsamfir | 15:caa5a93a31d7 | 37 | char ch; |
balsamfir | 16:73db7ef2deb6 | 38 | while (bt.readable()) pc.putc(bt.getc()); |
balsamfir | 15:caa5a93a31d7 | 39 | return ch; |
balsamfir | 2:2bc519e14bae | 40 | } |