Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of CoilGun by
coilgun.h@4:0e2bdd3d52bc, 2013-09-14 (annotated)
- Committer:
- mlaane
- Date:
- Sat Sep 14 22:57:17 2013 +0000
- Revision:
- 4:0e2bdd3d52bc
- Parent:
- 3:7273ba733560
- Child:
- 6:4c75db8a43db
documentation
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Reiko | 0:2d5820be7f51 | 1 | #ifndef COILGUN_H |
| Reiko | 0:2d5820be7f51 | 2 | #define COILGUN_H |
| Reiko | 0:2d5820be7f51 | 3 | |
| Reiko | 0:2d5820be7f51 | 4 | #include "mbed.h" |
| mlaane | 4:0e2bdd3d52bc | 5 | |
| mlaane | 4:0e2bdd3d52bc | 6 | /** Interface to the CoilGun*/ |
| Reiko | 0:2d5820be7f51 | 7 | class CoilGun { |
| Reiko | 0:2d5820be7f51 | 8 | public: |
| mlaane | 4:0e2bdd3d52bc | 9 | /** Create an instance of the CoilGun connected to specfied pins. |
| mlaane | 4:0e2bdd3d52bc | 10 | * |
| mlaane | 4:0e2bdd3d52bc | 11 | * @param chargePinName The charge pin. |
| mlaane | 4:0e2bdd3d52bc | 12 | * @param kickPinName The kick pin. |
| mlaane | 4:0e2bdd3d52bc | 13 | * @param donePinName The done pin. |
| mlaane | 4:0e2bdd3d52bc | 14 | */ |
| mlaane | 4:0e2bdd3d52bc | 15 | CoilGun(PinName chargePinName, PinName kickPinName, PinName donePinName); |
| Reiko | 0:2d5820be7f51 | 16 | |
| mlaane | 4:0e2bdd3d52bc | 17 | /** Kick with coilgun. |
| mlaane | 4:0e2bdd3d52bc | 18 | * |
| mlaane | 4:0e2bdd3d52bc | 19 | * @param length The length of the kick in uS |
| mlaane | 4:0e2bdd3d52bc | 20 | */ |
| Reiko | 2:781ea1999ad3 | 21 | void kick(unsigned int length); |
| mlaane | 4:0e2bdd3d52bc | 22 | |
| mlaane | 4:0e2bdd3d52bc | 23 | /** Discharge coilgun */ |
| mlaane | 4:0e2bdd3d52bc | 24 | void discharge(void); |
| mlaane | 4:0e2bdd3d52bc | 25 | |
| mlaane | 4:0e2bdd3d52bc | 26 | /** turn charging on or off |
| mlaane | 4:0e2bdd3d52bc | 27 | * |
| mlaane | 4:0e2bdd3d52bc | 28 | * @param chargeState Set true to charge. False, to not charge. |
| mlaane | 4:0e2bdd3d52bc | 29 | */ |
| Reiko | 0:2d5820be7f51 | 30 | void setCharge(bool chargeState); |
| Reiko | 0:2d5820be7f51 | 31 | |
| Reiko | 0:2d5820be7f51 | 32 | private: |
| Reiko | 1:aa39e3a9d06f | 33 | DigitalOut chargePin; |
| Reiko | 1:aa39e3a9d06f | 34 | DigitalOut kickPin; |
| mlaane | 4:0e2bdd3d52bc | 35 | InterruptIn donePin; |
| Reiko | 1:aa39e3a9d06f | 36 | void doneCallback(void); |
| mlaane | 3:7273ba733560 | 37 | |
| mlaane | 3:7273ba733560 | 38 | bool kicking; //True while kick is in progress |
| mlaane | 3:7273ba733560 | 39 | Timeout kickTimeout; // This will end kicking |
| Reiko | 2:781ea1999ad3 | 40 | void kickEnd(void); |
| mlaane | 3:7273ba733560 | 41 | |
| mlaane | 3:7273ba733560 | 42 | bool discharging; //True as long discharging is in progress |
| mlaane | 3:7273ba733560 | 43 | Timeout dischargeTimeout; // This will end discharging |
| mlaane | 3:7273ba733560 | 44 | Ticker discharger; // Calls short kicks during discharge |
| mlaane | 3:7273ba733560 | 45 | void dischargeKick(void); //Short kick for discharging |
| mlaane | 3:7273ba733560 | 46 | void dischargeEnd(void); //Method that ends discharging (dischargeTimeout calls this) |
| Reiko | 0:2d5820be7f51 | 47 | }; |
| Reiko | 0:2d5820be7f51 | 48 | |
| Reiko | 0:2d5820be7f51 | 49 | #endif |
