stepRocker Open Source TMCL
1.00
|
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"
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 | |
Motor monitoring.
This file contains the SystemControl function which does all necessary motor monitoring tasks.
GetClosedLoopInitFlag | ( | UCHAR | Axis | ) |
Check status of closed-loop initialization.
Axis | Axis number (always 0 with the stepRocker) |
Check if the closed loop function has been initialized.
GetTorqueModeCurrent | ( | UCHAR | Axis | ) |
Read actual torque mode current setting.
Axis | Axis number (always 0 with the stepRocker) |
Read back the actual torque mode current setting.
|
static |
Initialize closed loop.
Axis | Motor 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().
Switch to step/direction mode.
Axis | Axis number (always 0 with the stepRocker) |
Mode | Desired 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)
StartTorqueMode | ( | UCHAR | Axis, |
int | Torque | ||
) |
Run motor in torque mode.
Axis | Axis number (always 0 with stepRocker) |
Torque | Torque 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.
void StopTorqueMode | ( | UCHAR | Axis | ) |
Turn off torque mode.
Axis | Axis number (alwaxs 0 with the stepRocker) |
Switch off the torque mode. Afterwards the motr will be in velocity mode with velocity=0 (stopped).
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.