Instances of this class handle configuring, and enabling the MityDSP base Stepper Motor Controller core I/O interface. More...
#include <core/DspStepper.h>
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. |
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.
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.
[in] | apAddress | The base address of the GPIO core. |
[in] | apConfig | The configuration structure (optional). |
tcDspStepper::~tcDspStepper | ( | ) |
Destructor.
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.
[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). |
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.
[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. |
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.
[in] | DoneSem | Pointer to application semaphore. Can be NULL (process may be checked by polling on IsBusy(). |
[in] | Pos | Contact to seek. |
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.
[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. |
bool tcDspStepper::GetSwitchCondition | ( | teStepperSwitchPos | Position | ) |
Get Switch Closure Latch State.
[in] | Position | ID to check |
int tcDspStepper::GetStepCounter | ( | void | ) |
Get current value of step counter.
void tcDspStepper::GetTravelResult | ( | unsigned int & | TvlCnt, | |
unsigned int & | Overshoot | |||
) |
Returns the results from the last Move Command (or Locate).
[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. |
bool tcDspStepper::IsBusy | ( | void | ) |
Get state of the motion device.
bool tcDspStepper::GetSwitchLocation | ( | teStepperSwitchPos | Pos, | |
int & | Position | |||
) |
Get the stored location of a contact position.
[in] | Pos | Identity of the switch position to return |
[out] | Position | Position in steps relative to the stepcount of switch. |
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.
[in] | Enable | When true holds controller in reset 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.
[in] | Enable | When true holds controller in sleep 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).
[in] | Enable | When true holds controller in enabled condition. |
bool tcDspStepper::GetReset | ( | void | ) | [virtual] |
Check if motion controller is in Reset condition.
bool tcDspStepper::GetSleep | ( | void | ) | [virtual] |
Check if motion controller is in Sleep condition.
bool tcDspStepper::GetEnable | ( | void | ) | [virtual] |
Check if motion controller is Enabled.
void tcDspStepper::Abort | ( | void | ) | [virtual] |
Terminates any motion command.
void tcDspStepper::SetClockFreq | ( | float | Value_Hz | ) |
Set the base frequency of the controller.
[in] | Value_Hz | The base clock frequency |
float tcDspStepper::GetClockFreq | ( | void | ) |
Get the base frequency of the controller.
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.
[in] | NumCycles | Number of cycles to retry (minimum = 0). |
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.
[in] | Pos | The switch position to override. |
[in] | Position | The position of the switch being overridden. |
void tcDspStepper::SetContinuousMode | ( | bool | Enable | ) | [virtual] |
Enable/Disable Continuous running of motor.
The motor will ignor the travel count command and run forever until:
[in] | Enable | true to enable continuous mode, false to disable it |
void tcDspStepper::ClearContactLatches | ( | void | ) |
Clear latched contact states from status.
If any contact is active, the latches will relatch and read 1 immediately.
bool tcDspStepper::ReadyToMove | ( | void | ) | [virtual] |
Check if motion controller is ready to execute a motion command.
teStepperMicroStepSize tcDspStepper::GetMicroStepSize | ( | void | ) | [virtual] |
Get the MicroStepping size of the attached controller.
bool tcDspStepper::SetMicroStepSize | ( | teStepperMicroStepSize | Size | ) | [virtual] |
Set the MicroStepping size of the attached controller.
[in] | Size | The new step size for the controller. |
teStepperCurrentLevel tcDspStepper::GetCurrentLevel | ( | void | ) | [virtual] |
Get the High Current Setting of the attached controller.
bool tcDspStepper::SetCurrentLevel | ( | teStepperCurrentLevel | Current | ) | [virtual] |
Set the High Current Setting of the attached controller.
[in] | Current | The new current level setting |
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.
[in] | ahMyObject | The "this->" pointer for the instance of tcDspStepper associated with this ISR. |
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.
unsigned int MityDSP::tcDspStepper::mnInterruptCount |
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.
int MityDSP::tcDspStepper::mnMyIntLevel [protected] |
PWM Core interrupt level.
int MityDSP::tcDspStepper::mnMyIntVector [protected] |
PWM Core interrupt vector.
float MityDSP::tcDspStepper::mnBaseClockFreq [protected] |
Hz.
bool MityDSP::tcDspStepper::mbAutoDisable [protected] |
when true, controller will disable outputs upon cmd completion
int MityDSP::tcDspStepper::mnStartPosition [protected] |
the value of the counter at start of command
teStepperDir MityDSP::tcDspStepper::meInitialDir [protected] |
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.