for noam

Dependencies:   mbed Map

Committer:
drorbalbul
Date:
Fri Dec 20 15:17:18 2019 +0000
Revision:
0:33b00fa05201
noam

Who changed what in which revision?

UserRevisionLine numberNew contents of line
drorbalbul 0:33b00fa05201 1 /* mbed simple H-bridge motor controller
drorbalbul 0:33b00fa05201 2 * Copyright (c) 2007-2010, sford, http://mbed.org
drorbalbul 0:33b00fa05201 3 *
drorbalbul 0:33b00fa05201 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
drorbalbul 0:33b00fa05201 5 * of this software and associated documentation files (the "Software"), to deal
drorbalbul 0:33b00fa05201 6 * in the Software without restriction, including without limitation the rights
drorbalbul 0:33b00fa05201 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
drorbalbul 0:33b00fa05201 8 * copies of the Software, and to permit persons to whom the Software is
drorbalbul 0:33b00fa05201 9 * furnished to do so, subject to the following conditions:
drorbalbul 0:33b00fa05201 10 *
drorbalbul 0:33b00fa05201 11 * The above copyright notice and this permission notice shall be included in
drorbalbul 0:33b00fa05201 12 * all copies or substantial portions of the Software.
drorbalbul 0:33b00fa05201 13 *
drorbalbul 0:33b00fa05201 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drorbalbul 0:33b00fa05201 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drorbalbul 0:33b00fa05201 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
drorbalbul 0:33b00fa05201 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
drorbalbul 0:33b00fa05201 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
drorbalbul 0:33b00fa05201 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
drorbalbul 0:33b00fa05201 20 * THE SOFTWARE.
drorbalbul 0:33b00fa05201 21 */
drorbalbul 0:33b00fa05201 22
drorbalbul 0:33b00fa05201 23 #ifndef MBED_MOTOR_H
drorbalbul 0:33b00fa05201 24 #define MBED_MOTOR_H
drorbalbul 0:33b00fa05201 25
drorbalbul 0:33b00fa05201 26 #include "mbed.h"
drorbalbul 0:33b00fa05201 27
drorbalbul 0:33b00fa05201 28 /** Interface to control a standard DC motor
drorbalbul 0:33b00fa05201 29 *
drorbalbul 0:33b00fa05201 30 * with an H-bridge using a PwmOut and 2 DigitalOuts
drorbalbul 0:33b00fa05201 31 */
drorbalbul 0:33b00fa05201 32 class Motor {
drorbalbul 0:33b00fa05201 33 public:
drorbalbul 0:33b00fa05201 34
drorbalbul 0:33b00fa05201 35 /** Create a motor control interface
drorbalbul 0:33b00fa05201 36 *
drorbalbul 0:33b00fa05201 37 * @param pwm A PwmOut pin, driving the H-bridge enable line to control the speed
drorbalbul 0:33b00fa05201 38 * @param fwd A DigitalOut, set high when the motor should go forward
drorbalbul 0:33b00fa05201 39 * @param rev A DigitalOut, set high when the motor should go backwards
drorbalbul 0:33b00fa05201 40 */
drorbalbul 0:33b00fa05201 41 Motor(PinName pwm, PinName fwd, PinName rev);
drorbalbul 0:33b00fa05201 42
drorbalbul 0:33b00fa05201 43 /** Set the speed of the motor
drorbalbul 0:33b00fa05201 44 *
drorbalbul 0:33b00fa05201 45 * @param speed The speed of the motor as a normalised value between -1.0 and 1.0
drorbalbul 0:33b00fa05201 46 */
drorbalbul 0:33b00fa05201 47 void speed(float speed);
drorbalbul 0:33b00fa05201 48
drorbalbul 0:33b00fa05201 49 protected:
drorbalbul 0:33b00fa05201 50 PwmOut _pwm;
drorbalbul 0:33b00fa05201 51 DigitalOut _fwd;
drorbalbul 0:33b00fa05201 52 DigitalOut _rev;
drorbalbul 0:33b00fa05201 53
drorbalbul 0:33b00fa05201 54 };
drorbalbul 0:33b00fa05201 55
drorbalbul 0:33b00fa05201 56 #endif