Control for RenBuggy

Dependencies:   PID PinDetect mbed

Committer:
salatron
Date:
Thu Mar 06 09:56:11 2014 +0000
Revision:
2:cd7543fdcb8c
Parent:
1:8a2a7adb3c5d
version 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
salatron 2:cd7543fdcb8c 1 /*******************************************************************************
salatron 2:cd7543fdcb8c 2 * RenBED PID Motor Control for RenBuggy *
salatron 2:cd7543fdcb8c 3 * Copyright (c) 2014 Sally Brown & Liz Lloyd *
salatron 2:cd7543fdcb8c 4 * *
salatron 2:cd7543fdcb8c 5 * Permission is hereby granted, free of charge, to any person obtaining a copy *
salatron 2:cd7543fdcb8c 6 * of this software and associated documentation files (the "Software"), to deal*
salatron 2:cd7543fdcb8c 7 * in the Software without restriction, including without limitation the rights *
salatron 2:cd7543fdcb8c 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
salatron 2:cd7543fdcb8c 9 * copies of the Software, and to permit persons to whom the Software is *
salatron 2:cd7543fdcb8c 10 * furnished to do so, subject to the following conditions: *
salatron 2:cd7543fdcb8c 11 * *
salatron 2:cd7543fdcb8c 12 * The above copyright notice and this permission notice shall be included in *
salatron 2:cd7543fdcb8c 13 * all copies or substantial portions of the Software. *
salatron 2:cd7543fdcb8c 14 * *
salatron 2:cd7543fdcb8c 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
salatron 2:cd7543fdcb8c 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
salatron 2:cd7543fdcb8c 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
salatron 2:cd7543fdcb8c 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
salatron 2:cd7543fdcb8c 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
salatron 2:cd7543fdcb8c 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
salatron 2:cd7543fdcb8c 21 * THE SOFTWARE. *
salatron 2:cd7543fdcb8c 22 * *
salatron 2:cd7543fdcb8c 23 *******************************************************************************/
salatron 0:f414c64e674f 24
salatron 0:f414c64e674f 25 #include "RenBuggy_PID.h"
salatron 0:f414c64e674f 26
salatron 0:f414c64e674f 27 int main()
salatron 0:f414c64e674f 28 {
salatron 2:cd7543fdcb8c 29 //The code defaults to the striped wheel buggy configuration for counts per rev, wheel circumference, axle width
salatron 1:8a2a7adb3c5d 30 //pins are motor l, motor r, brake l, brake r, sensor l, sensor r
salatron 2:cd7543fdcb8c 31 //Supply the appropriate pins for the motors, brakes and sensors.
salatron 2:cd7543fdcb8c 32 //i.e. if you left motor is wired to pin p25 then supply p25 as the parameter for the left motor
salatron 1:8a2a7adb3c5d 33 //PID_Stripes pid(p25, p10, p8, p7, p9, p21);
salatron 1:8a2a7adb3c5d 34
salatron 1:8a2a7adb3c5d 35
salatron 1:8a2a7adb3c5d 36 //No striped wheels - remember to set up the constants
salatron 1:8a2a7adb3c5d 37 //i.e. counts per rev, wheel circumference, axle width
salatron 1:8a2a7adb3c5d 38 //pins are motor l, motor r, brake l, brake r, sensor l, sensor r
salatron 1:8a2a7adb3c5d 39 //PID_Magnet pid(p25, p10, p8, p7, p9, p21);
salatron 1:8a2a7adb3c5d 40 PID_Magnet pid(p5, p6, p7, p8, p21, p22);
salatron 1:8a2a7adb3c5d 41 pid.SetUpConstants(64, 11.31, 6.4);
salatron 1:8a2a7adb3c5d 42
salatron 1:8a2a7adb3c5d 43 pid.Stop();
salatron 1:8a2a7adb3c5d 44 pid.Forwards(50);
salatron 1:8a2a7adb3c5d 45 pid.Stop();
salatron 1:8a2a7adb3c5d 46 pid.Left(90, 13);
salatron 1:8a2a7adb3c5d 47 pid.Stop();
salatron 0:f414c64e674f 48 pid.Forwards(20);
salatron 1:8a2a7adb3c5d 49 pid.Right(90,20);
salatron 1:8a2a7adb3c5d 50 pid.Stop();
salatron 1:8a2a7adb3c5d 51 }