... more
                 
            
         
    
    
« Back to documentation index 
    
AX12 Class Reference 
Servo control class, based on a PwmOut.  
More... 
#include <AX12.h >
  AX12  (PinName tx, PinName rx, int ID, int baudrate)  Create an AX12  servo object connected to the specified serial port, with the specified ID.   int  SetMode  (int mode)  Set the mode of the servo.   int  SetGoal  (int degrees, int flags=0)  Set goal angle in integer degrees, in positional mode.   int  SetCRSpeed  (float speed)  Set the speed of the servo in continuous rotation mode.   int  SetCWLimit  (int degrees)  Set the clockwise limit of the servo.   int  SetCCWLimit  (int degrees)  Set the counter-clockwise limit of the servo.   int  SetID  (int CurrentID, int NewID)  Change the ID of a servo.   int  isMoving  (void)  Poll to see if the servo is moving.   void  trigger  (void)  Send the broadcast "trigger" command, to activate any outstanding registered commands.   float  GetPosition  ()  Read the current angle of the servo.   float  GetTemp  (void)  Read the temperature of the servo.   float  GetVolts  (void)  Read the supply voltage of the servo.   
Detailed Description 
Servo control class, based on a PwmOut. 
Example: 
 #include "mbed.h" 
 #include "AX12.h" 
 
 int  main() {
 
   AX12  myax12 (p9, p10, 1);
   while  (1) {
       myax12.SetGoal(0);    
       wait (2.0);
       myax12.SetGoal(300);  
       wait (2.0);
   }
 }
Definition at line 74  of file AX12.h .
Constructor & Destructor Documentation 
      
        
          AX12  ( 
          PinName  
           tx ,  
         
        
          PinName  
           rx ,  
         
        
          int  
           ID ,  
         
        
          int  
           baudrate   
         
        
          ) 
           
      
 
Create an AX12  servo object connected to the specified serial port, with the specified ID. 
Parameters: 
  
    pin tx pin  pin rx pin  int ID, the Bus ID of the servo 1-255  
   
Definition at line 28  of file AX12.cpp .
 
 
Member Function Documentation 
      
        
          float GetPosition  
          ( 
          void  
           ) 
           
      
 
Read the current angle of the servo. 
Returns: float in the range 0.0-300.0  Definition at line 230  of file AX12.cpp .
 
 
Read the temperature of the servo. 
Returns: float temperature  Definition at line 246  of file AX12.cpp .
 
 
Read the supply voltage of the servo. 
Returns: float voltage  Definition at line 258  of file AX12.cpp .
 
 
Poll to see if the servo is moving. 
Returns: true is the servo is moving  Definition at line 166  of file AX12.cpp .
 
 
      
        
          int SetCCWLimit  
          ( 
          int  
           degrees  ) 
           
      
 
Set the counter-clockwise limit of the servo. 
Parameters: 
  
   
Definition at line 134  of file AX12.cpp .
 
 
      
        
          int SetCRSpeed  
          ( 
          float  
           speed  ) 
           
      
 
Set the speed of the servo in continuous rotation mode. 
Parameters: 
  
    speed,-1.0 to 1.0 -1.0 = full speed counter clock wise 1.0 = full speed clock wise  
   
Definition at line 87  of file AX12.cpp .
 
 
      
        
          int SetCWLimit  
          ( 
          int  
           degrees  ) 
           
      
 
Set the clockwise limit of the servo. 
Parameters: 
  
   
Definition at line 114  of file AX12.cpp .
 
 
      
        
          int SetGoal  
          ( 
          int  
           degrees ,  
         
        
          int  
           flags  = 0  
         
        
          ) 
           
      
 
Set goal angle in integer degrees, in positional mode. 
Parameters: 
  
    degrees 0-300  flags,defaults to 0 flags[0] = blocking, return when goal position reached flags[1] = register, activate with a broadcast trigger  
   
Definition at line 56  of file AX12.cpp .
 
 
      
        
          int SetID  
          ( 
          int  
           CurrentID ,  
         
        
          int  
           NewID   
         
        
          ) 
           
      
 
Change the ID of a servo. 
Parameters: 
  
   
If a servo ID is not know, the broadcast address of 0 can be used for CurrentID. In this situation, only one servo should be connected to the bus 
Definition at line 153  of file AX12.cpp .
 
 
Set the mode of the servo. 
Parameters: 
  
    mode 0 = Positional, default 1 = Continuous rotation  
   
Definition at line 38  of file AX12.cpp .
 
 
Send the broadcast "trigger" command, to activate any outstanding registered commands. 
Definition at line 174  of file AX12.cpp .