zhaw_st16b_pes2_10
/
Motors
d
Revision 0:d4a8d6a32b36, committed 2017-03-08
- Comitter:
- beacon
- Date:
- Wed Mar 08 16:49:14 2017 +0000
- Commit message:
- l
Changed in this revision
diff -r 000000000000 -r d4a8d6a32b36 Robot.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Robot.cpp Wed Mar 08 16:49:14 2017 +0000 @@ -0,0 +1,29 @@ +#include "Robot.h" + +/* Work in progress -------------------------------------------- */ + +Robot::Robot(PwmOut* left, PwmOut* right, DigitalOut* enableSignal){ + this->powerSignal = enableSignal; + this->left = left; + this->right = right; + + this->left->period(0.00005f); + this->right->period(0.00005f); + } + +/* work in progress ------------------------------------------- */ +void Robot::drive(){ + //pwm determine what direction it goes. + *powerSignal = 1; + *left = 0.5; + *right = 0.5; +} + +//Remember to set +//DigitalOut powerMotor(PB_2) = 1; +//DigitalIn errorMotor(PB_14); +//if (errorMotor){ + //reset +//} + +//Add management for Overpower!! Pin PB_15
diff -r 000000000000 -r d4a8d6a32b36 Robot.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Robot.h Wed Mar 08 16:49:14 2017 +0000 @@ -0,0 +1,27 @@ +#ifndef MOTORS_H +#define MOTORS_H + +#include <cstdlib> +#include <mbed.h> + + +#include "mbed.h" + +/* Declarations for the Motors in the Robot in order to drive -------- */ +class Robot +{ +public: + Robot(PwmOut* left, PwmOut* right, DigitalOut* enable); + void drive(); + +private: + PwmOut* left; + PwmOut* right; + + DigitalOut* powerSignal; + DigitalIn* errorSignal; + DigitalIn* overtemperatur; + +}; + +#endif
diff -r 000000000000 -r d4a8d6a32b36 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 08 16:49:14 2017 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "Robot.h" + +PwmOut left(PA_8); +PwmOut right(PA_3); + +DigitalOut powerSignal(PB_2); +DigitalIn errorSignal(PB_14); +DigitalIn overtemperatur(PB_15); + +Robot bot( &left, &right, &powerSignal); + +int main() +{ + bot.drive(); + + while( 1 ) { + wait(0.5f); + } + return 0; +}
diff -r 000000000000 -r d4a8d6a32b36 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 08 16:49:14 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f \ No newline at end of file
diff -r 000000000000 -r d4a8d6a32b36 mbed.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.lib Wed Mar 08 16:49:14 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/gokmenascioglu/code/mbed/#a8fa94490a0a