1am

Revision:
0:d2dcb47dc8e9
Child:
1:9a7e6c978adb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Serializer.h	Sun Dec 12 23:49:02 2010 +0000
@@ -0,0 +1,152 @@
+#ifndef SERIALIZER_H
+#define SERIALIZER_H
+
+
+#define     BAUD                    19200
+#define     MAX_SPEED               127
+
+#define     WAIT                    .001
+#define     PI                      3.1415926
+#define     PIVET_ADJUSTMENT        6
+#define     PIVET_SPEED             25
+
+#define     PULSES_PER_REVOLUTION   624
+#define     WHEEL_DIAMETER          2.25           //inches
+#define     WHEEL_CIRCUMFERENCE     PI*WHEEL_DIAMETER
+#define     PULSE_DISTANCE          WHEEL_CIRCUMFERENCE / 624
+#define     PULSES_PER_INCH         int(PULSES_PER_REVOLUTION / WHEEL_CIRCUMFERENCE)
+
+
+#include "mbed.h"
+
+/**
+ * Serializer Class to communicate with Robotics 
+ * Connection Serializer(tm) board
+ */
+class Serializer {
+
+public:
+    /**
+     * Constructor.
+     *
+     */     
+    Serializer();
+    
+    /**
+     * Destructor.
+     *
+     */
+    ~Serializer();
+
+    /**
+     * Clears left motor encoder count
+     *
+     */
+    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 
+     * @param inPsec Motor Speed in inches per second
+     */
+    void    SetSpeed(int inPsec);
+
+    /**
+     * Sets VPID
+     * @param p
+     * @param i
+     * @param d
+     * @param l
+     */
+    void    SetVPID(int,int,int,int);
+    
+    /**
+     * Sets DPID
+     * @param p
+     * @param i
+     * @param d
+     * @param a
+     */
+    void    SetDPID(int,int,int,int);
+    
+    /**
+     * Sets left motor distance and speed
+     * @param inches Distance in inches
+     * @param inPsec Motor Speed
+     */
+    void    DiGoLeft(int inches,int inPsec);
+    
+    /**
+     * Sets right motor distance and speed
+     * @param inches Distance in inches
+     * @param inPsec Motor Speed
+     */
+    void    DiGoRight(int inches,int inPsec);
+    
+    /**
+     * Sets both motors distance and speed
+     * @param inches Distance in inches
+     * @param inPsec Motor Speed
+     */
+    void    DiGo(int inches,int inPsec);
+    
+    void    SetLeftPWM(int pwm);
+    void    SetRightPWM(int pwm);
+
+    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();
+    int     GetDistanceLeft();
+    int     GetDistanceRight();
+    int     GetDistance();
+    
+    
+
+
+
+//protected:
+    int     GetReply();
+    void    InterruptHandler();
+    int     Initialize();
+//private:
+    Serial          *serial;
+    volatile int    leftSpeed, rightSpeed;
+    volatile int    _lPWM, _rPWM;
+    volatile char   commandInProgress;
+};
+#endif
\ No newline at end of file