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.
Fork of MotorTest by
Revision 3:78f03f96d641, committed 2015-04-21
- Comitter:
- hollegha2
- Date:
- Tue Apr 21 08:04:54 2015 +0000
- Parent:
- 2:49bce817747c
- Commit message:
- Rev 1.0
Changed in this revision
Dist2Wall_US.cpp | Show annotated file Show diff for this revision Revisions of this file |
MotorTest.cpp | Show diff for this revision Revisions of this file |
diff -r 49bce817747c -r 78f03f96d641 Dist2Wall_US.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Dist2Wall_US.cpp Tue Apr 21 08:04:54 2015 +0000 @@ -0,0 +1,50 @@ + +#include "mbed.h" +#include "Serial_HL.h" +#include "Bertl14.h" +#include "BertlObjects.h" + +void DriveUntilObstacle(); +void Turn180(); + +int main(void) +{ + InitBertl(); + pex.ClearLeds(); + // Damit der Roboter nicht gleich loskoffert + leds = 9; + pex.WaitUntilFrontButtonPressed(); + leds=6; + wait(0.8); + pex.WaitUntilFrontButtonPressed(); + leds=0; + // 2x Button-pressed jetzt gehts los + + while(1) { + DriveUntilObstacle(); + wait(0.5); // Debug wait + Turn180(); + wait(0.5); + } + + return 1; +} + + +void DriveUntilObstacle() +{ + // Motoren ein + // in einer While-Schleife warten bis Distanz kleiner MinDistance + // Motoren aus !!! +} + +void Turn180() +{ + // Motoren auf 0.5 bis 0.7 + // in einer While-Schleife warten bis + // bei !!!beiden!!! Motoren die Ticks für eine 180° Drehung erreicht sind + // Motoren aus +} + + +
diff -r 49bce817747c -r 78f03f96d641 MotorTest.cpp --- a/MotorTest.cpp Tue Apr 21 06:32:51 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ - -#include "mbed.h" -#include "Serial_HL.h" -#include "Bertl14.h" -#include "BertlObjects.h" - -SerialBLK pc(USBTX, USBRX); -SvProtocol ua0(&pc); - -void CommandHandler(); - -int main(void) -{ - InitBertl(); - pex.useISR=0; leds=9; - pex.ClearLeds(); - pc.format(8,SerialBLK::None,1); pc.baud(500000); // 115200 - - ua0.SvMessage("MotorTest1"); // Meldung zum PC senden - - Timer stw; stw.start(); - while(1) - { - CommandHandler(); - if( (stw.read_ms()>10) ) // 100Hz - { // dieser Teil wird mit 100Hz aufgerufen - stw.reset(); - if( ua0.acqON ) { - // nur wenn vom PC aus das Senden eingeschaltet wurde - // wird auch etwas gesendet - ua0.WriteSvI16(1, mL.encCnt); - ua0.WriteSvI16(2, mR.encCnt); - ua0.WriteSvI16(3, us.distCM*100.0); - us.StartMeas(); // for next cycle - } - } - } - return 1; -} - -void CommandHandler() -{ - uint8_t cmd; - // Fragen ob überhaupt etwas im RX-Reg steht - if( !pc.IsDataAvail() ) - return; - // wenn etwas im RX-Reg steht - // Kommando lesen - cmd = ua0.GetCommand(); - - if( cmd==2 ) // Encoder auf 0 setzen - { - mL.encCnt=0; mR.encCnt=0; - ua0.SvMessage("Clear Encoder"); - } - if( cmd==3 ) // bei beiden Motoren Gas geben - { - mL.SetPow(ua0.ReadF()); - mR.SetPow(ua0.ReadF()); - ua0.SvMessage("Set Power"); - } -} - -