Robotique FIP / Easyspin_lib

Fork of Easyspin_lib by Julien Tiron

Embed: (wiki syntax)

« Back to documentation index

Shield control functions

Shield control functions

Functions

void AttachFlagInterrupt (void(*callback)(void))
 Attaches a user callback to the flag Interrupt The call back will be then called each time the status flag pin will be pulled down due to the occurrence of a programmed alarms ( OCD, thermal pre-warning or shutdown, UVLO, wrong command, non-performable command)
void Begin (uint8_t nbShields)
 Starts the Easyspin library.
uint16_t GetAcceleration (uint8_t shieldId)
 Returns the acceleration of the specified shield.
uint16_t GetCurrentSpeed (uint8_t shieldId)
 Returns the current speed of the specified shield.
uint16_t GetDeceleration (uint8_t shieldId)
 Returns the deceleration of the specified shield.
shieldState_t GetShieldState (uint8_t shieldId)
 Returns the shield state.
uint8_t GetFwVersion (void)
 Returns the FW version of the library.
int32_t GetMark (uint8_t shieldId)
 Returns the mark position of the specified shield.
uint16_t GetMaxSpeed (uint8_t shieldId)
 Returns the max speed of the specified shield.
uint16_t GetMinSpeed (uint8_t shieldId)
 Returns the min speed of the specified shield.
int32_t GetPosition (uint8_t shieldId)
 Returns the ABS_POSITION of the specified shield.
void GoHome (uint8_t shieldId)
 Requests the motor to move to the home position (ABS_POSITION = 0)
void GoMark (uint8_t shieldId)
 Requests the motor to move to the mark position.
void GoTo (uint8_t shieldId, int32_t targetPosition)
 Requests the motor to move to the specified position.
void HardStop (uint8_t shieldId)
 Immediatly stops the motor and disable the power bridge.
void Move (uint8_t shieldId, dir_t direction, uint32_t stepCount)
 Moves the motor of the specified number of steps.
void ResetAllShields (void)
 Resets all Easyspin shields.
void Run (uint8_t shieldId, dir_t direction)
 Runs the motor.
bool SetAcceleration (uint8_t shieldId, uint16_t newAcc)
 Changes the acceleration of the specified shield.
bool SetDeceleration (uint8_t shieldId, uint16_t newDec)
 Changes the deceleration of the specified shield.
void SetHome (uint8_t shieldId)
 Set current position to be the Home position (ABS pos set to 0)
void SetMark (uint8_t shieldId)
 Sets current position to be the Mark position.
bool SetMaxSpeed (uint8_t shieldId, uint16_t newMaxSpeed)
 Changes the max speed of the specified shield.
bool SetMinSpeed (uint8_t shieldId, uint16_t newMinSpeed)
 Changes the min speed of the specified shield.
bool SoftStop (uint8_t shieldId)
 Stops the motor by using the shield deceleration.
void WaitWhileActive (uint8_t shieldId)
 Locks until the shield state becomes Inactive.
void Turn (rot_t rotation, uint16_t angle)
 Turn left or right with the specified angle.
void Move_cm (dir_t direction, uint16_t distance)
 Move forward or backward with the specified distance.

Function Documentation

void AttachFlagInterrupt ( void(*)(void)  callback ) [inherited]

Attaches a user callback to the flag Interrupt The call back will be then called each time the status flag pin will be pulled down due to the occurrence of a programmed alarms ( OCD, thermal pre-warning or shutdown, UVLO, wrong command, non-performable command)

Parameters:
[in]callbackName of the callback to attach to the Flag Interrupt
Return values:
None

Definition at line 54 of file easyspin.cpp.

void Begin ( uint8_t  nbShields ) [inherited]

Starts the Easyspin library.

Parameters:
[in]nbShieldsNumber of Easyspin shields to use (from 1 to 3)
Return values:
None

Definition at line 64 of file easyspin.cpp.

uint16_t GetAcceleration ( uint8_t  shieldId ) [inherited]

Returns the acceleration of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
Accelerationin pps^2

Definition at line 118 of file easyspin.cpp.

uint16_t GetCurrentSpeed ( uint8_t  shieldId ) [inherited]

Returns the current speed of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
Speedin pps

Definition at line 128 of file easyspin.cpp.

uint16_t GetDeceleration ( uint8_t  shieldId ) [inherited]

Returns the deceleration of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
Decelerationin pps^2

Definition at line 138 of file easyspin.cpp.

uint8_t GetFwVersion ( void   ) [inherited]

Returns the FW version of the library.

Parameters:
None
Return values:
Easyspin_FW_VERSION

Definition at line 148 of file easyspin.cpp.

int32_t GetMark ( uint8_t  shieldId ) [inherited]

Returns the mark position of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
Markregister value converted in a 32b signed integer

Definition at line 158 of file easyspin.cpp.

uint16_t GetMaxSpeed ( uint8_t  shieldId ) [inherited]

Returns the max speed of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
maxSpeedin pps

Definition at line 168 of file easyspin.cpp.

uint16_t GetMinSpeed ( uint8_t  shieldId ) [inherited]

Returns the min speed of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
minSpeedin pps

Definition at line 178 of file easyspin.cpp.

int32_t GetPosition ( uint8_t  shieldId ) [inherited]

Returns the ABS_POSITION of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
ABS_POSITIONregister value converted in a 32b signed integer

Definition at line 188 of file easyspin.cpp.

shieldState_t GetShieldState ( uint8_t  shieldId ) [inherited]

Returns the shield state.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
State(ACCELERATING, DECELERATING, STEADY or INACTIVE)

Definition at line 198 of file easyspin.cpp.

void GoHome ( uint8_t  shieldId ) [inherited]

Requests the motor to move to the home position (ABS_POSITION = 0)

Parameters:
[in]shieldId(from 0 to 2)
Return values:
None

Definition at line 208 of file easyspin.cpp.

void GoMark ( uint8_t  shieldId ) [inherited]

Requests the motor to move to the mark position.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
None

Definition at line 218 of file easyspin.cpp.

void GoTo ( uint8_t  shieldId,
int32_t  targetPosition 
) [inherited]

Requests the motor to move to the specified position.

Parameters:
[in]shieldId(from 0 to 2)
[in]targetPositionabsolute position in steps
Return values:
None

Definition at line 232 of file easyspin.cpp.

void HardStop ( uint8_t  shieldId ) [inherited]

Immediatly stops the motor and disable the power bridge.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
None

Definition at line 276 of file easyspin.cpp.

void Move ( uint8_t  shieldId,
dir_t  direction,
uint32_t  stepCount 
) [inherited]

Moves the motor of the specified number of steps.

Parameters:
[in]shieldId(from 0 to 2)
[in]directionFORWARD or BACKWARD
[in]stepCountNumber of steps to perform
Return values:
None

Definition at line 301 of file easyspin.cpp.

void Move_cm ( dir_t  direction,
uint16_t  distance 
) [inherited]

Move forward or backward with the specified distance.

Parameters:
[in]directionFORWARD or BACKWARD
[in]distancein cm
Return values:
None

Definition at line 350 of file easyspin.cpp.

void ResetAllShields ( void   ) [inherited]

Resets all Easyspin shields.

Parameters:
None
Return values:
None

Definition at line 367 of file easyspin.cpp.

void Run ( uint8_t  shieldId,
dir_t  direction 
) [inherited]

Runs the motor.

It will accelerate from the min speed up to the max speed by using the shield acceleration.

Parameters:
[in]shieldId(from 0 to 2)
[in]directionFORWARD or BACKWARD
Return values:
None

Definition at line 387 of file easyspin.cpp.

bool SetAcceleration ( uint8_t  shieldId,
uint16_t  newAcc 
) [inherited]

Changes the acceleration of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
[in]newAccNew acceleration to apply in pps^2
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the shield is executing a MOVE or GOTO command (but it can be used during a RUN command)

Definition at line 411 of file easyspin.cpp.

bool SetDeceleration ( uint8_t  shieldId,
uint16_t  newDec 
) [inherited]

Changes the deceleration of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
[in]newDecNew deceleration to apply in pps^2
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the shield is executing a MOVE or GOTO command (but it can be used during a RUN command)

Definition at line 431 of file easyspin.cpp.

void SetHome ( uint8_t  shieldId ) [inherited]

Set current position to be the Home position (ABS pos set to 0)

Parameters:
[in]shieldId(from 0 to 2)
Return values:
None

Definition at line 448 of file easyspin.cpp.

void SetMark ( uint8_t  shieldId ) [inherited]

Sets current position to be the Mark position.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
None

Definition at line 458 of file easyspin.cpp.

bool SetMaxSpeed ( uint8_t  shieldId,
uint16_t  newMaxSpeed 
) [inherited]

Changes the max speed of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
[in]newMaxSpeedNew max speed to apply in pps
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the shield is executing a MOVE or GOTO command (but it can be used during a RUN command).

Definition at line 472 of file easyspin.cpp.

bool SetMinSpeed ( uint8_t  shieldId,
uint16_t  newMinSpeed 
) [inherited]

Changes the min speed of the specified shield.

Parameters:
[in]shieldId(from 0 to 2)
[in]newMinSpeedNew min speed to apply in pps
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the shield is executing a MOVE or GOTO command (but it can be used during a RUN command).

Definition at line 494 of file easyspin.cpp.

bool SoftStop ( uint8_t  shieldId ) [inherited]

Stops the motor by using the shield deceleration.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
trueif the command is successfully executed, else false
Note:
The command is not performed is the shield is in INACTIVE state.

Definition at line 514 of file easyspin.cpp.

void Turn ( rot_t  rotation,
uint16_t  angle 
) [inherited]

Turn left or right with the specified angle.

Parameters:
[in]rotationRIGHT or LEFT
[in]anglein degrees
Return values:
None

Definition at line 332 of file easyspin.cpp.

void WaitWhileActive ( uint8_t  shieldId ) [inherited]

Locks until the shield state becomes Inactive.

Parameters:
[in]shieldId(from 0 to 2)
Return values:
None

Definition at line 529 of file easyspin.cpp.