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

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"
Include dependency graph for Commands.c:

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.
 

Detailed Description

Mini TMCL interpreter.

Author
Trinamic Motion Control GmbH & Co KG
Version
2.20

This file all functions necessary to implement a small TMCL interpreter.

Function Documentation

static void Boot ( void  )
static

Enter bootloader mode.

Special command for exiting TMCL and calling the boot loader.

Here is the call graph for this function:

Here is the caller graph for this function:

ExecuteActualCommand ( void  )
static

Execute actual TMCL command.

Execute the TMCL command that must have been written to the global variable "ActualCommand" before.

Here is the call graph for this function:

Here is the caller graph for this function:

static void GetAxisParameter ( void  )
static

Command GAP.

GAP (Get Axis Parameter) command (see TMCL manual).

Here is the call graph for this function:

Here is the caller graph for this function:

static void GetVersion ( void  )
static

Command 136 (get version)

Get the version number (when type==0) or the version string (when type==1).

Here is the caller graph for this function:

InitTMCL ( void  )

Initialize TMCL interpreter.

Intialise the TMCL interpreter. Must be called once at startup.

Here is the call graph for this function:

Here is the caller graph for this function:

static void MotorStop ( void  )
static

Command MST.

MST (Motor StoP) command (see TMCL manual).

Here is the call graph for this function:

Here is the caller graph for this function:

static void MoveToPosition ( void  )
static

Command MVP.

MVP (Move To Position) command (see TMCL manual).

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

static void RotateLeft ( void  )
static

Command ROL.

ROL (ROtate Left) command (see TMCL manual).

Here is the call graph for this function:

Here is the caller graph for this function:

static void RotateRight ( void  )
static

Command ROR (see TMCL manual)

ROR (ROtate Right) command (see TMCL manual).

Here is the call graph for this function:

Here is the caller graph for this function:

SetAccelerationDecelerationParameters ( UCHAR  Axis)

Set the acceleration and deceleration parameters of the TMC4361.

Parameters
AxisAxis 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.

Here is the call graph for this function:

Here is the caller graph for this function:

static void SetAxisParameter ( void  )
static

Command SAP.

SAP (Set Axis Parameter) command (see TMCL manual).

Here is the call graph for this function:

Here is the caller graph for this function:

static void SoftwareReset ( void  )
static

TMCL software reset command.

Issue a TMCL software reset.

Here is the caller graph for this function: