Control for RenBuggy
Dependencies: PID PinDetect mbed
Diff: RenBuggy_PID.h
- Revision:
- 1:8a2a7adb3c5d
- Parent:
- 0:f414c64e674f
--- a/RenBuggy_PID.h Tue Mar 04 13:31:17 2014 +0000 +++ b/RenBuggy_PID.h Wed Mar 05 13:37:10 2014 +0000 @@ -1,6 +1,6 @@ /******************************************************************************* * RenBED PID Motor Control for RenBuggy * -* Copyright (c) 2014 Sally Brown * +* Copyright (c) 2014 Sally Brown & Liz Lloyd * * * * Permission is hereby granted, free of charge, to any person obtaining a copy * * of this software and associated documentation files (the "Software"), to deal* @@ -36,42 +36,47 @@ class PID_Controller { - public: - PID_Controller(PinName motorL, PinName motorR, PinName brakeL, PinName brakeR, PinName sensorL, PinName sensorR); - - void SetUpConstants(int numberStripes, float wheelCircumference); + public: + void SetUpConstants(int countsPerRev, float wheelCircumference, float axleLength); - void Forwards(int countsForward); + void Forwards(int distanceForward); void Left(int angleLeft, int radiusLeft); void Right(int angleRight, int radiusRight); + void Stop(); + + void ConfigurePID(float p, float i, float d); + + void countL(); + void countR(); + + protected: + + PID_Controller(PinName motorL, PinName motorR, PinName brakeL, PinName brakeR); + virtual void setUpControllers(); + PID getLeftController() {return m_controllerL;} + PID getRightController() {return m_controllerR;} + private: void doSomePID(); void PIDLeft(); void PIDRight(); - void countL(); - void countR(); - - void setUpControllers(); - PID m_controllerL; //Kc, Ti, Td, interval PID m_controllerR; - + PwmOut m_motorL; PwmOut m_motorR; DigitalOut m_brakeL; DigitalOut m_brakeR; - - PinDetect m_senseL; //Left encoder. Pin detect type is the debouncing. - PinDetect m_senseR; Ticker m_rate; - int m_numberStrips; + int m_countsPerRev; float m_wheelCircumference; + float m_axleLength; int m_stripesL; int m_stripesR; @@ -81,9 +86,26 @@ float m_fProportionLeft; float m_fProportionRight; - - int m_iProportionLeft; - int m_iProportionRight; +}; + +class PID_Stripes : public PID_Controller +{ + public: + PID_Stripes(PinName motorL, PinName motorR, PinName brakeL, PinName brakeR, PinName sensorL, PinName sensorR); + + private: + PinDetect m_senseL; //Left encoder. Pin detect type is the debouncing. + PinDetect m_senseR; +}; + +class PID_Magnet : public PID_Controller +{ + public: + PID_Magnet(PinName motorL, PinName motorR, PinName brakeL, PinName brakeR, PinName sensorL, PinName sensorR); + + private: + InterruptIn m_senseL; //Left encoder. + InterruptIn m_senseR; }; #endif // _PIDCONTROLLER_H \ No newline at end of file