Ethercat HAL driver
I have a general question about the Ethercat.comp file used with Linuxcnc.
Here is a sample of 2 found ethercat.comp file's
Version 1. wiki.linuxcnc.org/cgi-bin/wiki.pl?Contri...EtherCAT_Digital_I_O
Version 2. wiki.linuxcnc.org/cgi-bin/wiki.pl?Etherlab
Version 1:
pin out bit eingang_0;
pin out bit eingang_1;
pin out bit eingang_2;
pin out bit eingang_3;
pin in bit ausgang_0;
pin in bit ausgang_1;
pin in bit ausgang_2;
pin in bit ausgang_3;
option extra_setup;
option extra_cleanup;
//option constructable no;
function update nofp;
;;
MODULE_LICENSE("GPL");
// RTAI
//#include "/usr/realtime-2.6.15-magma/include/rtai_sched.h"
//#include "/usr/realtime-2.6.15-magma/include/rtai_sem.h"
// EtherCAT
#include "/home/ruediger/ethercat-1.3.0/include/ecrt.h"
#include "/home/ruediger/ethercat-1.3.0/include/ecdb.h"
/*****************************************************************************/
// EtherCAT
static ec_master_t *master = NULL;
static ec_domain_t *domain1 = NULL;
spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
static ec_master_status_t master_status, old_status = {};
// data fields
static void *r_dig_in;
static void *r_dig_out;
const static ec_pdo_reg_t domain1_pdo_regs[] = {
{"1", Beckhoff_EL1014_Inputs, &r_dig_in},
{"2", Beckhoff_EL2004_Outputs, &r_dig_out},
{}
};
/*****************************************************************************/
#define MAX 8
int io[MAX] = {0,};
RTAPI_MP_ARRAY_INT(io, MAX, "I/O addresses of serial ports");
/***********************************************************************
* LOCAL FUNCTION DECLARATIONS *
************************************************************************/
static int request_lock(void *data);
static void release_lock(void *data);
/*****************************************************************************/
EXTRA_SETUP() {
ec_slave_t *slave;
rtapi_print_msg(RTAPI_MSG_INFO,"Starting...\n");
//printk(KERN_INFO PFX "Starting...\n");
if (!(master = ecrt_request_master(0))) {
rtapi_print_msg(RTAPI_MSG_INFO,"BRequesting master 0 failed!\n");
//printk(KERN_ERR PFX "Requesting master 0 failed!\n");
goto out_return;
}
ecrt_master_callbacks(master, request_lock, release_lock, NULL);
rtapi_print_msg(RTAPI_MSG_INFO,"Registering domain...\n");
//printk(KERN_INFO PFX "Registering domain...\n");
if (!(domain1 = ecrt_master_create_domain(master))) {
rtapi_print_msg(RTAPI_MSG_INFO,"Domain creation failed!\n");
//printk(KERN_ERR PFX "Domain creation failed!\n");
goto out_release_master;
}
rtapi_print_msg(RTAPI_MSG_INFO,"Registering PDOs...\n");
//rintk(KERN_INFO PFX "Registering PDOs...\n");
if (ecrt_domain_register_pdo_list(domain1, domain1_pdo_regs)) {
rtapi_print_msg(RTAPI_MSG_INFO,"PDO registration failed!\n");
//printk(KERN_ERR PFX "PDO registration failed!\n");
goto out_release_master;
}
rtapi_print_msg(RTAPI_MSG_INFO,"Activating master...\n");
//printk(KERN_INFO PFX "Activating master...\n");
if (ecrt_master_activate(master)) {
rtapi_print_msg(RTAPI_MSG_INFO,"Failed to activate master!\n");
//printk(KERN_ERR PFX "Failed to activate master!\n");
goto out_release_master;
}
rtapi_print_msg(RTAPI_MSG_INFO,"Started.\n");
//printk(KERN_INFO PFX "Started.\n");
return 0;
out_release_master:
rtapi_print_msg(RTAPI_MSG_INFO,"Releasing master...\n");
//printk(KERN_ERR PFX "Releasing master...\n");
ecrt_release_master(master);
out_return:
rtapi_print_msg(RTAPI_MSG_INFO,"Failed to load. Aborting.\n");
//printk(KERN_ERR PFX "Failed to load. Aborting.\n");
return -1;
}
EXTRA_CLEANUP() {
rtapi_print_msg(RTAPI_MSG_INFO,"Stopping...\n");
//printk(KERN_INFO PFX "Stopping...\n");
rtapi_print_msg(RTAPI_MSG_INFO,"Releasing master...\n");
//printk(KERN_INFO PFX "Releasing master...\n");
ecrt_release_master(master);
rtapi_print_msg(RTAPI_MSG_INFO,"Unloading.\n");
//printk(KERN_INFO PFX "Unloading.\n");
}
/*****************************************************/
/*****************************************************/
FUNCTION(update) {
// receive
spin_lock(&master_lock);
ecrt_master_receive(master);
ecrt_domain_process(domain1);
spin_unlock(&master_lock);
//EC_WRITE_U8(r_dig_out, blink ? 0x0F : 0x00);
eingang_0 = EC_READ_BIT(r_dig_in, 0);
eingang_1 = EC_READ_BIT(r_dig_in, 1);
eingang_2 = EC_READ_BIT(r_dig_in, 2);
eingang_3 = EC_READ_BIT(r_dig_in, 3);
EC_WRITE_BIT(r_dig_out, 0, ausgang_0);
EC_WRITE_BIT(r_dig_out, 1, ausgang_1);
EC_WRITE_BIT(r_dig_out, 2, ausgang_2);
EC_WRITE_BIT(r_dig_out, 3, ausgang_3);
spin_lock(&master_lock);
ecrt_master_get_status(master, &master_status);
spin_unlock(&master_lock);
if (master_status.bus_status != old_status.bus_status) {
rtapi_print_msg(RTAPI_MSG_INFO,"bus status changed to %i.\n", master_status.bus_status);
//printk(KERN_INFO PFX "bus status changed to %i.\n",
// master_status.bus_status);
}
if (master_status.bus_tainted != old_status.bus_tainted) {
rtapi_print_msg(RTAPI_MSG_INFO,"tainted flag changed to %u.\n", master_status.bus_tainted);
//printk(KERN_INFO PFX "tainted flag changed to %u.\n",
// master_status.bus_tainted);
}
if (master_status.slaves_responding !=
old_status.slaves_responding) {
rtapi_print_msg(RTAPI_MSG_INFO,"slaves_responding changed to %u.\n", master_status.slaves_responding);
//printk(KERN_INFO PFX "slaves_responding changed to %u.\n",
// master_status.slaves_responding);
}
old_status = master_status;
// send
spin_lock(&master_lock);
ecrt_domain_queue(domain1);
spin_unlock(&master_lock);
spin_lock(&master_lock);
ecrt_master_send(master);
spin_unlock(&master_lock);
}
/*****************************************************************************/
static int request_lock(void *data)
{
spin_lock(&master_lock);
return 0; // access allowed
}
/*****************************************************************************/
static void release_lock(void *data)
{
spin_unlock(&master_lock);
}
/*****************************************************************************/
Version 2:
pin out bit eingang_0;
pin out bit eingang_1;
pin out bit eingang_2;
pin out bit eingang_3;
pin out bit eingang_4;
pin out bit eingang_5;
pin out bit eingang_6;
pin out bit eingang_7;
pin in bit ausgang_0;
pin in bit ausgang_1;
pin in bit ausgang_2;
pin in bit ausgang_3;
pin in bit ausgang_4;
pin in bit ausgang_5;
pin in bit ausgang_6;
pin in bit ausgang_7;
option extra_setup;
option extra_cleanup;
//option constructable no;
function update nofp;
license "GPL";
;;
#include "/opt/ethercat/include/ecrt.h"
/*****************************************************************************/
// EtherCAT
static ec_master_t *master = NULL;
static ec_domain_t *domain1 = NULL;
spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
static ec_master_state_t master_status, old_status = {};
// data fields
static uint8_t *domain1_pd; // process data memory
// offsets to data fields
static unsigned int o_dig_in[8], bo_dig_in[8];
static unsigned int o_dig_out[8], bo_dig_out[8];
// pdo definitions may be read from autogenerated file
//#include "ethercat_cstruct.c"
#define Beckhoff_EL2004 0x00000002, 0x07D43052
#define Beckhoff_EL1014 0x00000002, 0x03F63052
const static ec_pdo_entry_reg_t domain1_pdo_regs[] = {
{ 0, 1, Beckhoff_EL2004, 0x7000, 1, &o_dig_out[0], &bo_dig_in[0]},
{ 0, 1, Beckhoff_EL2004, 0x7010, 1, &o_dig_out[1], &bo_dig_in[1]},
{ 0, 1, Beckhoff_EL2004, 0x7020, 1, &o_dig_out[2], &bo_dig_in[2]},
{ 0, 1, Beckhoff_EL2004, 0x7030, 1, &o_dig_out[3], &bo_dig_in[3]},
{ 0, 2, Beckhoff_EL2004, 0x7000, 1, &o_dig_out[4], &bo_dig_in[4]},
{ 0, 2, Beckhoff_EL2004, 0x7010, 1, &o_dig_out[5], &bo_dig_in[5]},
{ 0, 2, Beckhoff_EL2004, 0x7020, 1, &o_dig_out[6], &bo_dig_in[6]},
{ 0, 2, Beckhoff_EL2004, 0x7030, 1, &o_dig_out[7], &bo_dig_in[7]},
{ 0, 3, Beckhoff_EL1014, 0x6000, 1, &o_dig_in[0] , &bo_dig_out[0]},
{ 0, 3, Beckhoff_EL1014, 0x6010, 1, &o_dig_in[1] , &bo_dig_out[1]},
{ 0, 3, Beckhoff_EL1014, 0x6020, 1, &o_dig_in[2] , &bo_dig_out[2]},
{ 0, 3, Beckhoff_EL1014, 0x6030, 1, &o_dig_in[3] , &bo_dig_out[3]},
{ 0, 4, Beckhoff_EL1014, 0x6000, 1, &o_dig_in[4] , &bo_dig_out[4]},
{ 0, 4, Beckhoff_EL1014, 0x6010, 1, &o_dig_in[5] , &bo_dig_out[5]},
{ 0, 4, Beckhoff_EL1014, 0x6020, 1, &o_dig_in[6] , &bo_dig_out[6]},
{ 0, 4, Beckhoff_EL1014, 0x6030, 1, &o_dig_in[7] , &bo_dig_out[7]},
/* { 0, 1, Beckhoff_EL2004, 0x7000, 1, &o_dig_out[0], NULL}, */
/* { 0, 4, Beckhoff_EL1014, 0x6000, 1, &o_dig_in[0] , NULL}, */
{}
};
/***********************************************************************
* LOCAL FUNCTION DECLARATIONS *
************************************************************************/
void request_lock(void *data)
{
spin_lock(&master_lock);
}
void release_lock(void *data)
{
spin_unlock(&master_lock);
}
/*****************************************************************************/
EXTRA_SETUP() {
rtapi_print_msg(RTAPI_MSG_INFO,"Starting...\n");
//printk(KERN_INFO PFX "Starting...\n");
if (!(master = ecrt_request_master(0))) {
rtapi_print_msg(RTAPI_MSG_INFO,"BRequesting master 0 failed!\n");
//printk(KERN_ERR PFX "Requesting master 0 failed!\n");
goto out_return;
}
ecrt_master_callbacks(master, request_lock, release_lock, NULL);
rtapi_print_msg(RTAPI_MSG_INFO,"Registering domain...\n");
//printk(KERN_INFO PFX "Registering domain...\n");
if (!(domain1 = ecrt_master_create_domain(master))) {
rtapi_print_msg(RTAPI_MSG_INFO,"Domain creation failed!\n");
//printk(KERN_ERR PFX "Domain creation failed!\n");
goto out_release_master;
}
rtapi_print_msg(RTAPI_MSG_INFO,"Registering PDOs...\n");
//rintk(KERN_INFO PFX "Registering PDOs...\n");
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_pdo_regs)) {
rtapi_print_msg(RTAPI_MSG_INFO,"PDO registration failed!\n");
//printk(KERN_ERR PFX "PDO registration failed!\n");
goto out_release_master;
}
rtapi_print_msg(RTAPI_MSG_INFO,"Activating master...\n");
//printk(KERN_INFO PFX "Activating master...\n");
if (ecrt_master_activate(master)) {
rtapi_print_msg(RTAPI_MSG_INFO,"Failed to activate master!\n");
//printk(KERN_ERR PFX "Failed to activate master!\n");
goto out_release_master;
}
domain1_pd = ecrt_domain_data(domain1);
rtapi_print_msg(RTAPI_MSG_INFO,"Started.\n");
//printk(KERN_INFO PFX "Started.\n");
return 0;
out_release_master:
rtapi_print_msg(RTAPI_MSG_INFO,"Releasing master...\n");
//printk(KERN_ERR PFX "Releasing master...\n");
ecrt_release_master(master);
master= NULL;
out_return:
rtapi_print_msg(RTAPI_MSG_INFO,"Failed to load. Aborting.\n");
//printk(KERN_ERR PFX "Failed to load. Aborting.\n");
return -1;
}
EXTRA_CLEANUP() {
rtapi_print_msg(RTAPI_MSG_INFO,"Stopping...\n");
//printk(KERN_INFO PFX "Stopping...\n");
if (master) {
rtapi_print_msg(RTAPI_MSG_INFO,"Releasing master...\n");
//printk(KERN_INFO PFX "Releasing master...\n");
ecrt_release_master(master);
}
rtapi_print_msg(RTAPI_MSG_INFO,"Unloading.\n");
//printk(KERN_INFO PFX "Unloading.\n");
}
/*****************************************************/
/*****************************************************/
FUNCTION(update) {
// receive
spin_lock(&master_lock);
ecrt_master_receive(master);
ecrt_domain_process(domain1);
spin_unlock(&master_lock);
eingang_0 = EC_READ_BIT( domain1_pd+o_dig_in[0], bo_dig_in[0]);
eingang_1 = EC_READ_BIT( domain1_pd+o_dig_in[1], bo_dig_in[1]);
eingang_2 = EC_READ_BIT( domain1_pd+o_dig_in[2], bo_dig_in[2]);
eingang_3 = EC_READ_BIT( domain1_pd+o_dig_in[3], bo_dig_in[3]);
eingang_4 = EC_READ_BIT( domain1_pd+o_dig_in[4], bo_dig_in[4]);
eingang_5 = EC_READ_BIT( domain1_pd+o_dig_in[5], bo_dig_in[5]);
eingang_6 = EC_READ_BIT( domain1_pd+o_dig_in[6], bo_dig_in[6]);
eingang_7 = EC_READ_BIT( domain1_pd+o_dig_in[7], bo_dig_in[7]);
EC_WRITE_BIT(domain1_pd+o_dig_out[0], bo_dig_out[0], ausgang_0);
EC_WRITE_BIT(domain1_pd+o_dig_out[1], bo_dig_out[1], ausgang_1);
EC_WRITE_BIT(domain1_pd+o_dig_out[2], bo_dig_out[2], ausgang_2);
EC_WRITE_BIT(domain1_pd+o_dig_out[3], bo_dig_out[3], ausgang_3);
EC_WRITE_BIT(domain1_pd+o_dig_out[4], bo_dig_out[4], ausgang_4);
EC_WRITE_BIT(domain1_pd+o_dig_out[5], bo_dig_out[5], ausgang_5);
EC_WRITE_BIT(domain1_pd+o_dig_out[6], bo_dig_out[6], ausgang_6);
EC_WRITE_BIT(domain1_pd+o_dig_out[7], bo_dig_out[7], ausgang_7);
/* eingang_0= EC_READ_BIT( domain1_pd+o_dig_in[0],0); */
/* EC_WRITE_BIT(domain1_pd+o_dig_out[0],0,ausgang_0); */
spin_lock(&master_lock);
ecrt_master_state(master, &master_status);
spin_unlock(&master_lock);
if (master_status.al_states != old_status.al_states) {
rtapi_print_msg(RTAPI_MSG_INFO,"bus status changed to %i.\n", master_status.al_states);
}
if (master_status.slaves_responding !=
old_status.slaves_responding) {
rtapi_print_msg(RTAPI_MSG_INFO,"slaves_responding changed to %u.\n", master_status.slaves_responding);
}
old_status = master_status;
// send
spin_lock(&master_lock);
ecrt_domain_queue(domain1);
spin_unlock(&master_lock);
spin_lock(&master_lock);
ecrt_master_send(master);
spin_unlock(&master_lock);
}
If you want to compile the ethercat.comp file with latest version of linuxcnc it will not compile.
It has to do with librarie's, and much more. Okey a lot to solve in the component code.
Find out the error code's yourself : sudo halcompile --install ethercat.comp
My idea is to start working on a new ethercat.comp file.
If we get one good ehercat.comp file, that would also a very good Ethercat start option for today's linuxcnc user's i think.
A example : integrating ethercat in a custom made linuxcnc version is now a bit of a problem. In my opinion that is not documented before.
Here is my start of the new component, it compiles without issues :
description
"""
Ethercat Component
Modification list :
1. Changed include source from ethercat to etherlab
2. Start from zero
3. When writing a new component it is importand to use also "case" in programming style.
This will make a nice routing in the workflow of handling different senario's, like emergency stop,
and what to do in that senario.
Expanding "case" is very easy, just copy and rename a case, and add case name to typedef enum.
4. Don't us goto statements in your code.
5. In C style you can write your mind into the code.
""";
author "Grotius CNC Machines, started Oktober 2018";
license "GPL";
option singleton yes;
//Ethercat terminal hal connection :
//Servo hal connection :
//Stepper hal connection ;
//Input hal connection :
pin in bit Enable "Enable this ethercat component";
pin in bit Input_0 "Comment ....";
//Output hal connection :
pin out bit Ethercat_enabled "Connect to user gui led";
pin out bit Output_0 "Comment ....";
function _;
;;
#include "/opt/etherlab/include/ecrt.h"
// EtherCAT
static ec_master_t *master = NULL;
static ec_domain_t *domain1 = NULL;
//spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
static ec_master_state_t master_status, old_status = {};
// data fields
static uint8_t *domain1_pd; // process data memory
// offsets to data fields
static unsigned int o_dig_in[8], bo_dig_in[8];
static unsigned int o_dig_out[8], bo_dig_out[8];
// pdo definitions may be read from autogenerated file
//#include "ethercat_cstruct.c"
#define Beckhoff_EL2004 0x00000002, 0x07D43052
#define Beckhoff_EL1014 0x00000002, 0x03F63052
const static ec_pdo_entry_reg_t domain1_pdo_regs[] = {
{ 0, 1, Beckhoff_EL2004, 0x7000, 1, &o_dig_out[0], &bo_dig_in[0]},
{ 0, 1, Beckhoff_EL2004, 0x7010, 1, &o_dig_out[1], &bo_dig_in[1]},
{ 0, 1, Beckhoff_EL2004, 0x7020, 1, &o_dig_out[2], &bo_dig_in[2]},
{ 0, 1, Beckhoff_EL2004, 0x7030, 1, &o_dig_out[3], &bo_dig_in[3]},
{ 0, 2, Beckhoff_EL2004, 0x7000, 1, &o_dig_out[4], &bo_dig_in[4]},
{ 0, 2, Beckhoff_EL2004, 0x7010, 1, &o_dig_out[5], &bo_dig_in[5]},
{ 0, 2, Beckhoff_EL2004, 0x7020, 1, &o_dig_out[6], &bo_dig_in[6]},
{ 0, 2, Beckhoff_EL2004, 0x7030, 1, &o_dig_out[7], &bo_dig_in[7]},
{ 0, 3, Beckhoff_EL1014, 0x6000, 1, &o_dig_in[0] , &bo_dig_out[0]},
{ 0, 3, Beckhoff_EL1014, 0x6010, 1, &o_dig_in[1] , &bo_dig_out[1]},
{ 0, 3, Beckhoff_EL1014, 0x6020, 1, &o_dig_in[2] , &bo_dig_out[2]},
{ 0, 3, Beckhoff_EL1014, 0x6030, 1, &o_dig_in[3] , &bo_dig_out[3]},
{ 0, 4, Beckhoff_EL1014, 0x6000, 1, &o_dig_in[4] , &bo_dig_out[4]},
{ 0, 4, Beckhoff_EL1014, 0x6010, 1, &o_dig_in[5] , &bo_dig_out[5]},
{ 0, 4, Beckhoff_EL1014, 0x6020, 1, &o_dig_in[6] , &bo_dig_out[6]},
{ 0, 4, Beckhoff_EL1014, 0x6030, 1, &o_dig_in[7] , &bo_dig_out[7]},
};
typedef enum { INIT, SELECT} state_T;
state_T state = INIT;
FUNCTION(_) {
switch(state){
case INIT:
if(Enable){
Ethercat_enabled = 1;
state = SELECT; // If ethercat input is enabled the case function jump's to case SELECT:
}
if(!Enable){
Ethercat_enabled = 0;
state = INIT;
}
break;
case SELECT:
domain1_pd = ecrt_domain_data(domain1);
ecrt_master_receive(master);
ecrt_domain_process(domain1);
EC_WRITE_BIT(domain1_pd+o_dig_out[0], bo_dig_out[0], Output_0);
break;
}
}
Please Log in or Create an account to join the conversation.
it does actually help.
The /dev/Ethercat0 was already there but with some restrained permission so after a sudo chmod a+rwx Ethercat0, the linuxcnc 2.7 and linuxcnc 2.8 were able to carry on.The only issue is I have to do that everytime I log in as the permission seems not to be saved for some reason. Any idea about how I could make the permission permanent?
Edit: to make the /dev/EtherCAT0 usage permanent just do sudo adduser $USER ethercat, and/or sudo adduser root ethercat then you have to reboot (see post askubuntu.com/questions/373096/how-do-i-...ssions-for-dev-ttys0 for a similar case.)
However it did show another error for linuxcnc 2.8, which I believe is link to an error seen on the make of the linuxcnc-ethercat.
Using the linuxcnc-ethercat last commit:
commit b02252a79d11f1c9dd5884bac1a53743b3818d39
Merge: 22bcaa9 333dec5
Author: Sascha Ittner <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Date: Fri Aug 17 16:37:32 2018 +0200
Merge pull request #60 from sittner/add-fsoe-support
Add fsoe support
I obtain
LINUXCNC - 2.8.0~pre1
Machine configuration directory is '/home/laminator/linuxcnc/configs/LAMGUI'
Machine configuration file is 'lam.ini'
Starting LinuxCNC...
Found file(REL): ./lam-v1.hal
Note: Using POSIX realtime
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: rtapi_mutex_get
./lam-v1.hal:2: waitpid failed /usr/bin/rtapi_app lcec
./lam-v1.hal:2: /usr/bin/rtapi_app exited without becoming ready
./lam-v1.hal:2: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/laminator/linuxcnc_debug.txt
and
/home/laminator/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal
Using the linuxcnc-ethercat commit:
commit 7b1e4bb0bb0b5886486b98fc2511b2333402ad0d
Author: Sascha Ittner <This email address is being protected from spambots. You need JavaScript enabled to view it.>
Date: Sat Mar 10 10:03:44 2018 +0100
use linuxcnc's Makefile.modinc to build RT component
I obtain:
LINUXCNC - 2.8.0~pre1
Machine configuration directory is '/home/laminator/linuxcnc/configs/LAMGUI'
Machine configuration file is 'lam.ini'
Starting LinuxCNC...
Found file(REL): ./lam-v1.hal
Note: Using POSIX realtime
lcec: dlopen: /usr/lib/linuxcnc/modules/lcec.so: undefined symbol: ecrt_slave_config_sdo
./lam-v1.hal:2: waitpid failed /usr/bin/rtapi_app lcec
./lam-v1.hal:2: /usr/bin/rtapi_app exited without becoming ready
./lam-v1.hal:2: insmod for lcec failed, returned -1
Shutting down and cleaning up LinuxCNC...
Note: Using POSIX realtime
LinuxCNC terminated with an error. You can find more information in the log:
/home/laminator/linuxcnc_debug.txt
and
/home/laminator/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal
I believe this is related to the last post on github.com/sittner/linuxcnc-ethercat/issues/57 > and github.com/sittner/linuxcnc-ethercat/issues/61
Any idea how to avoid this error?
Thanks a lot for the help,
Nicolas
Please Log in or Create an account to join the conversation.
I have some news. Struggling with include files in hal.
Done some test's. I needed the "/opt/etherlab/include/ecrt.h" to work with linuxcnc hal. In hal we can couple a lot of stuff.
Nothing happened and linuxcnc refused to load dlopen .....
So i start from zero with a sucesfull test to that directory, to print some info.
Next thing will be integrating a bigger file.
in postgui.hal
loadrt ethercat
addf ethercat servo-thread
ethercat component, ethercat.comp :
(compiled in terminal by : sudo halcompile --install ethercat.comp)
component ethercat"ethercat";
description
"""
Test Component
""";
author "Grotius CNC Machines, started Oktober 2018";
license "GPL";
option singleton yes;
//Input hal connection :
pin in bit Testpin_in "Enable this component";
//Output hal connection :
pin out bit Testpin_out "Connect to user gui led";
function _;
;;
#include <stdio.h>
#include "/opt/etherlab/include/external_file.h"
typedef enum { INIT, SELECT} state_T;
state_T state = INIT;
FUNCTION(_) {
switch(state){
case INIT:
state = SELECT;
break;
case SELECT:
// do something with the include file
function_print();
break;
}
}
The external_file.h is located in directory : /opt/etherlab/include/external_file.h
The file below is : external_file.h (it is a short file, only containing a function with a print message, for fun, function is in fact : () )
Inside the function we say only print some info :
#include<stdio.h>
int function_print()
{
printf("external file print");
return 0;
}
Output in linuxcnc terminal :
So i think this is a first start to use Ethercat to Linuxcnc hal for me.
Please Log in or Create an account to join the conversation.
Please refer to IgH Master 1.5.2 Documentation Chapter 9.5
The device nodes will be created with mode 0660 and group root by default. If “nor-
mal” users shall have reading access, a udev rule file (for example /etc/udev/rules.d/99-
EtherCAT.rules) has to be created with the following contents:KERNEL ==" EtherCAT [0 -9]*" , MODE ="0664"
Then you can use that device as non-root user.
Regards
Bryan
Please Log in or Create an account to join the conversation.
@ Chimeno
edit the file "lcec_el40x4.h" add the PID number yourself, from where you get it, then the terminal executes this command "ethercat slave -v" will leave the "product code" that is, you also have to add the module to the following files, "Kbuild, lcec_conf.h, lcec_conf.c, lcec_main.c, I think that is everything, if you have more questions ask me, I will try to help you.
regards
Chimeno
I've followed these instructions, ran make, make install, reboot but I only get two out of four channels coming up. Any idea? Bad terminal?
Kind regards,
Dan
Hello dan,
I've been very busy with projects, now I have some free time, have you gotten it to work?
regards
Chimeno
Please Log in or Create an account to join the conversation.
- sqmathlete
- Offline
- Premium Member
- Posts: 118
- Thank you received: 17
Unfortunately no, I ended up ordering an EL4102 from ebay since I knew it was already supported and I only need one channel anyways. Worked perfect.
If you have any suggestions I'll go back and try again though. Would be nice to expand the library of supported devices.
Kind regards
Dan
Please Log in or Create an account to join the conversation.
@chimeno
Unfortunately no, I ended up ordering an EL4102 from ebay since I knew it was already supported and I only need one channel anyways. Worked perfect.
If you have any suggestions I'll go back and try again though. Would be nice to expand the library of supported devices.
Kind regards
Dan
Hello dan,
I will revise the files that I have made of the previous project, I will do a little cleaning of them and I will post them here, if it is a good idea to expand the library!
Regards, Chimeno
Please Log in or Create an account to join the conversation.
I think tomorrow i recieve the beckhoff ethercat module.
I will try to merge the ethercat into a current linuxcnc version with already the
external offset branche and reverse run branche included. This i have done 6 month's ago, with succes after a learning periode.
My strategy is first make it run with the current linuxcnc ethercat github version on a separate
hard disk. I am working normally on 64 bit debian stretch. So that is the goal to reach.
After this is succeeded, i will try to find the importand code differences between both versions and merge it finaly into the current linuxcnc version. I cross my finger's coming weeks. If we do that in Github, we can see the code differences quite ease. I think
maybe it will succeed at once. But when not compiling, we can do it again. And finaly it will succeed i hope so.
I have some expience with previous merged version's. Even the master programmer's have problem's to merge the reverse run from Rob Ellenberg. I did it in 3 attemp's. So i have good hope that it will succeed.
But when i begin this, it can be i have to solve difficult problem's.
Please Log in or Create an account to join the conversation.
Hi,
I think tomorrow i recieve the beckhoff ethercat module.
I will try to merge the ethercat into a current linuxcnc version with already the
external offset branche and reverse run branche included. This i have done 6 month's ago, with succes after a learning periode.
My strategy is first make it run with the current linuxcnc ethercat github version on a separate
hard disk. I am working normally on 64 bit debian stretch. So that is the goal to reach.
After this is succeeded, i will try to find the importand code differences between both versions and merge it finaly into the current linuxcnc version. I cross my finger's coming weeks. If we do that in Github, we can see the code differences quite ease. I think
maybe it will succeed at once. But when not compiling, we can do it again. And finaly it will succeed i hope so.
I have some expience with previous merged version's. Even the master programmer's have problem's to merge the reverse run from Rob Ellenberg. I did it in 3 attemp's. So i have good hope that it will succeed.
But when i begin this, it can be i have to solve difficult problem's.
Hello Grotius,
It's great, I've been using the 2.7 branch, now I want to try the master branch, I think it's great what you're doing with linuxcnc, I hope I can help you as much as I can, even though I'm not a born programmer.
Regards, Chimeno
Please Log in or Create an account to join the conversation.
Me too no born programmer. If i was the founder of programming language, it was looking more easyer.
Bit's and byte's are zero and one's in machine language. Why not implementing more characters? Then we could do much more.
I think that will come if arteficial intellegence will design a new machine language. And that all is done in second's.
I have an idea. Tomorrow i wil open a new ethercat github channel with the linuxcnc version i own, the version with the advantage's.
It's a new github user space. I will provide the password's over here. Then every ethercat fan can try to merge it by his own.
I will make a text file how you could copy/clone the orginal one into your test version... And how merging works.
Maybe that is a good idea. Many of you are capable to merge this for sure.
Here comes the data to enter the github channel : forum.linuxcnc.org/cb-profile/pluginclas...gs&func=show&id=1276
Please Log in or Create an account to join the conversation.