Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LocalPositionSystem MMA8451Q Motor_Driver Sensors mbed
Fork of TDP_main by
Diff: motor_driver.h
- Revision:
- 5:2fc7bf0135d4
- Parent:
- 4:3aa9c1c734fe
- Child:
- 6:bea13722aae7
diff -r 3aa9c1c734fe -r 2fc7bf0135d4 motor_driver.h
--- a/motor_driver.h Sat Feb 21 01:54:23 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
-WWWWWWWW WWWWWWWW OOOOOOOOO RRRRRRRRRRRRRRRRR KKKKKKKKK KKKKKKK IIIIIIIIIINNNNNNNN NNNNNNNN
-W::::::W W::::::W OO:::::::::OO R::::::::::::::::R K:::::::K K:::::K I::::::::IN:::::::N N::::::N
-W::::::W W::::::W OO:::::::::::::OO R::::::RRRRRR:::::R K:::::::K K:::::K I::::::::IN::::::::N N::::::N
-W::::::W W::::::WO:::::::OOO:::::::ORR:::::R R:::::RK:::::::K K::::::K II::::::IIN:::::::::N N::::::N
- W:::::W WWWWW W:::::W O::::::O O::::::O R::::R R:::::RKK::::::K K:::::KKK I::::I N::::::::::N N::::::N
- W:::::W W:::::W W:::::W O:::::O O:::::O R::::R R:::::R K:::::K K:::::K I::::I N:::::::::::N N::::::N
- W:::::W W:::::::W W:::::W O:::::O O:::::O R::::RRRRRR:::::R K::::::K:::::K I::::I N:::::::N::::N N::::::N
- W:::::W W:::::::::W W:::::W O:::::O O:::::O R:::::::::::::RR K:::::::::::K I::::I N::::::N N::::N N::::::N
- W:::::W W:::::W:::::W W:::::W O:::::O O:::::O R::::RRRRRR:::::R K:::::::::::K I::::I N::::::N N::::N:::::::N
- W:::::W W:::::W W:::::W W:::::W O:::::O O:::::O R::::R R:::::R K::::::K:::::K I::::I N::::::N N:::::::::::N
- W:::::W:::::W W:::::W:::::W O:::::O O:::::O R::::R R:::::R K:::::K K:::::K I::::I N::::::N N::::::::::N
- W:::::::::W W:::::::::W O::::::O O::::::O R::::R R:::::RKK::::::K K:::::KKK I::::I N::::::N N:::::::::N
- W:::::::W W:::::::W O:::::::OOO:::::::ORR:::::R R:::::RK:::::::K K::::::K II::::::IIN::::::N N::::::::N
- W:::::W W:::::W OO:::::::::::::OO R::::::R R:::::RK:::::::K K:::::K I::::::::IN::::::N N:::::::N
- W:::W W:::W OO:::::::::OO R::::::R R:::::RK:::::::K K:::::K I::::::::IN::::::N N::::::N
- WWW WWW OOOOOOOOO RRRRRRRR RRRRRRRKKKKKKKKK KKKKKKK IIIIIIIIIINNNNNNNN NNNNNNN
-
-
-PPPPPPPPPPPPPPPPP RRRRRRRRRRRRRRRRR OOOOOOOOO GGGGGGGGGGGGGRRRRRRRRRRRRRRRRR EEEEEEEEEEEEEEEEEEEEEE SSSSSSSSSSSSSSS SSSSSSSSSSSSSSS
-P::::::::::::::::P R::::::::::::::::R OO:::::::::OO GGG::::::::::::GR::::::::::::::::R E::::::::::::::::::::E SS:::::::::::::::S SS:::::::::::::::S
-P::::::PPPPPP:::::P R::::::RRRRRR:::::R OO:::::::::::::OO GG:::::::::::::::GR::::::RRRRRR:::::R E::::::::::::::::::::ES:::::SSSSSS::::::SS:::::SSSSSS::::::S
-PP:::::P P:::::PRR:::::R R:::::RO:::::::OOO:::::::O G:::::GGGGGGGG::::GRR:::::R R:::::REE::::::EEEEEEEEE::::ES:::::S SSSSSSSS:::::S SSSSSSS
- P::::P P:::::P R::::R R:::::RO::::::O O::::::O G:::::G GGGGGG R::::R R:::::R E:::::E EEEEEES:::::S S:::::S
- P::::P P:::::P R::::R R:::::RO:::::O O:::::OG:::::G R::::R R:::::R E:::::E S:::::S S:::::S
- P::::PPPPPP:::::P R::::RRRRRR:::::R O:::::O O:::::OG:::::G R::::RRRRRR:::::R E::::::EEEEEEEEEE S::::SSSS S::::SSSS
- P:::::::::::::PP R:::::::::::::RR O:::::O O:::::OG:::::G GGGGGGGGGG R:::::::::::::RR E:::::::::::::::E SS::::::SSSSS SS::::::SSSSS
- P::::PPPPPPPPP R::::RRRRRR:::::R O:::::O O:::::OG:::::G G::::::::G R::::RRRRRR:::::R E:::::::::::::::E SSS::::::::SS SSS::::::::SS
- P::::P R::::R R:::::RO:::::O O:::::OG:::::G GGGGG::::G R::::R R:::::R E::::::EEEEEEEEEE SSSSSS::::S SSSSSS::::S
- P::::P R::::R R:::::RO:::::O O:::::OG:::::G G::::G R::::R R:::::R E:::::E S:::::S S:::::S
- P::::P R::::R R:::::RO::::::O O::::::O G:::::G G::::G R::::R R:::::R E:::::E EEEEEE S:::::S S:::::S
-PP::::::PP RR:::::R R:::::RO:::::::OOO:::::::O G:::::GGGGGGGG::::GRR:::::R R:::::REE::::::EEEEEEEE:::::ESSSSSSS S:::::SSSSSSSS S:::::S
-P::::::::P R::::::R R:::::R OO:::::::::::::OO GG:::::::::::::::GR::::::R R:::::RE::::::::::::::::::::ES::::::SSSSSS:::::SS::::::SSSSSS:::::S
-P::::::::P R::::::R R:::::R OO:::::::::OO GGG::::::GGG:::GR::::::R R:::::RE::::::::::::::::::::ES:::::::::::::::SS S:::::::::::::::SS
-PPPPPPPPPP RRRRRRRR RRRRRRR OOOOOOOOO GGGGGG GGGGRRRRRRRR RRRRRRREEEEEEEEEEEEEEEEEEEEEE SSSSSSSSSSSSSSS SSSSSSSSSSSSSSS
-
-*/
-
-/* Contains control schemes for motors,
-* - Allows change of steering mode
-* - Independent speed control of wheels
-* - None of variable need to be modified once completed, all pin changes etc. can be completed externally
-*/
-
-/* Steering mode:
- LINEAR: Motors share a common direction, turn by changing velocity
- PIVOT: Motors contrarotate in order to turn
- {{{TODO: Find better names for these!!!}}}
-*/
-typedef enum {LINEAR, PIVOT} steering_mode;
-
-
-class motor_driver
-{
- public:
- // Constructor
- motor_driver(PinName L_ENABLE, PinName L_FWD, PinName L_REV, PinName R_ENABLE, PinName R_FWD, PinName R_REV);
- void stop(int time);
- // Deconstructor
- ~motor_driver();
- protected:
- steering_mode steering;
- // Holds the flags for the motor state in a single byte
- // [x][x][L_ENABLE][L_MOTOR_FWD][L_MOTOR_REV][R_ENABLE][R_MOTOR_FWD][R_MOTOR_REV]
- char* current_mode;
-
- float* left_motor_speed;
- float* right_motor_speed;
-};
-
-motor_driver::motor_driver(PinName L_ENABLE, PinName L_FWD, PinName L_REV, PinName R_ENABLE, PinName R_FWD, PinName R_REV)
-{
- // Set default steering mode
- steering = LINEAR;
- // Default all motors to disabled
- current_mode = 0x00;
-
- PwmOut L_MOTOR_EN(L_ENABLE);
- DigitalOut L_MOTOR_FWD(L_FWD);
- DigitalOut L_MOTOR_REV(L_REV);
-
- PwmOut R_MOTOR_EN(R_ENABLE);
- DigitalOut R_MOTOR_FWD(R_FWD);
- DigitalOut R_MOTOR_REV(R_REV);
-}
-
-void motor_driver::stop(int time)
-{
- if ((current_mode & 0x20) != 0) {
- }
-}
