[Etherlab-users] Problems with PDOs registration into the domain
Personale
vincenzopagliacci at libero.it
Sun May 12 17:14:30 CEST 2024
Good morning everyone,
I’m trying to configure my ethercat network between my raspberryPi 4, and my Elmo Gold Solo Twitter.
I’m facing a problem into trying to register the pdos into the domain. It seems that whichever pdo I insert into the ec_pdo_entry_reg_t variable I always get the same values. Here I attach my snipped code
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <time.h> /* clock_gettime() */
#include <sys/mman.h> /* mlockall() */
#include <sched.h> /* sched_setscheduler() */
#include <signal.h>
#include "ecrt.h"
#define DriverSlavePos 0, 0
#define Elmo_GoldTwitter 0x0000009a, 0x00030924
#define MAX_SAFE_STACK (8 * 1024) /* The maximum stack size which is
guranteed safe to access without
faulting */
#define TxPDO_LEN 3
#define RxPDO_LEN 8
volatile sig_atomic_t keepRunning = 1;
static ec_master_t *master = NULL;
static ec_master_state_t master_state = {};
static ec_domain_t *domain = NULL;
static ec_domain_state_t domain_state = {};
static ec_slave_config_t *sc_ana_in = NULL;
static ec_slave_config_state_t sc_ana_in_state = {};
static uint8_t *domain_pd = NULL;
static unsigned int off_elm[TxPDO_LEN+RxPDO_LEN];
static const ec_pdo_entry_info_t elmo_pdo_entries[] = {
{0x6040, 0, 16}, // Control Word
{0x6060, 0, 8}, // Modes of Operation
{0x60FF, 0, 32}, // Target Velocity
{0x2041, 0, 32}, // Timestamp
{0x606C, 0, 32}, // Actual Velocity
{0x6041, 0, 16}, // Status Word
{0x6061, 0, 8}, // Modes of Operation Display
{0x6064, 0, 32}, // Actual Position
{0x6077, 0, 16}, // Actual Torque
{0x22A3, 1, 16}, // Drive Temperature
{0x6078, 0, 16}, // Actual Current
};
#define PDO_ENTRY_STRUCT(i) {DriverSlavePos, Elmo_GoldTwitter, elmo_pdo_entries[i].index, elmo_pdo_entries[i].subindex, off_elm + i}
const static ec_pdo_entry_reg_t domain_regs[] = {
PDO_ENTRY_STRUCT(0),
PDO_ENTRY_STRUCT(1),
PDO_ENTRY_STRUCT(2),
PDO_ENTRY_STRUCT(3),
PDO_ENTRY_STRUCT(4),
PDO_ENTRY_STRUCT(5),
PDO_ENTRY_STRUCT(6),
PDO_ENTRY_STRUCT(7),
PDO_ENTRY_STRUCT(8),
PDO_ENTRY_STRUCT(9),
PDO_ENTRY_STRUCT(10),
{}
};
static ec_pdo_info_t elmo_pdos[] = {
{0x1600, TxPDO_LEN, elmo_pdo_entries},
{0x1A00, RxPDO_LEN, elmo_pdo_entries + TxPDO_LEN},
};
static ec_sync_info_t elmo_syncs[] = {
{2, EC_DIR_OUTPUT, 1, elmo_pdos},
{3, EC_DIR_INPUT, 1, elmo_pdos + 1},
{0xff}
};
By running the code and using the command line “ethercat domain —verbose” I see always the same domain values, independently if I change the order of the “domain_reg” inputs.
Is it normal? Where am I mistaken?
Thank you very much in advance for the help.
More information about the Etherlab-users
mailing list