You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone, I need help! I used a Linux environment to drive Soem1.3.1, and I modified the code based on Simple_test. c. This code was once able to operate the position mode of the motor smoothly on an Envision motor, but after changing to SV660n, it has not been able to solve the error related to SDO writing: ERROR: SDO write failed for slave 1, index 0x1600, subindex 0x03, I guess this is also the reason why: Slave 1 State=0x14 StatusCode=0x0027 : Freerun not supported。
This is my Simple_test c:
`//移植自1.4 将ethercat.h暂展开
/*
Licensed under the GNU General Public License version 2 with exceptions. See
LICENSE file in the project root for full license information
*/
Hello everyone, I need help! I used a Linux environment to drive Soem1.3.1, and I modified the code based on Simple_test. c. This code was once able to operate the position mode of the motor smoothly on an Envision motor, but after changing to SV660n, it has not been able to solve the error related to SDO writing: ERROR: SDO write failed for slave 1, index 0x1600, subindex 0x03, I guess this is also the reason why: Slave 1 State=0x14 StatusCode=0x0027 : Freerun not supported。
This is my Simple_test c:
`//移植自1.4 将ethercat.h暂展开
/*
*/
/** \file
*/
#ifndef _EC_ETHERCAT_H
#define _EC_ETHERCAT_H
#include "ethercattype.h"
#include "nicdrv.h"
#include "ethercatbase.h"
#include "ethercatmain.h"
#include "ethercatdc.h"
#include "ethercatcoe.h"
#include "ethercatfoe.h"
#include "ethercatsoe.h"
//#include "ethercateoe.h"
#include "ethercatconfig.h"
#include "ethercatprint.h"
#endif /* _EC_ETHERCAT_H */
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
#include <signal.h>
#define EC_TIMEOUTMON 500
#define DEBUG 1 // 设置为1以启用调试,设置为0则关闭调试
// 定义IO映射
char IOmap[12800];
OSAL_THREAD_HANDLE thread1;
int expectedWKC;
boolean needlf;
volatile int wkc;
boolean inOP;
uint8 currentgroup = 0;
// 全局变量,用于控制主循环的终止
volatile sig_atomic_t stop = 0;
typedef struct PACKED {
uint16 controlword; // 6040
int32 targetPostion; // 607A
int32 targetSpeed; // 60FF
int16 targetnu;
} PDO_Output;
typedef struct PACKED {
uint16 statusWord; // 6041
int32 actualPostion; // 6064
int32 actualSpeed; // 606C
int16 actualnu;
} PDO_Input;
PDO_Output *outputs1;
PDO_Input *inputs1;
// 调试打印函数
void debug_print(const char* msg) {
if (DEBUG) {
printf("%s\n", msg);
}
}
// 信号处理函数
void handle_sigint(int sig)
{
(void)sig; // 声明参数已被使用
stop = 1;
}
// SDO写操作的错误检查(增加详细的错误信息)
int sdo_write_safe(uint16 slave, uint16 index, uint8 subindex, void *data, int size) {
int ret = ec_SDOwrite(slave, index, subindex, FALSE, size, data, EC_TIMEOUTRXM);
}
// 设置PDO映射
void INVT_DA180_setup(uint16 slave) {
uint8 u8val;
uint16 u16val;
uint32 u32val;
short i16val;
}
// EtherCAT 状态控制
void EtherCAT_ctrl_state(void) {
switch (outputs1->controlword) {
case 0:
outputs1->controlword = 6; // Shutdown
break;
}
void simpletest(char *ifname) {
printf("\ntest_for_onlyoneslave\n");
int i,j, oloop, iloop, chk;
needlf = FALSE;
inOP = FALSE;
/*
oloop = ec_slave[0].Obytes;
if ((oloop == 0) && (ec_slave[0].Obits > 0)) oloop = 1;
if (oloop > 8) oloop = 8;
*/
}
else
{
printf("No socket connection on %s\nExcecute as root\n", ifname);
}
}
OSAL_THREAD_FUNC ecatcheck(void ptr)
{
int slave;
(void)ptr; / Not used */
while (1)
{
if (inOP && ((wkc < expectedWKC) || ec_group[currentgroup].docheckstate))
{
if (needlf)
{
needlf = FALSE;
printf("\n");
}
/* one ore more slaves are not responding /
ec_group[currentgroup].docheckstate = FALSE;
ec_readstate();
for (slave = 1; slave <= ec_slavecount; slave++)
{
if ((ec_slave[slave].group == currentgroup) && (ec_slave[slave].state != EC_STATE_OPERATIONAL))
{
ec_group[currentgroup].docheckstate = TRUE;
if (ec_slave[slave].state == (EC_STATE_SAFE_OP + EC_STATE_ERROR))
{
printf("ERROR : slave %d is in SAFE_OP + ERROR, attempting ack.\n", slave);
ec_slave[slave].state = (EC_STATE_SAFE_OP + EC_STATE_ACK);
ec_writestate(slave);
}
else if (ec_slave[slave].state == EC_STATE_SAFE_OP)
{
printf("WARNING : slave %d is in SAFE_OP, change to OPERATIONAL.\n", slave);
ec_slave[slave].state = EC_STATE_OPERATIONAL;
ec_writestate(slave);
}
//else if (ec_slave[slave].state > EC_STATE_NONE)
else if (ec_slave[slave].state > 0)
{
if (ec_reconfig_slave(slave, EC_TIMEOUTMON))
{
ec_slave[slave].islost = FALSE;
printf("MESSAGE : slave %d reconfigured\n", slave);
}
}
else if (!ec_slave[slave].islost)
{
/ re-check state */
ec_statecheck(slave, EC_STATE_OPERATIONAL, EC_TIMEOUTRET);
//if (ec_slave[slave].state == EC_STATE_NONE)
if (ec_slave[slave].state == 0)
{
ec_slave[slave].islost = TRUE;
printf("ERROR : slave %d lost\n", slave);
}
}
}
if (ec_slave[slave].islost)
{
//if (ec_slave[slave].state == EC_STATE_NONE)
if (ec_slave[slave].state == 0)
{
if (ec_recover_slave(slave, EC_TIMEOUTMON))
{
ec_slave[slave].islost = FALSE;
printf("MESSAGE : slave %d recovered\n", slave);
}
}
else
{
ec_slave[slave].islost = FALSE;
printf("MESSAGE : slave %d found\n", slave);
}
}
}
if (!ec_group[currentgroup].docheckstate)
printf("OK : all slaves resumed OPERATIONAL.\n");
}
osal_usleep(10000);
}
}
int main(int argc, char *argv[])
{
printf("SOEM (Simple Open EtherCAT Master)\nSimple test\n");
// 注册信号处理器
//signal(SIGINT, handle_sigint);
if (argc > 1)
{
/* create thread to handle slave error handling in OP */
// pthread_create( &thread1, NULL, (void ) &ecatcheck, (void) &ctime);
osal_thread_create(&thread1, 128000, &ecatcheck, (void )&ctime);
printf("EtherCAT Master initializing on %s\n", argv[1]);
/ start cyclic part */
simpletest(argv[1]);
}
else
{
printf("Usage: simple_test ifname1\nifname = eth0 for example\n");
}
printf("End program\n");
return (0);
}`
And here is my print debugging information:
The text was updated successfully, but these errors were encountered: