Control a robot over the internet using UDP and a Ethernet interface.

Dependencies:   EthernetInterface Motor TextLCD mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Committer:
apatel336
Date:
Thu Oct 17 13:26:38 2013 +0000
Revision:
0:1496281373a5
Initial Release

Who changed what in which revision?

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