Lol smth

Dependencies:   LocalPositionSystem MMA8451Q Motor_Driver Sensors mbed

Fork of TDP_main_BartFork by Yelfie

Committer:
Reckstyle
Date:
Wed Mar 11 14:00:37 2015 +0000
Revision:
14:3844d1dacece
Parent:
12:bb21b76b6375
11/03

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 14:3844d1dacece 21 PwmOut squareOut(PTD0); //TESTED WORKING
Reckstyle 14:3844d1dacece 22 DigitalOut solenoid(PTC16);
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