Changeset 789

Show
Ignore:
Timestamp:
08/06/08 14:03:57 (3 months ago)
Author:
liamstask
Message:

- add examples to stepper doc
- remove Stepper_GetStep() which was unimplemented and unused

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • firmware/trunk/libraries/stepper/stepper.c

    r777 r789  
    9898  - bipolar or unipolar 
    9999  - normal of half-stepping 
    100  
     100   
     101  \section Positioning 
    101102  You can generally use the stepper motor in 2 modes - \b absolute positioning or \b relative positioning. 
    102103 
     
    106107 
    107108  For relative positioning, use Stepper_Step( ) to simply move a number of steps from the current position. 
     109   
     110  See the <a href="http://www.makingthings.com/documentation/how-to/stepper-motor">Stepper Motor how-to</a> 
     111  for more detailed info on hooking up a stepper motor to the Make Controller. 
    108112* \ingroup Libraries 
    109113* @{ 
     
    111115 
    112116/** 
    113   Attempt to set the specified  
    114117  Sets whether the specified Stepper is active. 
    115118  @param index An integer specifying which stepper (0 or 1). 
    116119  @param state An integer specifying the active state - 1 (active) or 0 (inactive). 
    117120  @return Zero on success. 
     121   
     122  \b Example 
     123  \code 
     124  // enable stepper 1 
     125  Stepper_SetActive(1, 1); 
     126  \endcode 
    118127*/ 
    119128int Stepper_SetActive( int index, int state ) 
     
    152161  @param index An integer specifying which stepper (0-1). 
    153162  @return State - 1 (active) or 0 (inactive). 
     163   
     164  \b Example 
     165  \code 
     166  if( Stepper_GetActive(1) ) 
     167  { 
     168    // Stepper 1 is active 
     169  } 
     170  else 
     171  { 
     172    // Stepper 1 is inactive 
     173  } 
     174  \endcode 
    154175*/ 
    155176int Stepper_GetActive( int index ) 
     
    166187/**  
    167188  Set the position of the specified stepper motor. 
     189  Note that this will not ask the stepper to move.  It will simply update 
     190  the position that the stepper thinks its at.  To move the stepper, see 
     191  Stepper_SetPositionRequested() or Stepper_Step(). 
    168192  @param index An integer specifying which stepper (0 or 1). 
    169193  @param position An integer specifying the stepper position. 
    170194  @return status (0 = OK). 
     195   
     196  \b Example 
     197  \code 
     198  // reset stepper 1 to call its current position 0 
     199  Stepper_SetPosition(1, 0); 
     200  \endcode 
    171201*/ 
    172202int Stepper_SetPosition( int index, int position ) 
     
    192222/**  
    193223  Set the destination position for a stepper motor. 
     224  This will start the stepper moving the given number of 
     225  steps at the current speed, as set by Stepper_SetSpeed(). 
     226   
     227  While it's moving, you can call Stepper_GetPosition() to read 
     228  its current position. 
    194229  @param index An integer specifying which stepper (0 or 1). 
    195230  @param positionRequested An integer specifying the desired stepper position. 
    196231  @return status (0 = OK). 
     232   
     233  \b Example 
     234  \code 
     235  // start moving stepper 0 1500 steps 
     236  Stepper_SetPositionRequested(0, 1500); 
     237  \endcode 
    197238*/ 
    198239int Stepper_SetPositionRequested( int index, int positionRequested ) 
     
    216257/**  
    217258  Set the speed at which a stepper will move. 
    218   This is a number of ms per step, 
    219   rather than the more common steps per second.  Arranging it this way makes  
    220   it easier to express as an integer.  Fastest speed is 1ms / step (1000 steps 
    221   per second) and slowest is many seconds. 
     259  This is a number of ms per step, rather than the more common steps per second.   
     260  Arranging it this way makes it easier to express as an integer.   
     261  Fastest speed is 1ms / step (1000 steps per second) and slowest is many seconds. 
    222262  @param index An integer specifying which stepper (0 or 1). 
    223263  @param speed An integer specifying the stepper speed in ms per step 
    224264  @return status (0 = OK). 
     265   
     266  \b Example 
     267  \code 
     268  // set the speed to 1ms / step (1000 steps per second) 
     269  Stepper_SetSpeed(0, 1); 
     270  \endcode 
    225271*/ 
    226272int Stepper_SetSpeed( int index, int speed ) 
     
    250296  @param index An integer specifying which stepper (0 or 1). 
    251297  @return The speed (0 - 1023), or 0 on error. 
     298   
     299  \b Example 
     300  \code 
     301  int step0_speed = Stepper_GetSpeed(0); 
     302  // now step0_speed has the speed of stepper 0 
     303  \endcode 
    252304*/ 
    253305int Stepper_GetSpeed( int index ) 
     
    264316/**  
    265317  Read the current position of a stepper motor. 
    266   @param index An integer specifying which stepper (0 - 3). 
     318  @param index An integer specifying which stepper (0 or 1). 
    267319  @return The position, 0 on error. 
     320   
     321  \b Example 
     322  \code 
     323  int step0_pos = Stepper_GetPosition(0); 
     324  // now step0_pos has the current position of stepper 0 
     325  \endcode 
    268326*/ 
    269327int Stepper_GetPosition( int index ) 
     
    280338/**  
    281339  Read the destination position of a stepper motor. 
     340  This indicates where the stepper is ultimately headed.  To see 
     341  where it actually is, see Stepper_GetPosition(). 
    282342  @param index An integer specifying which stepper (0 or 1). 
    283343  @return The position and 0 on error 
     344   
     345  \b Example 
     346  \code 
     347  int step1_destination = Stepper_GetPositionRequested(1); 
     348  // step1_destination has the requested position for stepper 1 
     349  \endcode 
    284350*/ 
    285351int Stepper_GetPositionRequested( int index ) 
     
    300366  @param steps An integer specifying the number of steps.  Can be negative to go in reverse. 
    301367  @return status (0 = OK). 
     368   
     369  \b Example 
     370  \code 
     371  // take 1200 steps forward from our current position 
     372  Stepper_Step(0, 1200); 
     373  \endcode 
    302374*/ 
    303375int Stepper_Step( int index, int steps ) 
     
    319391 
    320392/**  
    321   Not implemented - returns 0. 
    322   @param index An integer specifying which stepper (0 or 1). 
    323 */ 
    324 int Stepper_GetStep( int index ) 
    325 { 
    326   if ( index < 0 || index >= STEPPER_COUNT ) 
    327     return CONTROLLER_ERROR_ILLEGAL_INDEX; 
    328  
    329   return 0; // write-only 
    330 } 
    331  
    332 /**  
    333393  Set the duty - from 0 to 1023.  The default is for 100% power (1023). 
    334394  @param index An integer specifying which stepper (0 or 1). 
    335395  @param duty An integer specifying the stepper duty (0 - 1023). 
    336396  @return status (0 = OK). 
     397   
     398  \b Example 
     399  \code 
     400  // set stepper 0 to half power 
     401  Stepper_SetDuty(0, 512); 
     402  \endcode 
    337403*/ 
    338404int Stepper_SetDuty( int index, int duty ) 
     
    358424  Get the duty  
    359425  Read the value previously set for the duty. 
    360   @param index An integer specifying which stepper (0 - 3). 
     426  @param index An integer specifying which stepper (0 or 1). 
    361427  @return The duty (0 - 1023), or 0 on error. 
     428   
     429  \b Example 
     430  \code 
     431  int step1_duty = Stepper_GetDuty(1); 
     432  // step1_duty has the current duty for stepper 1 
     433  \endcode 
    362434*/ 
    363435int Stepper_GetDuty( int index ) 
     
    373445 
    374446/**  
    375   Declare whether the stepper is bipolar or not.  Default is bipolar. 
     447  Declare whether the stepper is bipolar or not.   
     448  Default is bipolar. 
    376449  @param index An integer specifying which stepper (0 or 1). 
    377450  @param bipolar An integer 1 for bipolar, 0 for unipolar 
    378451  @return status (0 = OK). 
     452   
     453  \b Example 
     454  \code 
     455  // set stepper 1 to unipolar 
     456  Stepper_SetBipolar(1, 0); 
     457  \endcode 
    379458*/ 
    380459int Stepper_SetBipolar( int index, int bipolar ) 
     
    395474  Get the bipolar setting 
    396475  Read the value previously set for bipolar. 
    397   @param index An integer specifying which stepper (0 - 3). 
     476  @param index An integer specifying which stepper (0 or 1). 
    398477  @return 1 for bipolar or 0 for unipolar. 
     478   
     479  \b Example 
     480  \code 
     481  if( Stepper_GetBipolar(1) ) 
     482  { 
     483    // stepper 1 is bipolar 
     484  } 
     485  else 
     486  { 
     487    // stepper 1 is unipolar 
     488  } 
     489  \endcode 
    399490*/ 
    400491int Stepper_GetBipolar( int index ) 
     
    410501 
    411502/**  
    412   Declare whether the stepper is in half stepping mode or not.  Default is not - i.e. in full step mode. 
     503  Declare whether the stepper is in half stepping mode or not.   
     504  Default is not - i.e. in full step mode. 
    413505  @param index An integer specifying which stepper (0 or 1). 
    414506  @param halfStep An integer specifying 1 for half step, 0 for full step 
    415507  @return status (0 = OK). 
     508   
     509  \b Example 
     510  \code 
     511  // set stepper 1 to half step mode 
     512  Stepper_SetHalfStep(1, 1); 
     513  \endcode 
    416514*/ 
    417515int Stepper_SetHalfStep( int index, int halfStep ) 
     
    433531  @param index An integer specifying which stepper (0 or 1). 
    434532  @return the HalfStep setting. 
     533   
     534  \b Example 
     535  \code 
     536  if( Stepper_GetHalfStep(1) ) 
     537  { 
     538    // stepper 1 is in half step mode 
     539  } 
     540  else 
     541  { 
     542    // stepper 1 is in full step mode 
     543  } 
     544  \endcode 
    435545*/ 
    436546int Stepper_GetHalfStep( int index ) 
     
    11511261      value = Stepper_GetBipolar( index ); 
    11521262      break; 
    1153     case 7: // step 
    1154       value = Stepper_GetStep( index ); 
    1155       break; 
    11561263  } 
    11571264  return value;