diff --git a/GNUmakefile b/GNUmakefile index 4f7d7a2..bf878ec 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,6 +1,8 @@ include /ioc/tools/driver.makefile MODULE = ecmc_plugin_motion +# "Transfer" module name to plugin +USR_CFLAGS +=-DECMC_PLUGIN_MODULE_NAME=${MODULE} BUILDCLASSES = Linux ARCH_FILTER = deb10% @@ -16,7 +18,7 @@ OPT_CXXFLAGS_YES = -O3 # dependencies ECmasterECMC_VERSION = v1.1.0 -ecmc_VERSION = 9.6 +ecmc_VERSION = sandst_a ################################################################################ # THIS RELATES TO THE EtherCAT MASTER LIBRARY diff --git a/src/ecmcPluginMotion.c b/src/ecmcPluginMotion.c index 413f03a..9140147 100644 --- a/src/ecmcPluginMotion.c +++ b/src/ecmcPluginMotion.c @@ -8,11 +8,16 @@ * Created on: july 10, 2023 * Author: anderssandstrom * +* Instructions: +* - IMPORTANT: Add "USR_CFLAGS +=-DECMC_PLUGIN_MODULE_NAME=${MODULE}" to GNUMakefile +* - All functions and ecmcPluginData struct must be declared static +* \*************************************************************************/ // Needed to get headers in ecmc right... #define ECMC_IS_PLUGIN -#define ECMC_EXAMPLE_PLUGIN_VERSION 2 +#define ECMC_PLUGIN_VERSION 2 + #ifdef __cplusplus extern "C" { @@ -30,15 +35,13 @@ static int lastEcmcError = 0; static char* lastConfStr = NULL; /** Optional. - * Will be called once after successfull load into ecmc. + * Will be called once after successful load into ecmc. * Return value other than 0 will be considered error. * configStr can be used for configuration parameters. **/ -int motionConstruct(char *configStr) +static int construct(char *configStr) { //This module is allowed to load several times so no need to check if loaded - - // create FFT object and register data callback lastConfStr = strdup(configStr); return createMotionObj(configStr); } @@ -46,31 +49,27 @@ int motionConstruct(char *configStr) /** Optional function. * Will be called once at unload. **/ -void motionDestruct(void) +static void motionDestruct(void) { - //deleteAllMotionObjs(); - //if(lastConfStr){ - // free(lastConfStr); - //} } /** Optional function. - * Will be called each realtime cycle if definded - * ecmcError: Error code of ecmc. Makes it posible for + * Will be called each realtime cycle if defined + * ecmcError: Error code of ecmc. Makes it possible for * this plugin to react on ecmc errors * Return value other than 0 will be considered to be an error code in ecmc. **/ -int motionRealtime(int ecmcError) +static int motionRealtime(int ecmcError) { executeMotionObjs(); lastEcmcError = ecmcError; return 0; } -/** Link to data source here since all sources should be availabe at this stage +/** Link to data source here since all sources should be available at this stage * (for example ecmc PLC variables are defined only at enter of realtime) **/ -int motionEnterRT(){ +static int motionEnterRT(){ return linkDataTomotionObjs(); } @@ -78,41 +77,17 @@ int motionEnterRT(){ * Will be called once just before leaving realtime mode * Return value other than 0 will be considered error. **/ -int motionExitRT(void){ +static int motionExitRT(void){ return 0; } -//// Plc function for clear of buffers -//double fft_clear(double index) { -// return (double)clearFFT((int)index); -//} -// -//// Plc function for enable -//double fft_enable(double index, double enable) { -// return (double)enableFFT((int)index, (int)enable); -//} -// -//// Plc function for trigg new measurement (will clear buffers) -//double fft_trigg(double index) { -// return (double)triggFFT((int)index); -//} -// -//// Plc function for enable -//double fft_mode(double index, double mode) { -// return (double)modeFFT((int)index, (FFT_MODE)((int)mode)); -//} -// -//// Plc function for enable -//double fft_stat(double index) { -// return (double)statFFT((int)index); -//} - // Register data for plugin so ecmc know what to use -struct ecmcPluginData pluginDataDef = { +static struct ecmcPluginData pluginDataDef = { + // Allways use ECMC_PLUG_VERSION_MAGIC .ifVersion = ECMC_PLUG_VERSION_MAGIC, // Name - .name = "ecmcPlugin_Motion", + .name = "ecmc_plugin_motion", // Description .desc = "Motion plugin for commissioning of ecmc motion axes.", // Option description @@ -123,171 +98,20 @@ struct ecmcPluginData pluginDataDef = { " "ECMC_PLUGIN_MODE_OPTION_CMD" : Sampling rate in Hz" , // Plugin version - .version = ECMC_EXAMPLE_PLUGIN_VERSION, - // Optional construct func, called once at load. NULL if not definded. - .constructFnc = motionConstruct, - // Optional destruct func, called once at unload. NULL if not definded. + .version = ECMC_PLUGIN_VERSION, + // Optional construct func, called once at load. NULL if not defined. + .constructFnc = construct, + // Optional destruct func, called once at unload. NULL if not defined. .destructFnc = motionDestruct, - // Optional func that will be called each rt cycle. NULL if not definded. + // Optional func that will be called each rt cycle. NULL if not defined. .realtimeFnc = motionRealtime, // Optional func that will be called once just before enter realtime mode .realtimeEnterFnc = motionEnterRT, // Optional func that will be called once just before exit realtime mode .realtimeExitFnc = motionExitRT, // PLC funcs -// .funcs[0] = -// { /*----fft_clear----*/ -// // Function name (this is the name you use in ecmc plc-code) -// .funcName = "fft_clear", -// // Function description -// .funcDesc = "double fft_clear(index) : Clear/reset fft[index].", -// /** -// * 7 different prototypes allowed (only doubles since reg in plc). -// * Only funcArg${argCount} func shall be assigned the rest set to NULL. -// **/ -// .funcArg0 = NULL, -// .funcArg1 = fft_clear, -// .funcArg2 = NULL, -// .funcArg3 = NULL, -// .funcArg4 = NULL, -// .funcArg5 = NULL, -// .funcArg6 = NULL, -// .funcArg7 = NULL, -// .funcArg8 = NULL, -// .funcArg9 = NULL, -// .funcArg10 = NULL, -// .funcGenericObj = NULL, -// }, -// .funcs[1] = -// { /*----fft_enable----*/ -// // Function name (this is the name you use in ecmc plc-code) -// .funcName = "fft_enable", -// // Function description -// .funcDesc = "double fft_enable(index, enable) : Set enable for fft[index].", -// /** -// * 7 different prototypes allowed (only doubles since reg in plc). -// * Only funcArg${argCount} func shall be assigned the rest set to NULL. -// **/ -// .funcArg0 = NULL, -// .funcArg1 = NULL, -// .funcArg2 = fft_enable, -// .funcArg3 = NULL, -// .funcArg4 = NULL, -// .funcArg5 = NULL, -// .funcArg6 = NULL, -// .funcArg7 = NULL, -// .funcArg8 = NULL, -// .funcArg9 = NULL, -// .funcArg10 = NULL, -// .funcGenericObj = NULL, -// }, -// .funcs[2] = -// { /*----fft_trigg----*/ -// // Function name (this is the name you use in ecmc plc-code) -// .funcName = "fft_trigg", -// // Function description -// .funcDesc = "double fft_trigg(index) : Trigg new measurement for fft[index]. Will clear buffers.", -// /** -// * 7 different prototypes allowed (only doubles since reg in plc). -// * Only funcArg${argCount} func shall be assigned the rest set to NULL. -// **/ -// .funcArg0 = NULL, -// .funcArg1 = fft_trigg, -// .funcArg2 = NULL, -// .funcArg3 = NULL, -// .funcArg4 = NULL, -// .funcArg5 = NULL, -// .funcArg6 = NULL, -// .funcArg7 = NULL, -// .funcArg8 = NULL, -// .funcArg9 = NULL, -// .funcArg10 = NULL, -// .funcGenericObj = NULL, -// }, -// .funcs[3] = -// { /*----fft_mode----*/ -// // Function name (this is the name you use in ecmc plc-code) -// .funcName = "fft_mode", -// // Function description -// .funcDesc = "double fft_mode(index, mode) : Set mode Cont(1)/Trigg(2) for fft[index].", -// /** -// * 7 different prototypes allowed (only doubles since reg in plc). -// * Only funcArg${argCount} func shall be assigned the rest set to NULL. -// **/ -// .funcArg0 = NULL, -// .funcArg1 = NULL, -// .funcArg2 = fft_mode, -// .funcArg3 = NULL, -// .funcArg4 = NULL, -// .funcArg5 = NULL, -// .funcArg6 = NULL, -// .funcArg7 = NULL, -// .funcArg8 = NULL, -// .funcArg9 = NULL, -// .funcArg10 = NULL, -// .funcGenericObj = NULL, -// }, -// .funcs[4] = -// { /*----fft_stat----*/ -// // Function name (this is the name you use in ecmc plc-code) -// .funcName = "fft_stat", -// // Function description -// .funcDesc = "double fft_stat(index) : Get status of fft (NO_STAT, IDLE, ACQ, CALC) for fft[index].", -// /** -// * 7 different prototypes allowed (only doubles since reg in plc). -// * Only funcArg${argCount} func shall be assigned the rest set to NULL. -// **/ -// .funcArg0 = NULL, -// .funcArg1 = fft_stat, -// .funcArg2 = NULL, -// .funcArg3 = NULL, -// .funcArg4 = NULL, -// .funcArg5 = NULL, -// .funcArg6 = NULL, -// .funcArg7 = NULL, -// .funcArg8 = NULL, -// .funcArg9 = NULL, -// .funcArg10 = NULL, -// .funcGenericObj = NULL, -// }, .funcs[0] = {0}, // last element set all to zero.. // PLC consts - /* CONTINIOUS MODE = 1 */ -// .consts[0] = { -// .constName = "fft_CONT", -// .constDesc = "FFT Mode: Continious", -// .constValue = CONT -// }, -// /* TRIGGERED MODE = 2 */ -// .consts[1] = { -// .constName = "fft_TRIGG", -// .constDesc = "FFT Mode :Triggered", -// .constValue = TRIGG -// }, -// /* TRIGGERED MODE = 2 */ -// .consts[2] = { -// .constName = "fft_NO_STAT", -// .constDesc = "FFT Status: Invalid state", -// .constValue = NO_STAT, -// }, -// /* TRIGGERED MODE = 2 */ -// .consts[3] = { -// .constName = "fft_IDLE", -// .constDesc = "FFT Status: Idle state (waiting for trigger)", -// .constValue = IDLE -// }, -// /* TRIGGERED MODE = 2 */ -// .consts[4] = { -// .constName = "fft_ACQ", -// .constDesc = "FFT Status: Acquiring data", -// .constValue = ACQ -// }, -// /* TRIGGERED MODE = 2 */ -// .consts[5] = { -// .constName = "fft_CALC", -// .constDesc = "FFT Status: Calculating result", -// .constValue = CALC -// }, .consts[0] = {0}, // last element set all to zero.. }; diff --git a/tools/cos_ff_trq_test.png b/tools/cos_ff_trq_test.png new file mode 100644 index 0000000..a8059f8 Binary files /dev/null and b/tools/cos_ff_trq_test.png differ diff --git a/tools/cos_ff_trq_test_2.png b/tools/cos_ff_trq_test_2.png new file mode 100644 index 0000000..408a585 Binary files /dev/null and b/tools/cos_ff_trq_test_2.png differ diff --git a/tools/cos_ff_trq_test_adaptive.png b/tools/cos_ff_trq_test_adaptive.png new file mode 100644 index 0000000..a33f993 Binary files /dev/null and b/tools/cos_ff_trq_test_adaptive.png differ diff --git a/tools/cos_ff_trq_test_adaptive_2.png b/tools/cos_ff_trq_test_adaptive_2.png new file mode 100644 index 0000000..381ae95 Binary files /dev/null and b/tools/cos_ff_trq_test_adaptive_2.png differ diff --git a/tools/cos_ff_trq_test_adaptive_3.png b/tools/cos_ff_trq_test_adaptive_3.png new file mode 100644 index 0000000..7107c62 Binary files /dev/null and b/tools/cos_ff_trq_test_adaptive_3.png differ diff --git a/tools/cos_ff_trq_test_adaptive_4.png b/tools/cos_ff_trq_test_adaptive_4.png new file mode 100644 index 0000000..bdeb108 Binary files /dev/null and b/tools/cos_ff_trq_test_adaptive_4.png differ diff --git a/tools/cos_ff_trq_test_adaptive_5.png b/tools/cos_ff_trq_test_adaptive_5.png new file mode 100644 index 0000000..5b2ebb8 Binary files /dev/null and b/tools/cos_ff_trq_test_adaptive_5.png differ