The subsystem design/basis for the final project

Dependencies:   mbed-rtos mbed-src pixylib

Committer:
balsamfir
Date:
Fri Mar 25 21:20:10 2016 +0000
Revision:
9:62fbb69b612c
Parent:
7:5ef312aa2678
Child:
15:caa5a93a31d7
commit before revert

Who changed what in which revision?

UserRevisionLine numberNew 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 9:62fbb69b612c 16 //Serial pc(USBTX, USBRX); // PC serial channel
balsamfir 9:62fbb69b612c 17 Serial pc(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 2:2bc519e14bae 33 }