MityDSP Documentation Index

MityDSP::tcDspStepper Class Reference

Instances of this class handle configuring, and enabling the MityDSP base Stepper Motor Controller core I/O interface. More...

#include <core/DspStepper.h>

List of all members.

Public Member Functions

 tcDspStepper (void *apAddress, tcDspStepperConfig *=NULL)
 This constructor is used to open a Stepper core instance.
 ~tcDspStepper ()
 Destructor.
virtual int SetPulseParams (unsigned int MinPulseRate, unsigned int MaxPulseRate, unsigned int AccelRate)
 Configure the minimum and maximum pulse rate, and set the acceleration parameter used when transitioning to and from steady state conditions.
virtual int LocateSwitchPosition (SEM_Handle *DoneSem, teStepperSwitchPos Pos, teStepperDir TravelDir=eeFORWARD)
 Locate a specified switch contact position.
virtual int GotoSwitchPosition (SEM_Handle *DoneSem, teStepperSwitchPos Pos)
 Move to a specified switch contact position.
virtual int Move (SEM_Handle *DoneSem, teStepperDir aeDir, unsigned int TvlCnt, teStepperSwitchPos StopPos=eeNONE, bool HardStop=false)
 Move to a specified location.
bool GetSwitchCondition (teStepperSwitchPos Position)
 Get Switch Closure Latch State.
int GetStepCounter (void)
 Get current value of step counter.
void GetTravelResult (unsigned int &TvlCnt, unsigned int &Overshoot)
 Returns the results from the last Move Command (or Locate).
bool IsBusy (void)
 Get state of the motion device.
bool GetSwitchLocation (teStepperSwitchPos Pos, int &Position)
 Get the stored location of a contact position.
virtual void SetReset (bool Enable)
 Force a reset to the stepper controller.
virtual void SetSleep (bool Enable)
 Force the stepper controller to enter a low power sleep mode.
virtual void SetEnable (bool Enable)
 Enable the Stepper Outputs.
virtual bool GetReset (void)
 Check if motion controller is in Reset condition.
virtual bool GetSleep (void)
 Check if motion controller is in Sleep condition.
virtual bool GetEnable (void)
 Check if motion controller is Enabled.
virtual void Abort (void)
 Terminates any motion command.
void SetClockFreq (float Value_Hz)
 Set the base frequency of the controller.
float GetClockFreq (void)
 Get the base frequency of the controller.
void SetNumCyclesOnSeek (int NumCycles)
 Sets the number of iterations that a motor will try to seek to a switch position in the event of overshooting.
void SetSwitchLocation (teStepperSwitchPos Pos, int Position)
 Provides capability for software to override switch locations.
virtual void SetContinuousMode (bool Enable)
 Enable/Disable Continuous running of motor.
void ClearContactLatches (void)
 Clear latched contact states from status.
virtual bool ReadyToMove (void)
 Check if motion controller is ready to execute a motion command.
virtual teStepperMicroStepSize GetMicroStepSize (void)
 Get the MicroStepping size of the attached controller.
virtual bool SetMicroStepSize (teStepperMicroStepSize Size)
 Set the MicroStepping size of the attached controller.
virtual teStepperCurrentLevel GetCurrentLevel (void)
 Get the High Current Setting of the attached controller.
virtual bool SetCurrentLevel (teStepperCurrentLevel Current)
 Set the High Current Setting of the attached controller.

Public Attributes

unsigned int mnInterruptCount
 for debug

Protected Member Functions

void StepperISRHandler (void)
 Stepper Controller ISR handler (object method).

Static Protected Member Functions

static int interrupt_dispatch (Arg ahMyObject)
 Static interrupt dispatch routine.

Protected Attributes

unsigned int mnNumSeekCycles
 number of iterations to gyrate on contact position
volatile bool mbBusy
 when true, a command is still being processed
teStepperCommand meCurrentCommand
 current operation being performed
SEM_Handle * mpActiveUserSem
 Pointer to user register semaphore for current command.
SEM_Handle mhMySemaphore
 Pointer to internal semaphore for controller interrupts.
volatile unsigned int * mpMyBaseReg
 PWM Core base register.
unsigned short mnMyIntMask
 PWM Core interrupt mask.
int mnMyIntLevel
 PWM Core interrupt level.
int mnMyIntVector
 PWM Core interrupt vector.
float mnBaseClockFreq
 Hz.
bool mbAutoDisable
 when true, controller will disable outputs upon cmd completion
int mnStartPosition
 the value of the counter at start of command
teStepperDir meInitialDir
 initial direction of command
unsigned int mnCyclesRun
 number of cycles currently executed
volatile int maHomePositions [DSP_STEPPER_NUM_HOME_POS]
 tracks last known location of given home position
volatile bool maHomePositionValid [DSP_STEPPER_NUM_HOME_POS]
 when true, indicates position was located since init.

Detailed Description

Instances of this class handle configuring, and enabling the MityDSP base Stepper Motor Controller core I/O interface.

Each Stepper Core provides for motion control of 1 discrete motor. The routing of the motor pulse outputs is application specific. See the application FPGA hardware design notes for further information.

See also:
tcDspStepper Page

Constructor & Destructor Documentation

tcDspStepper::tcDspStepper ( void *  apAddress,
tcDspStepperConfig apConfig = NULL 
)

This constructor is used to open a Stepper core instance.

The base address and default configuration data are provided.

Parameters:
[in] apAddress The base address of the GPIO core.
[in] apConfig The configuration structure (optional).
Returns:
None.
See also:
DspStepper.h
tcDspStepper::~tcDspStepper (  ) 

Destructor.


Member Function Documentation

int tcDspStepper::SetPulseParams ( unsigned int  MinPulseRate,
unsigned int  MaxPulseRate,
unsigned int  AccelRate 
) [virtual]

Configure the minimum and maximum pulse rate, and set the acceleration parameter used when transitioning to and from steady state conditions.

Parameters:
[in] MinPulseRate Initial pulse rate (Hz) applied immediately following start of motion or immediately prior to stop of motion. (must be > 0)
[in] MaxPulseRate Maximum pulse rate (Hz)applied for motion. (must be >= MinPulseRate)
[in] AccelRate Rate at which stepper pulse output rate will be increased (Hz/sec) during initial acceleration and final deceleration. (can be 0 if MaxPulseRate=MinPulseRate, otherwise should be Non-Zero).
Returns:
0 on success. Non-Zero for invalid parameters or if unit is Busy.
Note:
Due to clock quantization, the closest possible values to those specified will be applied. Use GetPulseParams() to determine exact values assigned.
int tcDspStepper::LocateSwitchPosition ( SEM_Handle *  DoneSem,
teStepperSwitchPos  Pos,
teStepperDir  TravelDir = eeFORWARD 
) [virtual]

Locate a specified switch contact position.

This command will cause the motor to seek a contact position over the entire distance of travel. The module will first move in the direction specified by traveldir until it reaches the contact position. If the contact was seen but overshot (due to decelerration), the unit will reverse direction and proceed at half speed to try to stop directly on the constact position. This will continue until the number of cycles on seek (see SetNumCyclesOnSeek() has expired. Following a successful seek the GetSwitchLocation() call will return true.

If the contact was not seen and the motor reaches the end of travel, the direction will be reversed and the process repeated. If the motor reaches the end of travel in the other direction or an ESTOP condition is detected, then the process is terminated.

Upon completion of the process, the DoneSem will be flagged.

Parameters:
[in] DoneSem Pointer to application semaphore. Can be NULL (process may be checked by polling on IsBusy().
[in] Pos Contact to seek.
[in] TravelDir Initial direction to seek.
Returns:
0 on successful initiation of command. Non-Zero for invalid parameters or if unit is Busy.
Note:
eeSTOP is an illegal parameter for this operation.
it may be advisable to use a slower speed for this process in order to reduce the intertia upon indicent on the end of the travel bounds.
int tcDspStepper::GotoSwitchPosition ( SEM_Handle *  DoneSem,
teStepperSwitchPos  Pos 
) [virtual]

Move to a specified switch contact position.

This command will cause the motor to travel to move to a specified contact position: if the contact position was successfully determined using LocateSwitchPosition(), the controller will compute the travel distance and direction based on the current step count and initiate motion to that step location. If the contact position was not previously determined, this routine will return immediately will a failed code. This process will also terminate if the ESTOP condition is detected or a end travel condition is detected.

Upon completion of the process, the DoneSem will be flagged.

Parameters:
[in] DoneSem Pointer to application semaphore. Can be NULL (process may be checked by polling on IsBusy().
[in] Pos Contact to seek.
Returns:
0 on successful initiation of command. Non-Zero for if Pos location is unknown.
Note:
eeSTOP is an illegal parameter for this operation.
Users of this command may wish to check it the desired contact was latched to ensure that the motor did indeed travel to the correct switch location.
Motion will also terminate if the desired switch location was latched prior to reaching the stored step location. To check for this condition, use GetTravelResults and check for non-zero Overshoot.
int tcDspStepper::Move ( SEM_Handle *  DoneSem,
teStepperDir  aeDir,
unsigned int  TvlCnt,
teStepperSwitchPos  StopPos = eeNONE,
bool  HardStop = false 
) [virtual]

Move to a specified location.

This command will cause the motor to travel a specified number of microstep counts. Optionally, the user may request early termination upon detection of a switch contact.

Upon completion of the process, the DoneSem will be flagged.

Parameters:
[in] DoneSem Pointer to application semaphore. Can be NULL (process may be checked by polling on IsBusy().
[in] aeDir This direction to move.
[in] TvlCnt The number of counts to travel, must be less than or equal to TVL_MAX_COUNT. If TVL_CONTINUOUS, the motor will travel until aborted or a stop condition (ESTOP or boundary stop) is detected.
[in] StopPos Optional stop contact closure sense.
[in] HardStop If this option is set, the motor controller will not decelerate the pulse rate if the specified StopPos contact closure is sensed, but rather stop immediately.
Returns:
0 on successful initiation of command. Non-Zero on error.
Note:
eeSTOP is an illegal parameter for this operation.
bool tcDspStepper::GetSwitchCondition ( teStepperSwitchPos  Position  ) 

Get Switch Closure Latch State.

Parameters:
[in] Position ID to check
Returns:
true if the the contact was closed and latched.
int tcDspStepper::GetStepCounter ( void   ) 

Get current value of step counter.

Returns:
counter value
void tcDspStepper::GetTravelResult ( unsigned int &  TvlCnt,
unsigned int &  Overshoot 
)

Returns the results from the last Move Command (or Locate).

Parameters:
[out] TvlCnt The number of steps traveled in the command
[out] Overshoot The number of steps overshot from a specified sensed contact. If a specifiec contact was not detected in the move or no contact was specified, then the Overshoot is 0. If the last command was a Locate or Seek, the Overshoot will be the amount of steps of overshoot from the last executed iteration.
Returns:
None
Note:
This routine assumes that the travel did not exceed the maximum count size (2^32).
bool tcDspStepper::IsBusy ( void   ) 

Get state of the motion device.

Returns:
true if the motion controller is Busy. False if it is idle.
bool tcDspStepper::GetSwitchLocation ( teStepperSwitchPos  Pos,
int &  Position 
)

Get the stored location of a contact position.

Parameters:
[in] Pos Identity of the switch position to return
[out] Position Position in steps relative to the stepcount of switch.
Returns:
true if the position data is valid. false if the position data has not been validated.
Note:
This will return unknown results if the contact position has never been located since power up.
void tcDspStepper::SetReset ( bool  Enable  )  [virtual]

Force a reset to the stepper controller.

If a command is currently being executed, the command will be aborted prior to issuing the reset control.

Parameters:
[in] Enable When true holds controller in reset condition.
Returns:
None.
Note:
While in reset, the stepper controller will not assert any holding voltages on the coil outputs. The stepper will "free wheel" in this condition.
void tcDspStepper::SetSleep ( bool  Enable  )  [virtual]

Force the stepper controller to enter a low power sleep mode.

If a command is currently being executed, the command will be aborted prior to issuing the reset control.

Parameters:
[in] Enable When true holds controller in sleep condition.
Returns:
None.
Note:
While in reset, the stepper controller will not assert any holding voltages on the coil outputs. The stepper will "free wheel" in this condition.
void tcDspStepper::SetEnable ( bool  Enable  )  [virtual]

Enable the Stepper Outputs.

This routine may be called to energize the stepper output coils while not executing a motion command. Any motion commands which may be running are aborted if this call is made (the motion methods provided automatically control the enable lines upon command startup).

Parameters:
[in] Enable When true holds controller in enabled condition.
Returns:
None.
bool tcDspStepper::GetReset ( void   )  [virtual]

Check if motion controller is in Reset condition.

Returns:
true if reset condition is active
bool tcDspStepper::GetSleep ( void   )  [virtual]

Check if motion controller is in Sleep condition.

Returns:
true if sleep condition is active.
bool tcDspStepper::GetEnable ( void   )  [virtual]

Check if motion controller is Enabled.

Returns:
true if enabled
void tcDspStepper::Abort ( void   )  [virtual]

Terminates any motion command.

Returns:
None
void tcDspStepper::SetClockFreq ( float  Value_Hz  ) 

Set the base frequency of the controller.

Parameters:
[in] Value_Hz The base clock frequency
Returns:
None.
float tcDspStepper::GetClockFreq ( void   ) 

Get the base frequency of the controller.

Returns:
The base clock frequency [Hz]
void tcDspStepper::SetNumCyclesOnSeek ( int  NumCycles  ) 

Sets the number of iterations that a motor will try to seek to a switch position in the event of overshooting.

Parameters:
[in] NumCycles Number of cycles to retry (minimum = 0).
Returns:
None
void tcDspStepper::SetSwitchLocation ( teStepperSwitchPos  Pos,
int  Position 
)

Provides capability for software to override switch locations.

Useful if switch positions are known and relocating them is not required.

Parameters:
[in] Pos The switch position to override.
[in] Position The position of the switch being overridden.
Returns:
None.
Warning:
Incorrect use of this routine may result in unknown behaviour of the controller.
void tcDspStepper::SetContinuousMode ( bool  Enable  )  [virtual]

Enable/Disable Continuous running of motor.

The motor will ignor the travel count command and run forever until:

  • a boundary contact is hit
  • an ESTOP condition is detected
  • the user disables the motor
Parameters:
[in] Enable true to enable continuous mode, false to disable it
Returns:
None.
void tcDspStepper::ClearContactLatches ( void   ) 

Clear latched contact states from status.

If any contact is active, the latches will relatch and read 1 immediately.

Returns:
None.
bool tcDspStepper::ReadyToMove ( void   )  [virtual]

Check if motion controller is ready to execute a motion command.

Returns:
true if reset is disabled, enable is enabled, and sleep is disabled and not busy with another command.
teStepperMicroStepSize tcDspStepper::GetMicroStepSize ( void   )  [virtual]

Get the MicroStepping size of the attached controller.

Returns:
The stepping size of the controller
bool tcDspStepper::SetMicroStepSize ( teStepperMicroStepSize  Size  )  [virtual]

Set the MicroStepping size of the attached controller.

Parameters:
[in] Size The new step size for the controller.
Returns:
true for sucessful change false for failure
teStepperCurrentLevel tcDspStepper::GetCurrentLevel ( void   )  [virtual]

Get the High Current Setting of the attached controller.

Returns:
the current value type of the controller
bool tcDspStepper::SetCurrentLevel ( teStepperCurrentLevel  Current  )  [virtual]

Set the High Current Setting of the attached controller.

Parameters:
[in] Current The new current level setting
Returns:
true if setting was changed false if failed
int tcDspStepper::interrupt_dispatch ( Arg  ahMyObject  )  [static, protected]

Static interrupt dispatch routine.

Required because of the hidden this pointer associated with a member function, which cannot be passed directly to the interrupt dispatcher.

Parameters:
[in] ahMyObject The "this->" pointer for the instance of tcDspStepper associated with this ISR.
Returns:
0
void tcDspStepper::StepperISRHandler ( void   )  [protected]

Stepper Controller ISR handler (object method).

This function is called to handle interrupts issued by the stepper controller. The ISR is will handle Move and Goto commands by simply clearing the busy state and clearing the pending interrupt from the stepper core. For Seek commands, the ISR will perform the needed logic to determine/store detected contact positions or re-initiate move commands as required to complete the Seek operation.

Returns:
None

Member Data Documentation

for debug

unsigned int MityDSP::tcDspStepper::mnNumSeekCycles [protected]

number of iterations to gyrate on contact position

volatile bool MityDSP::tcDspStepper::mbBusy [protected]

when true, a command is still being processed

current operation being performed

SEM_Handle* MityDSP::tcDspStepper::mpActiveUserSem [protected]

Pointer to user register semaphore for current command.

SEM_Handle MityDSP::tcDspStepper::mhMySemaphore [protected]

Pointer to internal semaphore for controller interrupts.

volatile unsigned int* MityDSP::tcDspStepper::mpMyBaseReg [protected]

PWM Core base register.

unsigned short MityDSP::tcDspStepper::mnMyIntMask [protected]

PWM Core interrupt mask.

PWM Core interrupt level.

PWM Core interrupt vector.

Hz.

when true, controller will disable outputs upon cmd completion

the value of the counter at start of command

initial direction of command

unsigned int MityDSP::tcDspStepper::mnCyclesRun [protected]

number of cycles currently executed

volatile int MityDSP::tcDspStepper::maHomePositions[DSP_STEPPER_NUM_HOME_POS] [protected]

tracks last known location of given home position

volatile bool MityDSP::tcDspStepper::maHomePositionValid[DSP_STEPPER_NUM_HOME_POS] [protected]

when true, indicates position was located since init.


  
Generated on Fri Sep 23 16:33:55 2011 for MityDSP Core by  Doxygen Version 1.6.1
Copyright © 2009, Critical Link LLC, All rights reserved.