A motor control class for driving two DC motors as part of RenBuggy
MotorController.h@0:4aa0a6b134ea, 2014-01-15 (annotated)
- Committer:
- jf1452
- Date:
- Wed Jan 15 11:48:41 2014 +0000
- Revision:
- 0:4aa0a6b134ea
- Child:
- 1:548ee2d0bb89
- Child:
- 2:2e59abd4b6b9
Simplified class for DC motor drive using PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jf1452 | 0:4aa0a6b134ea | 1 | /******************************************************************************* |
jf1452 | 0:4aa0a6b134ea | 2 | * RenBED DC Motor Drive for RenBuggy * |
jf1452 | 0:4aa0a6b134ea | 3 | * Copyright (c) 2014 Jon Fuge * |
jf1452 | 0:4aa0a6b134ea | 4 | * * |
jf1452 | 0:4aa0a6b134ea | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy * |
jf1452 | 0:4aa0a6b134ea | 6 | * of this software and associated documentation files (the "Software"), to deal* |
jf1452 | 0:4aa0a6b134ea | 7 | * in the Software without restriction, including without limitation the rights * |
jf1452 | 0:4aa0a6b134ea | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * |
jf1452 | 0:4aa0a6b134ea | 9 | * copies of the Software, and to permit persons to whom the Software is * |
jf1452 | 0:4aa0a6b134ea | 10 | * furnished to do so, subject to the following conditions: * |
jf1452 | 0:4aa0a6b134ea | 11 | * * |
jf1452 | 0:4aa0a6b134ea | 12 | * The above copyright notice and this permission notice shall be included in * |
jf1452 | 0:4aa0a6b134ea | 13 | * all copies or substantial portions of the Software. * |
jf1452 | 0:4aa0a6b134ea | 14 | * * |
jf1452 | 0:4aa0a6b134ea | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * |
jf1452 | 0:4aa0a6b134ea | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * |
jf1452 | 0:4aa0a6b134ea | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * |
jf1452 | 0:4aa0a6b134ea | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * |
jf1452 | 0:4aa0a6b134ea | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,* |
jf1452 | 0:4aa0a6b134ea | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * |
jf1452 | 0:4aa0a6b134ea | 21 | * THE SOFTWARE. * |
jf1452 | 0:4aa0a6b134ea | 22 | * * |
jf1452 | 0:4aa0a6b134ea | 23 | * DCMotorDrive.h * |
jf1452 | 0:4aa0a6b134ea | 24 | * * |
jf1452 | 0:4aa0a6b134ea | 25 | * V1.0 06/01/2014 First issue of code Jon Fuge * |
jf1452 | 0:4aa0a6b134ea | 26 | *******************************************************************************/ |
jf1452 | 0:4aa0a6b134ea | 27 | |
jf1452 | 0:4aa0a6b134ea | 28 | #ifndef _DCMOTORCONTROLLER_H |
jf1452 | 0:4aa0a6b134ea | 29 | #define _DCMOTORCONTROLLER_H |
jf1452 | 0:4aa0a6b134ea | 30 | |
jf1452 | 0:4aa0a6b134ea | 31 | #include "mbed.h" |
jf1452 | 0:4aa0a6b134ea | 32 | #include "DCMotorDrive.h" |
jf1452 | 0:4aa0a6b134ea | 33 | |
jf1452 | 0:4aa0a6b134ea | 34 | #define WHEEL_CIRCUMFERENCE 114.4 |
jf1452 | 0:4aa0a6b134ea | 35 | #define COUNTS_PER_ROTATION 64 |
jf1452 | 0:4aa0a6b134ea | 36 | #define PWM_SPEED_ADJUST 20 |
jf1452 | 0:4aa0a6b134ea | 37 | #define ROTATION_LIMIT 20 |
jf1452 | 0:4aa0a6b134ea | 38 | |
jf1452 | 0:4aa0a6b134ea | 39 | class MotorController |
jf1452 | 0:4aa0a6b134ea | 40 | { |
jf1452 | 0:4aa0a6b134ea | 41 | public: |
jf1452 | 0:4aa0a6b134ea | 42 | MotorController(PinName LMotorOut, PinName LSensorIn, PinName LMotorOut, PinName LSensorIn); |
jf1452 | 0:4aa0a6b134ea | 43 | void LeftResetOdometer(void); |
jf1452 | 0:4aa0a6b134ea | 44 | int LeftReadOdometer(void); |
jf1452 | 0:4aa0a6b134ea | 45 | int LeftReadCaptureTime(void); |
jf1452 | 0:4aa0a6b134ea | 46 | int LeftReadLastTime(void); |
jf1452 | 0:4aa0a6b134ea | 47 | void RightResetOdometer(void); |
jf1452 | 0:4aa0a6b134ea | 48 | int RightReadOdometer(void); |
jf1452 | 0:4aa0a6b134ea | 49 | int RightReadCaptureTime(void); |
jf1452 | 0:4aa0a6b134ea | 50 | int RightReadLastTime(void); |
jf1452 | 0:4aa0a6b134ea | 51 | private: |
jf1452 | 0:4aa0a6b134ea | 52 | DCMotorDrive _LeftMotor; |
jf1452 | 0:4aa0a6b134ea | 53 | DCMotorDrive _RightMotor; |
jf1452 | 0:4aa0a6b134ea | 54 | }; |
jf1452 | 0:4aa0a6b134ea | 55 | |
jf1452 | 0:4aa0a6b134ea | 56 | #endif // _DCMOTORCONTROLLER_H |