1am
Revision 3:94b650d0861d, committed 2010-12-16
- Comitter:
- sowmy87
- Date:
- Thu Dec 16 09:25:25 2010 +0000
- Parent:
- 2:9e0d3f159ec3
- Commit message:
- 1
Changed in this revision
Serializer.cpp | Show annotated file Show diff for this revision Revisions of this file |
Serializer.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Serializer.cpp Mon Dec 13 06:04:02 2010 +0000 +++ b/Serializer.cpp Thu Dec 16 09:25:25 2010 +0000 @@ -3,7 +3,7 @@ */ #include "Serializer.h" -Serial pcc(USBTX, USBRX); +//Serial pcc(USBTX, USBRX); Serializer::Serializer() { serial=new Serial(p28,p27); @@ -25,20 +25,19 @@ led2=1; while (serial->readable()) { c1=serial->getc(); - pcc.putc(c1); } if (c1!='>') for (int i=0;i<5;i++) { led1=led2=led3=led4=1; - wait(0.5); + wait(0.1); led1=led2=led3=led4=0; - wait(0.5); + wait(0.1); } wait(.25); led3=1; wait(.25); led4=1; - SetVPID(10,0,5,10); + SetVPID(1,0,0,100); wait(0.25); led1=0; wait(.25); @@ -97,11 +96,9 @@ } void Serializer::SetSpeed(int inPsec) { - pcc.printf("inSpeed %i\n\r",inPsec); if (inPsec>MAX_SPEED)inPsec=MAX_SPEED; if (inPsec<-MAX_SPEED)inPsec=-MAX_SPEED; inPsec*=-1; - pcc.printf("mogo 1:%i\n\r",inPsec); if (serial->writeable()) serial->printf("mogo 1:%i 2:%i\r", inPsec, inPsec); leftSpeed=rightSpeed=inPsec; @@ -189,9 +186,7 @@ void Serializer::PivetLeft(int deg) { Stop(); - pcc.printf("deg = %i\t",deg); deg=deg*PIVET_ADJUSTMENT; - //pcc.printf("adj = %i\n\r",deg); wait(0.1); if (serial->writeable()) serial->printf("digo 1:%i:%i 2:%i:%i\r",deg,PIVET_SPEED,-deg,PIVET_SPEED); @@ -219,6 +214,20 @@ serial->printf("pwm 2:%i\r",_rPWM); } +void Serializer::SetPWM(int pwm){ + _rPWM=-pwm; + _lPWM=-pwm; + if (serial->writeable()) + serial->printf("pwm 1:%i 2:%i\r",_lPWM, _rPWM); + } + +void Serializer::SetPWM(int lPwm, int rPwm){ + _rPWM=-rPwm; + _lPWM=-lPwm; + if (serial->writeable()) + serial->printf("pwm 1:%i 2:%i\r",_lPWM, _rPWM); + } + int Serializer::GetCountLeft() { if (serial->writeable()) { serial->printf("getenc 1\r"); @@ -317,6 +326,5 @@ else if (c=='0') bsy=0; } - pcc.putc(_isBusy+'0'); if (_isBusy&&!bsy) _isBusy=0; }
--- a/Serializer.h Mon Dec 13 06:04:02 2010 +0000 +++ b/Serializer.h Thu Dec 16 09:25:25 2010 +0000 @@ -20,7 +20,7 @@ #include "mbed.h" /** - * Serializer Class to communicate with Robotics + * Serializer Class to communicate with Robotics * Connection Serializer(tm) board */ class Serializer { @@ -29,9 +29,9 @@ /** * Constructor. * - */ + */ Serializer(); - + /** * Destructor. * @@ -43,33 +43,33 @@ * */ void ClearCountLeft(); - + /** * Clears right motor encoder count * - */ + */ void ClearCountRight(); - + /** * Clears motors encoder counts * */ void ClearCount(); - + /** * Sets left motor speed * @param inPsec Motor Speed in inches per second */ void SetSpeedLeft(int inPsec); - + /** * Sets right motor speed * @param inPsec Motor Speed in inches per second */ void SetSpeedRight(int inPsec); - + /** - * Sets speed for both motors + * Sets speed for both motors * @param inPsec Motor Speed in inches per second */ void SetSpeed(int inPsec); @@ -82,7 +82,7 @@ * @param l */ void SetVPID(int,int,int,int); - + /** * Sets DPID * @param p @@ -91,51 +91,52 @@ * @param a */ void SetDPID(int,int,int,int); - + /** * Sets left motor distance and speed - * @param inches Distance in inches + * @param inches Distance in ticks * @param inPsec Motor Speed */ void DiGoLeft(int inches,int inPsec); - + /** * Sets right motor distance and speed - * @param inches Distance in inches + * @param inches Distance in ticks * @param inPsec Motor Speed */ void DiGoRight(int inches,int inPsec); - + /** * Sets both motors distance and speed - * @param inches Distance in inches + * @param inches Distance in ticks * @param inPsec Motor Speed */ void DiGo(int inches,int inPsec); - + void SetLeftPWM(int pwm); void SetRightPWM(int pwm); - + void SetPWM(int pwm); + void SetPWM(int lPwm, int rPwm); int IsBusy(); - + /** * Stops both motors */ void Stop(); - + void TurnLeft(int deg); void TurnRight(int deg); void PivetLeft(int deg); void PivetRight(int deg); - + int GetCountLeft(); int GetCountRight(); int GetCount(); float GetDistanceLeft(); float GetDistanceRight(); float GetDistance(); - - + +