D:/DRISSI/arduino-0022/arduino-0022/libraries/motors/motors.h
Go to the documentation of this file.
00001 
00005 #ifndef motors_h
00006 #define motors_h
00007 
00008 #include <WProgram.h>
00009 #include <TimerOne/TimerOne.h>
00010 
00011 
00012 /*
00013   motors.h - Library for controling motors
00014   from Faulhaber (with RS232 link)
00015 
00016 
00017   Copyright (c) 2011 David Drissi.  All right reserved.
00018   Property of the University of Angers.
00019 
00020   Contact : philippe.lucidarme@univ-angers.fr
00021 
00022   This library is distributed in the hope that it will be useful,
00023   but WITHOUT ANY WARRANTY; without even the implied warranty of
00024   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025   Lesser General Public License for more details.  
00026 */
00027 
00028 // #define __DEBUG__MOTORS__
00029 
00030 
00032 
00033                         
00034 // Enable left or right
00037         bool            EnableLeft();
00040         bool            EnableRight();
00041 
00042 
00043 // Disable left or right
00046         bool            DisableLeft();
00049         bool            DisableRight();
00050 
00051 
00052 // Reset left or right
00055         bool            ResetLeft();
00058         bool            ResetRight();
00059 
00060 // Read reception buffer left or right
00066         char            ReadBufferLeft (char *Buffer,int NbMax,long TimeOut);
00072         char            ReadBufferRight (char *Buffer,int NbMax,long TimeOut);
00073 
00074 // Read reception and check if a "ok" is received
00078         bool            CheckOKLeft(long TimeOut_us=100000);
00082         bool            CheckOKRight(long TimeOut_us=100000);
00083 
00084 // Read reception and check if a "reset" is received
00088         bool            CheckRESETLeft(long TimeOut_us=100000);
00092         bool            CheckRESETRight(long TimeOut_us=100000);
00093 
00094 // Interrupt function of the time out
00097         void            ISR_TimeOut_Motors();
00098 
00100 
00101 // Set speed left or right (0 to 32767 rpm)
00105         bool            SetLeftSpeed(long Vit);
00109         bool            SetRightSpeed(long Vit);
00110 
00111 
00112 // Set absolute position left or right (-1.8*10^9 to +1.8*10^9)
00116         bool            SetLeftAbsolutePos(long Pos);
00120         bool            SetRightAbsolutePos(long Pos);
00121 
00122 
00123 // Set relative position left or right (-2.14*10^9 to +2.14*10^9)
00127         bool            SetLeftRelativePos(long Pos);
00131         bool            SetRightRelativePos(long Pos);
00132 
00133                 
00134 // Set acceleration left or right (0 to 30000 r/s^2)
00138         bool            SetLeftAcc(int Acc);
00142         bool            SetRightAcc(int Acc);
00143 
00144 
00145 // Set deceleration left or right (0 to 30000 r/s^2)
00149         bool            SetLeftDec(int Dec);
00153         bool            SetRightDec(int Dec);
00154 
00155 
00156 // Set peak current left or right (0 to 12000 mA)
00160         bool            SetLeftPeakCurrentLimit(int Current);
00164         bool            SetRightPeakCurrentLimit(int Current);
00165 
00166 // Set continuous current limit (0 to 12000 mA)
00170         bool            SetLeftContCurrentLimit(int Current);
00174         bool            SetRightContCurrentLimit(int Current);
00175 
00176 // Set if motors tell when position is reached
00180         bool            SetLeftNotifyPosition(long Pos=0);
00184         bool            SetRightNotifyPosition(long Pos=0);
00185 
00186 // Desactivate the notify position mode
00189         bool            SetLeftNotifyPositionOff();
00192         bool            SetRightNotifyPositionOff();
00193 
00194 // Set if motors tell when velocity is reached
00198         bool            SetLeftNotifyVelocity(long Vel);
00202         bool            SetRightNotifyVelocity(long Vel);
00203 
00204 // Desactivate the notify velocity mode
00207         bool            SetLeftNotifyVelocityOff();
00210         bool            SetRightNotifyVelocityOff();
00211         
00212 // Move to reach position load previously
00215         bool            MovingLeft();
00218         bool            MovingRight();
00219 
00221 
00222 // Get speed left or right (0 to 32767 rpm)
00225         char            GetLeftSpeed(long *Speed);
00228         char            GetRightSpeed(long *Speed);
00229 
00230         
00231 // Get position left or right (-1.8*10^9 to +1.8*10^9)
00234         char            GetLeftPos(long *Pos);
00237         char            GetRightPos(long *Pos);
00238 
00239 
00240 // Get acceleration left or right (0 to 30000 r/s^2)
00243         char            GetLeftAcc(int *Acc);
00246         char            GetRightAcc(int *Acc);
00247 
00248 
00249 // Get deceleration left or right (0 to 30000 r/s^2)
00252         char            GetLeftDec(int *Dec);
00255         char            GetRightDec(int *Dec);
00256 
00257 
00258 // Get peak current limit left or right (0 to 12000 mA)
00261         char            GetLeftPeakCurrentLimit(int *Current);
00264         char            GetRightPeakCurrentLimit(int *Current);
00265 
00266 
00267 // Get continuous current limit left or right (0 to 12000 mA)
00270         char            GetLeftContCurrentLimit(int *Current);
00273         char            GetRightContCurrentLimit(int *Current);
00274 
00275 // Check if a "notify position" packet is arrived
00278         bool            GetLeftNotifyPosition();
00281         bool            GetRightNotifyPosition();
00282 
00283 // Check if a "notify velocity" packet is arrived
00286         bool            GetLeftNotifyVelocity();
00289         bool            GetRightNotifyVelocity();
00290 
00291 
00292 #endif