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
MotorControl.cpp
- Committer:
- baxterja
- Date:
- 2015-11-06
- Revision:
- 5:1b2dc43e8947
- Parent:
- 2:3771b3195c7b
File content as of revision 5:1b2dc43e8947:
#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(); }