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.
Dependencies: mbed
Fork of Chemical_Sensor_DMA by
Diff: MotorControl.cpp
- Revision:
- 6:63de50ac29be
- Parent:
- 5:1b2dc43e8947
- Child:
- 7:af255a90505e
--- a/MotorControl.cpp Fri Nov 06 19:28:49 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -#include "MotorControl.h" -#include "mbed.h" - -// constructor -MotorControl::MotorControl(PinName cw, PinName ccw, int period, int safetyPeriod) : - _cw(cw), - _ccw(ccw) { - - // turn motor off - _cw = 0; - _ccw = 0; - - _cw.period_us(period); - _ccw.period_us(period); - - _period = period; - _safetyPeriod = safetyPeriod; -} - -void MotorControl::off() { - _cw = 0; - _ccw = 0; - pause_us(_safetyPeriod); -} - -void MotorControl::clockwise(float dutyCycle) { - _cw = dutyCycle; -} - -void MotorControl::releaseMallet() { - // make sure motor is off - off(); - - // pulse clockwise to release mallet - _cw = 1; - pause_ms(10); - _cw = 0; - pause_ms(75); - - // pulse counter-clockwise to stop snail cam - _ccw = 0.7; - pause_ms(8); - _ccw = 0; - - // make sure motor is off - off(); -} - -void MotorControl::reset() { - -} - -void MotorControl::hardReset(int duration) { - // make sure motor is off - off(); - - // long pulse clockwise to reset mallet - _cw = 1; - pause_ms(200); - _cw = 0; - - // short pulse counter-clockwise to stop snail cam - _ccw = 1; - pause_ms(10); - _ccw = 0; - - - wait_ms(duration); - // short pulse counter-clockwise to set snail cam in groove on mallet - _ccw = 1; - pause_ms(3); - _ccw = 0; - - // make sure motor is off - off(); -} \ No newline at end of file