taurd for noam

Dependencies:   mbed Map

Committer:
drorbalbul
Date:
Fri Dec 20 16:29:33 2019 +0000
Revision:
2:fd1023193cc4
pidtaurd

Who changed what in which revision?

UserRevisionLine numberNew contents of line
drorbalbul 2:fd1023193cc4 1 /* mbed simple H-bridge motor controller
drorbalbul 2:fd1023193cc4 2 * Copyright (c) 2007-2010, sford, http://mbed.org
drorbalbul 2:fd1023193cc4 3 *
drorbalbul 2:fd1023193cc4 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
drorbalbul 2:fd1023193cc4 5 * of this software and associated documentation files (the "Software"), to deal
drorbalbul 2:fd1023193cc4 6 * in the Software without restriction, including without limitation the rights
drorbalbul 2:fd1023193cc4 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
drorbalbul 2:fd1023193cc4 8 * copies of the Software, and to permit persons to whom the Software is
drorbalbul 2:fd1023193cc4 9 * furnished to do so, subject to the following conditions:
drorbalbul 2:fd1023193cc4 10 *
drorbalbul 2:fd1023193cc4 11 * The above copyright notice and this permission notice shall be included in
drorbalbul 2:fd1023193cc4 12 * all copies or substantial portions of the Software.
drorbalbul 2:fd1023193cc4 13 *
drorbalbul 2:fd1023193cc4 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
drorbalbul 2:fd1023193cc4 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
drorbalbul 2:fd1023193cc4 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
drorbalbul 2:fd1023193cc4 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
drorbalbul 2:fd1023193cc4 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
drorbalbul 2:fd1023193cc4 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
drorbalbul 2:fd1023193cc4 20 * THE SOFTWARE.
drorbalbul 2:fd1023193cc4 21 */
drorbalbul 2:fd1023193cc4 22
drorbalbul 2:fd1023193cc4 23 #include "Motor.h"
drorbalbul 2:fd1023193cc4 24
drorbalbul 2:fd1023193cc4 25 #include "mbed.h"
drorbalbul 2:fd1023193cc4 26
drorbalbul 2:fd1023193cc4 27 Motor::Motor(PinName pwm, PinName fwd, PinName rev):
drorbalbul 2:fd1023193cc4 28 _pwm(pwm), _fwd(fwd), _rev(rev) {
drorbalbul 2:fd1023193cc4 29
drorbalbul 2:fd1023193cc4 30 // Set initial condition of PWM
drorbalbul 2:fd1023193cc4 31 _pwm.period(0.001);
drorbalbul 2:fd1023193cc4 32 _pwm = 0;
drorbalbul 2:fd1023193cc4 33
drorbalbul 2:fd1023193cc4 34 // Initial condition of output enables
drorbalbul 2:fd1023193cc4 35 _fwd = 0;
drorbalbul 2:fd1023193cc4 36 _rev = 0;
drorbalbul 2:fd1023193cc4 37 }
drorbalbul 2:fd1023193cc4 38
drorbalbul 2:fd1023193cc4 39 void Motor::speed(float speed) {
drorbalbul 2:fd1023193cc4 40 _fwd = (speed > 0.0);
drorbalbul 2:fd1023193cc4 41 _rev = (speed < 0.0);
drorbalbul 2:fd1023193cc4 42 _pwm = abs(speed);
drorbalbul 2:fd1023193cc4 43 }
drorbalbul 2:fd1023193cc4 44
drorbalbul 2:fd1023193cc4 45
drorbalbul 2:fd1023193cc4 46