stepRocker Open Source TMCL  1.00
 All Data Structures Files Functions Variables Typedefs Enumerations Macros
Enumerations | Functions | Variables
SysControl.c File Reference

Motor monitoring. More...

#include <limits.h>
#include <stdlib.h>
#include "derivative.h"
#include "bits.h"
#include "stepRocker.h"
#include "Globals.h"
#include "IO.h"
#include "SysTick.h"
#include "TMC4361.h"
#include "TMC262.h"
Include dependency graph for SysControl.c:

Enumerations

enum  TClosedLoopInitState {
  CS_OPENLOOP, CS_START, CS_WAIT_FS, CS_CALIBRATE,
  CS_WAIT_CALIBRATE, CS_CLOSEDLOOP
}
 
enum  TTorqueMode { TQ_MODE_OFF, TQ_MODE_ROL, TQ_MODE_ROR }
 

Functions

void StopTorqueMode (UCHAR Axis)
 Turn off torque mode. More...
 
UCHAR GetClosedLoopInitFlag (UCHAR Axis)
 Check status of closed-loop initialization. More...
 
static void InitClosedLoop (UCHAR Axis)
 Initialize closed loop. More...
 
void SystemControl (void)
 Motor monitoring. More...
 
void SetStepDirMode (UCHAR Axis, UCHAR Mode)
 Switch to step/direction mode. More...
 
void StartTorqueMode (UCHAR Axis, int Torque)
 Run motor in torque mode. More...
 
int GetTorqueModeCurrent (UCHAR Axis)
 Read actual torque mode current setting. More...
 

Variables

static UCHAR ActualAxis
 monitored axis
 
static UINT Delay
 Delay timer.
 
static UCHAR StopOnStallState [N_O_MOTORS]
 status of the stop-on-stall functionality
 
static TClosedLoopInitState ClosedLoopInitState [N_O_MOTORS]
 closed-loop initialization status
 
static UINT ClosedLoopTimer [N_O_MOTORS]
 timer needed for closed-loop initiaization
 
static TTorqueMode TorqueMode [N_O_MOTORS]
 torque mode (FALSE=off, TRUE=on)
 
static int TorqueModeCurrent [N_O_MOTORS]
 desired current in torque mode
 

Detailed Description

Motor monitoring.

Author
Trinamic Motion Control GmbH & Co KG
Version
2.20

This file contains the SystemControl function which does all necessary motor monitoring tasks.

Function Documentation

GetClosedLoopInitFlag ( UCHAR  Axis)

Check status of closed-loop initialization.

Parameters
AxisAxis number (always 0 with the stepRocker)
Returns
TRUE: closed loop is initalized
FALSE: closed loop not initialized

Check if the closed loop function has been initialized.

Here is the caller graph for this function:

GetTorqueModeCurrent ( UCHAR  Axis)

Read actual torque mode current setting.

Parameters
AxisAxis number (always 0 with the stepRocker)
Returns
-255..+255 when in torque mode
0 when not in torque mode

Read back the actual torque mode current setting.

Here is the caller graph for this function:

InitClosedLoop ( UCHAR  Axis)
static

Initialize closed loop.

Parameters
AxisMotor number (always 0 with the stepRocker)

Initalizes or de-initializes the closed loop function of the given axis (depending on MotorConfig.ClosedLoopMode). This function gets called periodically by SystemControl().

Here is the call graph for this function:

Here is the caller graph for this function:

SetStepDirMode ( UCHAR  Axis,
UCHAR  Mode 
)

Switch to step/direction mode.

Parameters
AxisAxis number (always 0 with the stepRocker)
ModeDesired mode

Switch to step/direction mode or back to normal ramp generator mode.
Possible Modes:
0: Ramp generator mode
1: step/direction mode, step pulse are high
2: step/direction mode, step pulse are low
3: step/direction mode, both edges of each step pulse (double speed)
Bit 2: direction signal polarity
Bit 3: indirect mode (ramp generator controlled by step pulses)

Here is the call graph for this function:

Here is the caller graph for this function:

StartTorqueMode ( UCHAR  Axis,
int  Torque 
)

Run motor in torque mode.

Parameters
AxisAxis number (always 0 with stepRocker)
TorqueTorque mode direction and current (-255..+255)

Switch on torque mode and set the torque mode current to be used. This only works in closed loop mode.

Here is the call graph for this function:

Here is the caller graph for this function:

void StopTorqueMode ( UCHAR  Axis)

Turn off torque mode.

Parameters
AxisAxis number (alwaxs 0 with the stepRocker)

Switch off the torque mode. Afterwards the motr will be in velocity mode with velocity=0 (stopped).

Here is the call graph for this function:

Here is the caller graph for this function:

SystemControl ( void  )

Motor monitoring.

This function must be called periodically from the main loop and does some monitoring tasks, e.g. lowering the current after the motor has not been moving for some time.

Here is the call graph for this function:

Here is the caller graph for this function: