stepRocker Open Source TMCL
1.00
|
Mini TMCL interpreter. More...
#include <stdlib.h>
#include <stddef.h>
#include "derivative.h"
#include "bits.h"
#include "stepRocker.h"
#include "Commands.h"
#include "Globals.h"
#include "RS485.h"
#include "SysTick.h"
#include "SysControl.h"
#include "TMC4361.h"
#include "TMC262.h"
#include "Eeprom.h"
#include "IO.h"
#include "Can.h"
#include "USB.h"
Macros | |
#define | MAX_PPS_ACC 4194303 |
Maximum possible acceleration/deceleration in PPS/S. | |
Typedefs | |
typedef int(* | PConvertFunction )(int) |
Function pointer type definition for velocity and acceleration conversion functions. | |
Functions | |
static void | RotateRight (void) |
Command ROR (see TMCL manual) More... | |
static void | RotateLeft (void) |
Command ROL. More... | |
static void | MotorStop (void) |
Command MST. More... | |
static void | MoveToPosition (void) |
Command MVP. More... | |
static void | SetAxisParameter (void) |
Command SAP. More... | |
static void | GetAxisParameter (void) |
Command GAP. More... | |
static void | GetVersion (void) |
Command 136 (get version) More... | |
static void | Boot (void) |
Enter bootloader mode. More... | |
static void | SoftwareReset (void) |
TMCL software reset command. More... | |
static void | ExecuteActualCommand (void) |
Execute actual TMCL command. More... | |
void | InitTMCL (void) |
Initialize TMCL interpreter. More... | |
void | ProcessCommand (void) |
Fetch and execute TMCL commands. More... | |
void | SetAccelerationDecelerationParameters (UCHAR Axis) |
Set the acceleration and deceleration parameters of the TMC4361. More... | |
Variables | |
static UCHAR | UARTCmd [9] |
RS485 command buffer. | |
static UCHAR | UARTCount |
RS485 commnd byte counter. | |
static UCHAR | TMCLCommandState |
State of the interpreter. | |
static TTMCLCommand | ActualCommand |
TMCL command to be executed (with all parameters) | |
static TTMCLReply | ActualReply |
Reply of last executed TMCL command. | |
static UCHAR | TMCLReplyFormat |
format of next reply (RF_NORMAL or RF_SPECIAL) | |
static UCHAR | SpecialReply [9] |
buffer for special replies | |
static UCHAR | ResetRequested |
TRUE after executing the software reset command. | |
static UCHAR | ExtendedCANFrame |
TRUE when extended CAN frame used. | |
static UCHAR | RelativePositioningOptionCode [N_O_MOTORS] |
Option code for MVP REL command. | |
static int | VMax [N_O_MOTORS] |
Maximum positioning speed. | |
static PConvertFunction | VelocityToInternal [N_O_MOTORS] |
Pointer to velocity conversion function from PPS to TMC4361. | |
static PConvertFunction | VelocityToUser [N_O_MOTORS] |
Pointer to velocity conversion function from TMC4361 to PPS. | |
static PConvertFunction | AccelerationToInternal [N_O_MOTORS] |
Pointer to acceleration conversion function from PPS to TMC4361. | |
static PConvertFunction | AccelerationToUser [N_O_MOTORS] |
Pointer to acceleration conversion function from TMC4361 to PPS. | |
char | VersionString [] |
Imported version string. | |
Mini TMCL interpreter.
This file all functions necessary to implement a small TMCL interpreter.
|
static |
Enter bootloader mode.
Special command for exiting TMCL and calling the boot loader.
|
static |
Execute actual TMCL command.
Execute the TMCL command that must have been written to the global variable "ActualCommand" before.
|
static |
Command GAP.
GAP (Get Axis Parameter) command (see TMCL manual).
|
static |
Command 136 (get version)
Get the version number (when type==0) or the version string (when type==1).
InitTMCL | ( | void | ) |
Initialize TMCL interpreter.
Intialise the TMCL interpreter. Must be called once at startup.
|
static |
Command MST.
MST (Motor StoP) command (see TMCL manual).
|
static |
Command MVP.
MVP (Move To Position) command (see TMCL manual).
ProcessCommand | ( | void | ) |
Fetch and execute TMCL commands.
This is the main function for fetching and executing TMCL commands and has to be called periodically from the main loop.
|
static |
Command ROL.
ROL (ROtate Left) command (see TMCL manual).
|
static |
Command ROR (see TMCL manual)
ROR (ROtate Right) command (see TMCL manual).
SetAccelerationDecelerationParameters | ( | UCHAR | Axis | ) |
Set the acceleration and deceleration parameters of the TMC4361.
Axis | Axis number (always 0 with the stepRocker) |
This function adapts the acceleration and deceleration parameters in a way that the entire range for accleration and deceleration of the TMC4361 can be used. It bypasses a limitation of the internal parameter conversion of the TMC4361. When one of these parameters is higher than MAX_PPS_ACC we switch to direct acceleration values and do the conversions ourselves here. Otherwise we can turn on the built-in conversion of the TMC4361 and so do not have to do those calculations ourselves. This function gets called by the SetAxisParameter function (SAP command) each time an acceleration or deceleration parameter has been changed by an SAP command.
|
static |
Command SAP.
SAP (Set Axis Parameter) command (see TMCL manual).
|
static |
TMCL software reset command.
Issue a TMCL software reset.