TG Motion  version 502 - 4034/906 cnc 126
tgm.h File Reference

Main include file for TG Motion. Can be used as the only include for virtual PLC projects. More...

#include <cstdint>
#include <cstddef>
#include <atomic>
#include "tgm_compiler.h"
#include "tgm_os.h"
#include "tgm_hosts.h"

Classes

struct  HEADER
 The HEADER struct - fixed size 128 bytes. More...
 
struct  MAIN
 The MAIN struct - fixed size of 4096 bytes. More...
 
struct  OSC_EX_TRIGGER
 
struct  OSC_EX
 
struct  RESERVE_MAIN
 reserve the MAIN structure to 3072 bytes More...
 
struct  ETH_CONNECTION
 
struct  ETH
 
struct  TIMERS
 Timers with fixed 1ms period. More...
 
struct  CHANNEL
 One oscilloscope channel definition. More...
 
struct  OSC
 Oscilloscope control. More...
 
struct  EEPROM_CONTROL
 
struct  EEPROM
 
struct  SYSTEM
 Shared memory named "TGM_System". More...
 
struct  PG
 Profile generator. More...
 
struct  GEAR
 Gear generator. More...
 
struct  CAPTURE
 Capture position from servo. More...
 
struct  MAP_CNC
 Maps interpolator axis to servo drive. More...
 
struct  SDO
 SDO object communication. More...
 
struct  EXT_SDO
 Extended SDO object communication (GENERAL_DEVICES only) More...
 
struct  ECAT_REGISTER
 EtherCAT registers communication. More...
 
struct  COMMAND
 Servo command. More...
 
struct  SERVO
 Describes one servo drive (or axis) More...
 
struct  DIO
 Describes one servo input/output module. More...
 
struct  GENERAL_DEVICE
 Describes one general module. More...
 
struct  GENERAL_MEMORY
 Memory contains general devices (handled by PLC) More...
 
struct  INTERPOLATOR_LOOK_AHEAD_ENTRY
 Stores informations about CNC code parts ahead of the actual one. More...
 
struct  INTERPOLATOR_LOOK_AHEAD_BUFFER
 Lookahead informations about the G-code. More...
 
struct  CONT_MFUNC_HISTORY
 History of continuous M functions. More...
 
struct  INTERPOLATOR
 Interface to interpolator. More...
 
struct  PLC_LARGE_INTEGER
 
struct  PLC_IMPORT_FUNCTIONS
 Pointers to auxiliary functions usable in Virtual PLC. More...
 
struct  RECEIVE_DATA_CAN
 One entry of incoming CAN data. More...
 
struct  PLC_DATA
 main structure for communication between TGMotion and Virtual PLC More...
 

Typedefs

typedef int32_t PLC_CDECL RTWPRINTF_STRING_SEVERITY(uint32_t id_and_severity, TGM_LPCTSTR strText)
 Output string to console. More...
 
typedef void PLC_CDECL SLEEPFT(PLC_LARGE_INTEGER *Pause)
 Wait for specified time. Do not use in Program_04() ! More...
 
typedef int32_t PLC_CDECL CAN_TRANSMIT(uint32_t Number, uint32_t Id, uint32_t Dlc, uint8_t *Tx_Data)
 Send CAN message. More...
 
typedef int32_t PLC_CDECL CAN_TRANSMITREMOTE(uint32_t Number, uint32_t Id, uint32_t Dlc, uint8_t *Tx_Data)
 Send CAN remote message. More...
 
typedef intptr_t PLC_CDECL GET_FUNCTION_OR_INFO(const char *mangled_function_name, uint32_t opmode)
 Function to get additional function pointer for PLC programs. More...
 
typedef TGM_LPCSTR PLC_CDECL GET_DEVICE_INFO(void)
 Function to get textual info about the host system. More...
 
using PPLC_DATA = PLC_DATA *
 pointer to PLC_DATA
 

Enumerations

enum class  SERVO_TYPE : uint32_t {
  VIRTUAL = 0U ,
  SERVOSTAR_300_700 = 3U ,
  AKD = 5U ,
  AKD2G_SINGLE_AXIS = 51U ,
  AKD2G_DUAL_AXIS = 52U ,
  TGZ = 9U ,
  TGZ_MOTION = 91U ,
  TGM_CONTROLLER = 92U ,
  TGZ_IO_REMAPPED = 93U ,
  TGZ_MOTION_IO_REMAPPED = 94U ,
  TGM_CONTROLLER_IO_REMAPPED = 95U ,
  TGZ_COE = 99U ,
  INVALID = 0xFFFFU
}
 
enum class  DIO_TYPE : uint32_t {
  TG_IO_TYPE_BASIC = 0x0000U ,
  TG_IO_TENZOMETER = 0x0008U ,
  TG_IO_TYPE_NEW = 0x0014U ,
  TG_IO_TYPE_BASIC_LITE = 0x00E0U ,
  TG_IO_TYPE_NEW_LITE = 0x00F4U ,
  PIERCE_IO_TYPE_149D = 0x0007U ,
  PIERCE_IO_TYPE_147D = 0x000FU ,
  PIERCE_IO_TYPE_149E = 0x0017U ,
  PIERCE_IO_TYPE_147E = 0x001FU ,
  BECKHOFF_IO_TYPE_BK1120 = 0x0100U ,
  BR_IO_TYPE = 0x0200U ,
  FESTO_IO_TYPE = 0x0400U ,
  TENZO_IO_TYPE = 0x0800U ,
  TGM_MINI_DIO_TYPE = 0x1000U ,
  BECKHOFF_IO_TYPE_EL1100 = 0x2000U ,
  DFC_IO_TYPE = 0x7B90U ,
  IO_TYPE_INVALID = 0xFFFEU
}
 EtherCAT DIO types. Found automatically and set to DIO::Type variable. More...
 
enum class  SHARED_MEMORY : uint32_t {
  SYSTEM = 0U ,
  DATA = 1U ,
  CAM_PROFILE = 2U ,
  OSCILLOSCOPE = 3U ,
  SERVO = 4U ,
  DIO = 5U ,
  GENERAL = 6U ,
  INTERPOLATOR = 7U ,
  INTERPOLATOR_WRITE = 8U ,
  INTERPOLATOR_READ = 9U ,
  ODS = 10U ,
  CNC_ODS = 11U ,
  CNC_EX = 12U ,
  LAST_MEMORY_IDX = 13U
}
 Memory numbers (types) More...
 
enum class  OSC_DATA_TYPE : uint32_t {
  I32_DEC = 0U ,
  I32_HEX = 1U ,
  I32_BIN = 2U ,
  UI32_DEC = 3U ,
  I64_DEC = 4U ,
  I64_HEX = 5U ,
  I64_BIN = 6U ,
  UI64_DEC = 7U ,
  DOUBLE = 8U ,
  FLOAT = 9U ,
  ASTRING = 10U ,
  WSTRING = 11U ,
  I32_BIN_EX = 12U ,
  I64_BIN_EX = 13U
}
 Oscilloscope data types. More...
 
enum class  INTERPOLATOR_COMMANDS : int32_t {
  NONE_00 = 0 ,
  SET_AXIS_RATIO_1024 = 1024 ,
  SET_COORDS_ON_TRAJ_2048 = 2048 ,
  SET_COORDS_OUT_TRAJ_2049 = 2049 ,
  SET_COORDS_ON_TRAJ_DOUBLE_2050 = 2050 ,
  SET_COORDS_OUT_TRAJ_DOUBLE_2051 = 2051 ,
  EMERGENCY_STOP_04 = 4 ,
  EMERGENCY_STOP_WAIT_M04 = -4 ,
  EMERGENCY_STOP_OUT_TRAJ_05 = 5 ,
  NORMAL_STOP_08 = 8 ,
  NORMAL_STOP_WAIT_M08 = -8 ,
  NORMAL_STOP_OUT_TRAJ_09 = 9 ,
  SET_FILTER_PARAMETERS_M1 = -1 ,
  SET_SPLINE_PARAMETERS_M2 = -2
}
 
enum class  EXT_SDO_CONTROL : uint32_t {
  FINISHED_00 = SDO_CONTROL_FINISHED ,
  WRITE_01 = SDO_CONTROL_WRITE ,
  READ_02 = SDO_CONTROL_READ
}
 extended SDO commands (more than 4 bytes of data available) More...
 
enum class  EXT_SDO_STATUS : int32_t {
  OK_00 = SDO_STATUS_OK ,
  BUSY_01 = SDO_STATUS_BUSY ,
  ERROR_02 = SDO_STATUS_ERR
}
 extended SDO communication status (the same as for legacy SDO) More...
 
enum class  ECAT_REGISTER_CONTROL : uint32_t {
  READY_00 = 0U ,
  WRITE_01 = 1U ,
  READ_02 = 2U ,
  ERROR_03 = 3U ,
  BUSY_04 = 4U
}
 direct EtherCAT register read/write commands More...
 
enum class  interpolator_status : uint32_t {
  EMPTY_00 = 0U ,
  MOVE_01 = 1U ,
  STOP_03 = 3U ,
  TRAJECTORY_START_04 = 4U ,
  EMERGENCY_BREAKING_06 = 6U ,
  EMERGENCY_STOP_07 = 7U ,
  STOP_WHILE_BUFFER_FILL_08 = 8U
}
 interpolator states More...
 
enum class  ods_thread : uint32_t {
  MAIN ,
  SERVO_TIMER ,
  PROGRAM_01 ,
  PROGRAM_02 ,
  PROGRAM_03 ,
  INTERPOLATOR_THREAD ,
  EEPROM_THREAD ,
  PLC ,
  CNC ,
  ECAT ,
  N_THREADS
}
 reflects number of threads/timers for separate output debug string (ODS) areas
 
enum class  ods_id : uint32_t {
  MAIN = 0U ,
  PG = 1U ,
  GEAR = 2U ,
  OSC = 3U ,
  SERVO = 4U ,
  INTERPOLATOR = 5U ,
  PLC = 6U ,
  ECAT_TIMER = 7U ,
  EEPROM = 8U ,
  PROGRAM_01 = 9U ,
  PROGRAM_02 = 10U ,
  PROGRAM_03 = 11U ,
  PROGRAM_04 = 12U ,
  SPLINE = 13U ,
  AKD_CONTROL = 14U ,
  SR700_CONTROL = 15U ,
  TGZ_CONTROL = 16U ,
  ECAT_MASTER = 17U ,
  ECAT_SLAVES = 18U ,
  PE_IMAGE = 19U ,
  INI_FILE = 20U ,
  CNC_0 = 21U ,
  CNC_1 = 22U ,
  CNC_2 = 23U
}
 identifies the source of message
 
enum class  ods_severity : uint32_t {
  INFO_00 = 0 ,
  WARNING_01 = 1 ,
  ERROR_02 = 2
}
 allows to specify the severity of the message
 

Functions

template<typename T , size_t N>
constexpr size_t countof (T const (&)[N]) noexcept
 
constexpr uint32_t ODS_ID_SEVERITY (ods_id id, ods_severity severity)
 constructs info & severity number
 
constexpr uint32_t ODS_ID_INFO (ods_id id)
 
constexpr uint32_t ODS_ID_WARNING (ods_id id)
 
constexpr uint32_t ODS_ID_ERROR (ods_id id)
 
template<typename T >
void UNREFERENCED_PARAM (T &P) noexcept
 

Variables

constexpr TGM5_NAMESPACE_BEGIN uint32_t TGM_VERSION { 502U }
 Main TG Motion version.
 
constexpr uint32_t ID_COMPATIBILITY { 4034U }
 Compatibility number.
 
constexpr uint32_t ID_MEMORY_COMPATIBILITY { 906U }
 Memory Compatibility number.
 
constexpr uint32_t ID_CNC_COMPATIBILITY { 126U }
 CNC Compatibility ID.
 
constexpr uint32_t FEATURE_NEW_OSCILLOSCOPE { 1U << 0 }
 
constexpr uint32_t TGMOTION_PRODUCT_PC { 1U }
 
constexpr uint32_t TGMOTION_PRODUCT_TGMINI { 2U }
 TGMmini.
 
constexpr uint32_t TGMOTION_PRODUCT_TGM_CONTROLLER { 3U }
 TGM Controller.
 
constexpr uint32_t TGMOTION_PRODUCT_TGZ_MOTION { 4U }
 TGMotion on TGZ servo drive.
 
constexpr uint32_t MAX_SERVO { 256 }
 
constexpr uint32_t MAX_DIO { 16 }
 
constexpr uint32_t MAX_INTERPOLATOR { 3 }
 
constexpr uint32_t MAX_CORES { MAX_INTERPOLATOR }
 
constexpr uint32_t MAX_INTERPOLATOR_BUFFER_SIZE { 50000U }
 Maximum number of entries in interpolator buffer for each interpolator.
 
constexpr uint32_t MIN_INTERPOLATOR_BUFFER_SIZE { 500U }
 Minimal number of entries in interpolator buffer (for each interpolator)
 
constexpr uint32_t MAX_INTERPOLATOR_AXES { 10U }
 Maximum interpolated axes. Must be fixed to 10.
 
constexpr uint32_t MAX_TIMER_UP { 64U }
 Max number timers up.
 
constexpr uint32_t MAX_TIMER_DOWN { 64U }
 Max number timers down.
 
constexpr uint32_t TGM_LOG_MAIN { 0x0001U }
 Bit masks for debug log output. More...
 
constexpr uint32_t TGM_LOG_INTEPOLATOR { 0x0002U }
 Log TGM interpolator.
 
constexpr uint32_t TGM_LOG_CAN { 0x0004U }
 Log PLC CAN messages.
 
constexpr uint32_t TGM_LOG_PG { 0x0020U }
 Log PG profile generator.
 
constexpr uint32_t TGM_LOG_GEAR { 0x0040U }
 Log GEAR generator.
 
constexpr uint32_t TGM_LOG_ETHERCAT { 0x0100U }
 Log basic EtherCAT traffic.
 
constexpr uint32_t TGM_LOG_ETHERCAT_SDO { 0x0200U }
 Log SDO traffic.
 
constexpr uint32_t TGM_LOG_ETHERCAT_STATUS { 0x0400U }
 Log unexpected status change.
 
constexpr uint32_t TGM_LOG_ETHERCAT_DC { 0x0800U }
 Log distributed clock capability & topology.
 
constexpr uint32_t TGM_LOG_VERBOSE_PE { 0x2000U }
 Log PLC loading - PE image analysis (PC only)
 
constexpr uint32_t TGM_LOG_VERBOSE_RELOC { 0x4000U }
 Log PLC loading - PE image relocation (PC only)
 
constexpr uint32_t TGM_LOG_VERBOSE_EXPORTS { 0x8000U }
 Log PLC loading - list of exported functions (PC only)
 
constexpr uint32_t TGM_LOG_ETHERNET { 0x4000'0000U }
 Log Ethernet communication (TGMmini)
 
constexpr uint32_t TGM_LOG_ENABLE_RTX_SERVER { 0x8000'0000U }
 Log values also to RTX debug server (PC) or console (TGMmini)
 
constexpr TGM_LPCTSTR NAME_SYSTEM_MEMORY { TGM_TEXT("TGM_System") }
 Names of shared memories. More...
 
constexpr TGM_LPCTSTR NAME_DATA_MEMORY { TGM_TEXT("TGM_Data") }
 Name of the memory for PLC data.
 
constexpr TGM_LPCTSTR NAME_CAM_PROFILE_MEMORY { TGM_TEXT("TGM_Cam_Profile") }
 Name of the memory for CAM profile (internal)
 
constexpr TGM_LPCTSTR NAME_OSCILLOSCOPE_MEMORY { TGM_TEXT("TGM_Oscilloscope") }
 Name of the memory for Oscilloscope (internal)
 
constexpr TGM_LPCTSTR NAME_SERVO_MEMORY { TGM_TEXT("TGM_Servo") }
 Name of the memory for SERVO [MAX_SERVO].
 
constexpr TGM_LPCTSTR NAME_DIO_MEMORY { TGM_TEXT("TGM_Dio") }
 Name of the memory for DIO [MAX_DIO].
 
constexpr TGM_LPCTSTR NAME_INTERPOLATOR_MEMORY { TGM_TEXT("TGM_Interpolator") }
 Name of the memory for INTERPOLATOR [MAX_INTERPOLATOR].
 
constexpr TGM_LPCTSTR NAME_INTERPOLATOR_WRITE_MEMORY { TGM_TEXT("InterpolatorWriteMemory") }
 Name of the internal interpolator <-> CNC communication memory.
 
constexpr TGM_LPCTSTR NAME_INTERPOLATOR_READ_MEMORY { TGM_TEXT("InterpolatorReadMemory") }
 Name of the internal interpolator <-> CNC communication memory.
 
constexpr TGM_LPCTSTR NAME_ODS_MEMORY { TGM_TEXT("TGM_ODS") }
 Name of the message system memory (internal)
 
constexpr TGM_LPCTSTR NAME_CNCEX_MEMORY { TGM_TEXT("TGM_CNCEX") }
 Name of the memory for cnc::TGM_CNC_MEMORY.
 
constexpr TGM_LPCTSTR NAME_CNCODS_MEMORY { TGM_TEXT("TGM_CNCODS") }
 Name of the internal CNC -> ODS communication memory.
 
constexpr TGM_LPCTSTR NAME_GENERAL_MEMORY { TGM_TEXT("TGM_General") }
 Name of the memory for GENERAL_MEMORY.
 
constexpr uint32_t SIZE_DATA_MEMORY { 524288U }
 size for PLC data
 
constexpr uint32_t SIZE_CAM_PROFILE_MEMORY { 1048576U }
 size for CAM profiles
 
constexpr uint32_t DEFAULT_SIZE_OSCILLOSCOPE_MEMORY { 33554432 }
 
constexpr uint32_t MINIMAL_SIZE_OSCILLOSCOPE_MEMORY { 1048576U }
 
constexpr uint32_t MAXIMAL_SIZE_OSCILLOSCOPE_MEMORY { 33554432U }
 
constexpr uint32_t SIZE_CNCEX_MEMORY { 65536U }
 size for TGM_CNCEX memory
 
constexpr uint32_t SIZE_CNCODS_MEMORY { 65536U }
 size for TGM_CNCODS memory
 
constexpr uint32_t MAX_PLC_FILE_NAME_SIZE { 512U }
 max allowed string size for PLC file name
 
constexpr uint32_t MAX_ECAT_DRIVER_FILE_NAME_SIZE { 512U }
 max allowed string size for EtherCAT NIC driver file name (PC only)
 
constexpr uint32_t PLC_CTRL_LOAD_BIT { 0x01U }
 PLC control values. More...
 
constexpr uint32_t PLC_CTRL_RESET_BIT { 0x02U }
 Reset PLC.
 
constexpr uint32_t PLC_CTRL_PAUSE_BIT { 0x04U }
 Pause PLC.
 
constexpr uint32_t PLC_CTRL_ERROR_BIT { 0x08U }
 Signals PLC load error.
 
constexpr uint32_t PLC_CTRL_DISABLE_DIO_BIT { 0x10U }
 Disable DIO output (not yet used)
 
constexpr uint32_t FIXED_MAIN_STRUCT_SIZE { 3072U }
 Main memory area - fixed size 3072 bytes.
 
constexpr uint32_t FIXED_NUMBER_OF_INTERPOLATORS { 3U }
 Fixed maximal number of interpolators to keep the MAIN structure same for PC and TGMmini.
 
constexpr uint32_t FIXED_ETH_STRUCT_SIZE { 1024U }
 Ethernet connection memory area - fixed size 1024 bytes.
 
constexpr uint32_t FIXED_NUMBER_OF_ETH_CONNECTIONS { 4U }
 
constexpr uint32_t TGM_KILL { 0x4C4C'494BU }
 Value for MAIN::TGM_TgMotionCmd register - exit TGMotion (PC only)
 
constexpr uint32_t TGM_RESET_ECAT_BUS { 0x5355'4252U }
 Value for MAIN::TGM_TgMotionCmd register - reset EtherCAT bus (rescan all devices)
 
constexpr uint32_t TGM_REBOOT { 0x544F'4F42U }
 Value for MAIN::TGM_TgMotionCmd register - reboot computer TGMmini and its derivatives.
 
constexpr uint32_t TGM_RELOAD_INI { 0x494E'494CU }
 Value for MAIN::TGM_TgMotionCmd register - reload .INI file.
 
constexpr uint32_t MAX_USER_DEVICE_NAME_SIZE { 16U }
 size of the user device name array
 
constexpr uint32_t N_OSC_CHANNELS { 32U }
 Max number of oscilloscope numbers.
 
constexpr uint32_t SIZE_EEPROM_MEMORY
 auto calculated size EEPROM memory [ bytes ] More...
 
constexpr uint32_t SDO_CONTROL_FINISHED { 0U }
 SDO channel is ready for a next command.
 
constexpr uint32_t SDO_CONTROL_WRITE { 1U }
 Write SDO command for SDO::Control value.
 
constexpr uint32_t SDO_CONTROL_READ { 2U }
 Read SDO command for SDO::Control value.
 
constexpr int32_t SDO_STATUS_OK { 0 }
 SDO completed OK.
 
constexpr int32_t SDO_STATUS_BUSY { 1 }
 SDO is in progress (can have any other large positive value)
 
constexpr int32_t SDO_STATUS_ERR { -1 }
 SDO finished with error, the error code is in the SDO::Data.
 
constexpr uint32_t MFUNC_NUMBER_PAR { 26U }
 Number of M functions parameters (all the letters of English alphabet)
 

Detailed Description

Main include file for TG Motion. Can be used as the only include for virtual PLC projects.


Author
Antonin SAUER
Date
Jul, 20 th, 2011

Release notes

  • 26.09.2014 update ID numbers
    • ID_COMPATIBILITY 4028 to 4029
    • ID_MEMORY_COMPATIBILITY 900 to 901
    • memory CAM_PROFILE_MEMORY increased from 131072 bytes to 1048576 bytes
    • memory OSCILLOSCOPE_MEMORY increased from 131072 bytes to 1048576 bytes
  • 02.03.2016 update ID numbers
    • ID_COMPATIBILITY to 4030
    • ID_MEMORY_COMPATIBILITY 901
    • added shared memory TGM_ODS (1048576 bytes)
  • 21.06.2016 update ID numbers
    • ID_COMPATIBILITY 4031
    • ID_MEMORY_COMPATIBILITY 903
    • MAX_INTERPOLATOR 3
  • 15.08.2017 changed memory data type declarations from long int32_t to int32_t (using <stdint.h>)
    • DIO.Stav renamed to DIO.Status
    • SERVO.Axe renamed to SERVO.Axis
    • added structures needed fro PLC creation, so only this file is necessary for the PLC programmer
  • 10.05.2018
    • ID_COMPATIBILITY 4033
    • ID_MEMORY_COMPATIBILITY 904
    • CNC compatibility 119
    • new shared UNIVERSAL_MEMORY for various EtherCAT devices
  • 27.08.2018
  • 19.11.2018
    • CNC compatibility 122
  • 19.02.2020
    • rewrite for TGM500
    • CNC compatibility 123
    • ID_MEMORY_COMPATIBILITY 905
    • ID_COMPATIBILITY 4034
    • some fields of DIO changed to arrays
    • digital inputs & outputs uses full 32 bits of the variable
  • 24.02.2020
    • maximal number of DIO modules set to 16
    • maximal number of servos set to 256 (PC) or 64 (TGMmini)
    • number of interpolators is 3 (PC) or 2 (TGMmini)
    • structures HEADER, MAIN, DIO are now incompatible with the previous versions of TGMotion (TGM4xx) by offsets of the internal fields.
    • maximal number of analog inputs and outputs set to 16
    • maximal number of digital inputs and outputs set to 512
  • 08.06.2021
    • changed GENERAL_DEVICE structure (PDO send and receive locks)
    • ID_MEMORY_COMPATIBILITY 906
  • 08.06.2022
    • Size of oscilloscope memory can be set in .INI file for TGMmini in the range 1 - 32 (MB)
    • PC, TGMcontroller and TGZ+Motion all have 32 MB fixed.
    • constant SIZE_OSCILLOSCOPE_MEMORY is removed
  • 18.02.2025
    • PLC_DATA structure changed - contains a pointer to universal function, which can return auxiliary functions for the PLC program, depending on the TGMotion host
    • added other include files for several TGMotion hosts

Typedef Documentation

◆ CAN_TRANSMIT

typedef int32_t PLC_CDECL CAN_TRANSMIT(uint32_t Number, uint32_t Id, uint32_t Dlc, uint8_t *Tx_Data)

Send CAN message.

Parameters
Number
Id
Dlc
Tx_Data
Returns

◆ CAN_TRANSMITREMOTE

typedef int32_t PLC_CDECL CAN_TRANSMITREMOTE(uint32_t Number, uint32_t Id, uint32_t Dlc, uint8_t *Tx_Data)

Send CAN remote message.

Parameters
Number
Id
Dlc
Tx_Data
Returns

◆ GET_DEVICE_INFO

typedef TGM_LPCSTR PLC_CDECL GET_DEVICE_INFO(void)

Function to get textual info about the host system.

The mangled_function_name must be "pcGetDeviceInfo_v" and opmode must be 0.

Returns
pointer to string describing the device "PC-realtime", "PC-demo", "TGMmini", "TGMcontroller", "TGZ+Motion", "TGZ+MotionLite"

◆ GET_FUNCTION_OR_INFO

typedef intptr_t PLC_CDECL GET_FUNCTION_OR_INFO(const char *mangled_function_name, uint32_t opmode)

Function to get additional function pointer for PLC programs.

Returns
pointer to function or NULL if not found reserved, must be 0 for now
Parameters
mangled_function_namefunction name with parameters and return type

◆ RTWPRINTF_STRING_SEVERITY

typedef int32_t PLC_CDECL RTWPRINTF_STRING_SEVERITY(uint32_t id_and_severity, TGM_LPCTSTR strText)

Output string to console.

Parameters
id_and_severitycombined number of source id and severity. Use ODS_ID_INFO, ODS_ID_WARNING or ODS_ID_ERROR helper functions to construct the number.
strTextUNICODE (Windows) or ANSI (Linux) string to be displayed in TG Motion debug console. Use TGM_TEXT() macro for UNICODE/ANSI text independence.
Returns
Always zero

◆ SLEEPFT

typedef void PLC_CDECL SLEEPFT(PLC_LARGE_INTEGER *Pause)

Wait for specified time. Do not use in Program_04() !

Parameters
Pausetimeout in 100ns unit. Note that real time granularity could be much higher (50 us, 100 us or more, depending on operating system)

Enumeration Type Documentation

◆ DIO_TYPE

enum DIO_TYPE : uint32_t
strong

EtherCAT DIO types. Found automatically and set to DIO::Type variable.

Enumerator
TG_IO_TYPE_BASIC 

digital: 32out, 48in, analog: 4out, 4in

TG_IO_TENZOMETER 

digital: 8out, 8in, tenzometer: 4

TG_IO_TYPE_NEW 

digital: 40out, 48in, analog: 4out, 4in

TG_IO_TYPE_BASIC_LITE 

digital: 24out, 40in

TG_IO_TYPE_NEW_LITE 

digital: 16out, 32in, analog: 4out, 4in

FESTO_IO_TYPE 

digital: up to 128out, up to 128in

TGM_MINI_DIO_TYPE 

digital: 8out, 8in

DFC_IO_TYPE 

digital: 16out, 16in

◆ ECAT_REGISTER_CONTROL

enum ECAT_REGISTER_CONTROL : uint32_t
strong

direct EtherCAT register read/write commands

Uses the same values as for normal (legacy) SDO

Enumerator
READY_00 

ready for request

WRITE_01 

write request

READ_02 

read request

ERROR_03 

request error, can request another

BUSY_04 

system is processing the request

◆ EXT_SDO_CONTROL

enum EXT_SDO_CONTROL : uint32_t
strong

extended SDO commands (more than 4 bytes of data available)

Uses the same values as for normal (legacy) SDO. Used in GENERAL_DEVICE.

Enumerator
FINISHED_00 

0 - SDO is ready for a next command

WRITE_01 

1 - Write SDO

READ_02 

2 - Read SDO

◆ EXT_SDO_STATUS

enum EXT_SDO_STATUS : int32_t
strong

extended SDO communication status (the same as for legacy SDO)

Enumerator
OK_00 

command completed OK

BUSY_01 

command is in process

ERROR_02 

command ended with error, the error code is in EXT_SDO::Data[0]

◆ INTERPOLATOR_COMMANDS

enum INTERPOLATOR_COMMANDS : int32_t
strong

Interpolator commands (INTERPOLATOR::Command)

Enumerator
NONE_00 

No command or previous command finished.

SET_AXIS_RATIO_1024 

Sets the INTERPOLATOR::Ratio as a fraction

Command_Parametr Description
0 axis index
1 numerator
2 denominator
SET_COORDS_ON_TRAJ_2048 

Sets the actual position, keep the on_trajectory status. All the positions are in Command_Parametr array.

SET_COORDS_OUT_TRAJ_2049 

Sets the actual position, set the off_trajectory status. All the positions are in Command_Parametr array.

SET_COORDS_ON_TRAJ_DOUBLE_2050 

Sets the actual position, keep the on_trajectory status, using double parameters. All the positions are in Command_Parameter_Double array.

SET_COORDS_OUT_TRAJ_DOUBLE_2051 

Sets the actual position, set the off_trajectory status. All the positions are in Command_Parameter_Double array.

EMERGENCY_STOP_04 

Stop the interpolator and keep it on actual status. Uses emergency stop deceleration

EMERGENCY_STOP_WAIT_M04 

emergency stop is in progress

EMERGENCY_STOP_OUT_TRAJ_05 

Stop the interpolator and set off trajectory status Uses emergency stop deceleration

NORMAL_STOP_08 

Stop the interpolator and keep it on actual status. Uses normal stop deceleration

NORMAL_STOP_WAIT_M08 

normal stop is in progress

NORMAL_STOP_OUT_TRAJ_09 

Stop the interpolator and set off trajectory status Uses normal stop deceleration

SET_FILTER_PARAMETERS_M1 

Sets the IIR filter parameters

Command_Parametr Description
0 p parameter
1 q parameter
2 f parameter
3 axis bit mask
SET_SPLINE_PARAMETERS_M2 

Sets the spline parameters

Command_Parametr Description
0 number of points (50-500)
1 jerk value

◆ interpolator_status

enum interpolator_status : uint32_t
strong

interpolator states

Enumerator
EMPTY_00 

interpolator buffer is empty, no movement is possible

MOVE_01 

movement on trajectory is under way

STOP_03 

stop at the trajectory end

TRAJECTORY_START_04 

at least one part of the trajectory is in the buffer, start may be called

EMERGENCY_BREAKING_06 

stopping on emergency ramp

EMERGENCY_STOP_07 

interpolator stopped after emergency stop

STOP_WHILE_BUFFER_FILL_08 

interpolator was stopped during the buffer filling

◆ OSC_DATA_TYPE

enum OSC_DATA_TYPE : uint32_t
strong

Oscilloscope data types.

Enumerator
I32_DEC 

int32_t in decimal representation

I32_HEX 

int32_t in hexadecimal representation

I32_BIN 

int32_t in binary representation

UI32_DEC 

uint32_t in decimal representation

I64_DEC 

int64_t in decimal representation

I64_HEX 

int64_t in hexadecimal representation

I64_BIN 

int64_t in binary representation

UI64_DEC 

uint64_t in decimal representation

DOUBLE 

64 bits real data type

FLOAT 

32 bits real data type (single data type Pascal)

ASTRING 

ANSI (UTF-8) string.

WSTRING 

UNICODE (UTF-16) string.

I32_BIN_EX 

int32_t in binary representation, displayed bit by bit

I64_BIN_EX 

int64_t in binary representation, displayed bit by bit

◆ SERVO_TYPE

enum SERVO_TYPE : uint32_t
strong

Built-in servo types

Enumerator
VIRTUAL 

Virtual servo.

SERVOSTAR_300_700 

Servo drive Servostar 300 or Servostar 700.

AKD 

Servo drive AKD.

AKD2G_SINGLE_AXIS 

Servo drive AKD2G (one axis)

AKD2G_DUAL_AXIS 

Servo drive AKD2G (two axes)

TGZ 

Servo drive TGZ.

TGZ_MOTION 

TGMotion + TGZ servo = TGZ+Motion.

TGM_CONTROLLER 

TGMcontroller system.

TGZ_IO_REMAPPED 

TGZ servo with remapped I/O.

TGZ_MOTION_IO_REMAPPED 

TGMotion + TGZ servo with remapped I/O.

TGM_CONTROLLER_IO_REMAPPED 

TGMcontroller system with remapped I/O.

TGZ_COE 

TGZ servo with CoE mapping activated.

INVALID 

Invalid servo type.

◆ SHARED_MEMORY

enum SHARED_MEMORY : uint32_t
strong

Memory numbers (types)

The same numbers are used as memory types in TGM_Comm_Int_5.dll.

Note
The numbers are different to version TGM4xx!
Enumerator
SYSTEM 

SYSTEM memory.

DATA 

Virtual PLC private memory. TG Motion never writes to this memory.

CAM_PROFILE 

CAM memory.

OSCILLOSCOPE 

Oscilloscope memory. Stores oscilloscope values. Read-only.

SERVO 

All servos.

DIO 

All I/O modules.

GENERAL 

Memory for general devices.

INTERPOLATOR 

Interface to all interpolators.

INTERPOLATOR_WRITE 

Internal memory for CNC modules.

INTERPOLATOR_READ 

Internal memory for CNC modules.

ODS 

Stores debug, warning and error messages in a circular buffer.

CNC_ODS 

Internal memory for CNC -> ODS communication.

CNC_EX 

Internal memory for CNC modules.

LAST_MEMORY_IDX 

total number of shared memories

Function Documentation

◆ countof()

template<typename T , size_t N>
constexpr size_t countof ( T   const(&)[N])
constexprnoexcept

useful countof template function: determine number of elements in an array (not bytes)

◆ ODS_ID_ERROR()

constexpr uint32_t ODS_ID_ERROR ( ods_id  id)
inlineconstexpr

Constructs error message number with given ods_id. Used by RTWPRINTF_STRING_SEVERITY function in PLC_DATA::functions

◆ ODS_ID_INFO()

constexpr uint32_t ODS_ID_INFO ( ods_id  id)
inlineconstexpr

Constructs info message number with given ods_id. Used by RTWPRINTF_STRING_SEVERITY function in PLC_DATA::functions

◆ ODS_ID_WARNING()

constexpr uint32_t ODS_ID_WARNING ( ods_id  id)
inlineconstexpr

Constructs warning message number with given ods_id. Used by RTWPRINTF_STRING_SEVERITY function in PLC_DATA::functions

◆ UNREFERENCED_PARAM()

template<typename T >
void UNREFERENCED_PARAM ( T &  P)
noexcept

Used for declaring unreferenced parameter or variable. Useful for removing compiler warning about such a parameter/variable.

Variable Documentation

◆ DEFAULT_SIZE_OSCILLOSCOPE_MEMORY

constexpr uint32_t DEFAULT_SIZE_OSCILLOSCOPE_MEMORY { 33554432 }
constexpr

default size for oscilloscope data. Depends on architecture (PC or TGMmini), must be set in project or makefile by SIZE_OSCILLOSCOPE_MEMORY_PROJECT_SETTINGS define.

◆ FEATURE_NEW_OSCILLOSCOPE

constexpr uint32_t FEATURE_NEW_OSCILLOSCOPE { 1U << 0 }
constexpr

additional features implemented 0x00000001 - new oscilloscope with pretrigger and different data packing scheme

◆ MAX_CORES

constexpr uint32_t MAX_CORES { MAX_INTERPOLATOR }
constexpr

Maximum number of CNC cores inside TGM. Equals to MAX_INTERPOLATOR constant.

◆ MAX_DIO

constexpr uint32_t MAX_DIO { 16 }
constexpr

Max number of I/O modules - can be overridden for different TG Motion types (PC, TGMmini). Must be set in project or makefile by MAX_DIO_PROJECT_SETTINGS define. Actually only 16 is allowed.

◆ MAX_INTERPOLATOR

constexpr uint32_t MAX_INTERPOLATOR { 3 }
constexpr

Maximum number of interpolators - can be overridden for different TG Motion types (PC, TGMmini). Must be set in project or makefile be MAX_INTERPOLATOR_PROJECT_SETTINGS define. PC has up to 3 interpolators, TGMmini one or two according to hw version.

◆ MAX_SERVO

constexpr uint32_t MAX_SERVO { 256 }
constexpr

Max number of servos - can be overridden for different TG Motion types (PC, TGMmini). Must be set in project or makefile by MAX_SERVO_PROJECT_SETTINGS define. PC has up to 256 servos, TGMmini 64.

◆ NAME_SYSTEM_MEMORY

constexpr TGM_LPCTSTR NAME_SYSTEM_MEMORY { TGM_TEXT("TGM_System") }
constexpr

Names of shared memories.

Name of the memory for SYSTEM

◆ PLC_CTRL_LOAD_BIT

constexpr uint32_t PLC_CTRL_LOAD_BIT { 0x01U }
constexpr

PLC control values.

Load PLC

◆ SIZE_EEPROM_MEMORY

constexpr uint32_t SIZE_EEPROM_MEMORY
constexpr
Initial value:
{ MAX_SYSTEM_MEMORY_SIZE
- sizeof(HEADER)
- sizeof(MAIN)
- sizeof(RESERVE_MAIN)
- sizeof(OSC_EX)
- sizeof(ETH)
- sizeof(TIMERS)
- sizeof(OSC)
- (MAX_ECAT_DRIVES * sizeof(ECAT_DRIVER))
- sizeof(EEPROM_CONTROL)
}
Definition: tgm.h:924
Definition: tgm.h:770
The HEADER struct - fixed size 128 bytes.
Definition: tgm.h:446
The MAIN struct - fixed size of 4096 bytes.
Definition: tgm.h:528
Definition: tgm.h:673
Oscilloscope control.
Definition: tgm.h:816
reserve the MAIN structure to 3072 bytes
Definition: tgm.h:692
Timers with fixed 1ms period.
Definition: tgm.h:786

auto calculated size EEPROM memory [ bytes ]

◆ TGM_LOG_MAIN

constexpr uint32_t TGM_LOG_MAIN { 0x0001U }
constexpr

Bit masks for debug log output.

Values are set in the TgMotion4xx.ini file, entry Log=.... Log main TGM

◆ TGMOTION_PRODUCT_PC

constexpr uint32_t TGMOTION_PRODUCT_PC { 1U }
constexpr

supported TGMotion devices real-time on the PC