Mine, not yours justin

Dependencies:   HMC6352 USBHost mbed-rtos mbed

Fork of Project by Justin Eng

Committer:
ganeshsubram1
Date:
Fri Apr 25 23:08:01 2014 +0000
Revision:
4:b2a30c313297
Parent:
3:6a7620e9abd9
First Publish. Working 90 degree turning calibration and execution, just need a good power supply to fully test.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Strikewolf 0:b6fd1c37944a 1 #include "mbed.h"
Strikewolf 0:b6fd1c37944a 2 #include "RobotControl.h"
Strikewolf 2:56eb726bdb0d 3 #include "rtos.h"
ganeshsubram1 3:6a7620e9abd9 4
Strikewolf 2:56eb726bdb0d 5 #define ENTERCALIB 0x43
Strikewolf 2:56eb726bdb0d 6 #define EXITCALIB 0x45
Strikewolf 2:56eb726bdb0d 7
ganeshsubram1 3:6a7620e9abd9 8 DigitalOut led3(LED3);
ganeshsubram1 3:6a7620e9abd9 9 DigitalOut led4(LED4);
ganeshsubram1 3:6a7620e9abd9 10 DigitalOut rst1(p12);
ganeshsubram1 3:6a7620e9abd9 11
ganeshsubram1 3:6a7620e9abd9 12 Serial xbee1(p13, p14);
ganeshsubram1 3:6a7620e9abd9 13
Strikewolf 2:56eb726bdb0d 14 InterruptIn sw(p30);
ganeshsubram1 3:6a7620e9abd9 15
Strikewolf 2:56eb726bdb0d 16 void StopISR()
Strikewolf 2:56eb726bdb0d 17 {
Strikewolf 2:56eb726bdb0d 18 rightMotorPWM = 0;
Strikewolf 2:56eb726bdb0d 19 leftMotorPWM = 0;
Strikewolf 2:56eb726bdb0d 20 exit(1);
Strikewolf 2:56eb726bdb0d 21 }
ganeshsubram1 3:6a7620e9abd9 22
ganeshsubram1 3:6a7620e9abd9 23 int main() {
Strikewolf 2:56eb726bdb0d 24
Strikewolf 2:56eb726bdb0d 25 //Emergency stop mechanism
Strikewolf 2:56eb726bdb0d 26 sw.rise(&StopISR);
Strikewolf 2:56eb726bdb0d 27
ganeshsubram1 3:6a7620e9abd9 28 // start positioning system
ganeshsubram1 3:6a7620e9abd9 29 Thread position(PositionSystemMain, NULL, osPriorityNormal, 256 * 4);
ganeshsubram1 3:6a7620e9abd9 30 wait(3); // wait for the mouse sensor to boot up
ganeshsubram1 3:6a7620e9abd9 31
ganeshsubram1 3:6a7620e9abd9 32 // calibrate 90 degree turns
ganeshsubram1 3:6a7620e9abd9 33 turnCalibrate();
Strikewolf 0:b6fd1c37944a 34
ganeshsubram1 3:6a7620e9abd9 35 // PTURN_RIGHT is the measured x value for a 90 degree turn
ganeshsubram1 3:6a7620e9abd9 36 pc.printf("PTURN_RIGHT: %f\n\r", PTURN_RIGHT);
ganeshsubram1 3:6a7620e9abd9 37 wait(1);
ganeshsubram1 3:6a7620e9abd9 38
ganeshsubram1 3:6a7620e9abd9 39 // try a 90 degree turn with the measured PTURN_RIGHT value
ganeshsubram1 3:6a7620e9abd9 40 turnRight(90);
ganeshsubram1 3:6a7620e9abd9 41 }