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.
coilgun.h
00001 #ifndef COILGUN_H 00002 #define COILGUN_H 00003 00004 #include "mbed.h" 00005 00006 /** Class for controlling coilgun */ 00007 class Coilgun { 00008 public: 00009 /** Create an instance of the Coilgun connected to specfied pins */ 00010 Coilgun(PinName kickPinName ,PinName chargePinName, PinName donePinName); 00011 00012 /** Kick with coilgun */ 00013 void kick(unsigned int length); 00014 /** Stop kick */ 00015 void kickEnd(void); 00016 00017 /** Charge capacitor */ 00018 void charge(void); 00019 /** Stop charging capacitor */ 00020 void chargeEnd(void); 00021 00022 /** Discharge capacitor */ 00023 void discharge(void); 00024 /** Stop discharging */ 00025 void dischargeEnd(void); 00026 00027 /** Read only 00028 * Will be set to true, when charge() is called, 00029 * false, when discharge is called. 00030 * NB! if discharge is interrupted, capacitor may still have some charge on it. 00031 */ 00032 bool isCharged; 00033 00034 private: 00035 enum State {idle, kicking, charging, discharging}; 00036 State state; 00037 00038 DigitalOut kickPin; 00039 DigitalOut chargePin; 00040 InterruptIn donePin; 00041 00042 Timeout kickTimeout; // This will end kicking 00043 Timeout dischargeTimeout; // This will end discharging 00044 Ticker discharger; // Calls short kicks during discharge 00045 00046 void changeState(State new_state); 00047 void dischargeKick(void); 00048 void kick(unsigned int length, bool change_state); 00049 }; 00050 00051 #endif
Generated on Thu Jul 21 2022 02:05:47 by
1.7.2