Team Design project 3 main file

Dependencies:   mbed Motor_Driver Sensors MMA8451Q LocalPositionSystem

Fork of TDP_main by Ivelin Kozarev

Committer:
Bartas
Date:
Wed Mar 25 10:45:08 2015 +0000
Revision:
38:02ef89edd828
Parent:
35:1819c5a8254a
asd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
orsharp 12:bb21b76b6375 1 /*
orsharp 12:bb21b76b6375 2 Header file for Shooting mechanism.
orsharp 12:bb21b76b6375 3
orsharp 12:bb21b76b6375 4 Takes dutyCycle as a float and converts it t oduty cycle.
orsharp 12:bb21b76b6375 5 When off- dutyCycle is just switched to 0 duty cycle.
orsharp 12:bb21b76b6375 6
orsharp 12:bb21b76b6375 7 IMPORTANT: need to convert back to dutycycle=0, when not used!!
orsharp 12:bb21b76b6375 8
orsharp 12:bb21b76b6375 9 Possible improvements:
orsharp 12:bb21b76b6375 10 -Convert program so when it's off the pins are completely off???
orsharp 12:bb21b76b6375 11 -Caclutalate better time for the waits???
orsharp 12:bb21b76b6375 12 -maybe change the period??
orsharp 12:bb21b76b6375 13
orsharp 12:bb21b76b6375 14 TESTED AND WORKING - 06/03
orsharp 12:bb21b76b6375 15 IK
orsharp 12:bb21b76b6375 16 */
orsharp 12:bb21b76b6375 17
orsharp 12:bb21b76b6375 18 #ifndef _SHOOTER_H
orsharp 12:bb21b76b6375 19 #define _SHOOTER_H
orsharp 12:bb21b76b6375 20
Reckstyle 35:1819c5a8254a 21 PwmOut squareOut(PTE31); //TESTED WORKING
Reckstyle 35:1819c5a8254a 22 DigitalOut solenoid(PTA17);
orsharp 12:bb21b76b6375 23
orsharp 12:bb21b76b6375 24 void shoot(float dutyCycle) {
orsharp 12:bb21b76b6375 25
orsharp 12:bb21b76b6375 26 squareOut.period(0.01f); // 0.01 second period
orsharp 12:bb21b76b6375 27 squareOut.write(dutyCycle); // 50% duty cycle
orsharp 12:bb21b76b6375 28 wait(1.7); // give time for motors to reach optimal speed - is it needed
orsharp 12:bb21b76b6375 29
orsharp 12:bb21b76b6375 30 if (dutyCycle == 0.0) //if not used any more, don't shoot
orsharp 12:bb21b76b6375 31 return;
orsharp 12:bb21b76b6375 32
orsharp 12:bb21b76b6375 33 solenoid = 1; //push solenoid
orsharp 12:bb21b76b6375 34 wait (0.3); // wait needed
orsharp 12:bb21b76b6375 35 solenoid = 0; //pull it back
orsharp 12:bb21b76b6375 36
orsharp 12:bb21b76b6375 37 return;
orsharp 12:bb21b76b6375 38 }
orsharp 12:bb21b76b6375 39
orsharp 12:bb21b76b6375 40 #endif