Closed Vjinqu closed 1 month ago
Your slave has a well know firmware bug where it mixes up the inputs/outputs with SM association. From above:
SM0 A:1000 L: 128 F:00010026 Type:1
SM1 A:1080 L: 128 F:00010022 Type:2
SM2 A:1100 L: 8 F:00010064 Type:4
SM3 A:1400 L: 2 F:00010020 Type:3
The types should actually be SM2 type 3 and SM3 type 4. SOEM just follows the description the slave reports.
You can circumvent this by manually modifying the response coming from that particular slave.
Of course using slaves with these kind of bugs do question the quality of the firmware. I would not support such a manufacturer if they do not promptly fix their bugs.
Thank you for your quick response, I do appreciate it. I found the same problem in #423 and #224 yesterday, and followed to modify ethercatcoe file , and it worked. But the problem ( Not all slaves reached safe operational state. )remains unresolved. There seem to be other undiscovered problems.
the new slaveinfo imformation: SOEM (Simple Open EtherCAT Master) Slaveinfo Starting slaveinfo ecinit on \Device\NPF{C2F61E97-62B7-4935-8427-BBE4866515A2} succeeded. 1 slaves found and configured. Calculated workcounter 2 Not all slaves reached safe operational state. Slave 1 State=12 StatusCode= 1e : Invalid input configuration
Slave:1 Name:EC-DO64 Output size: 64bits Input size: 0bits State: 18 Delay: 0[ns] Has DC: 1 DCParentport:0 Activeports:1.0.0.0 Configured address: 1001 Man: 00000af0 ID: 20240510 Rev: 20240510 SM0 A:1000 L: 128 F:00010026 Type:1 SM1 A:1080 L: 128 F:00010022 Type:2 SM2 A:1100 L: 8 F:00010064 Type:3 SM3 A:1400 L: 2 F:00010020 Type:4 FMMU0 Ls:00000000 Ll: 8 Lsb:0 Leb:7 Ps:1100 Psb:0 Ty:02 Act:01 FMMUfunc 0:1 1:2 2:3 3:0 MBX length wr: 128 rd: 128 MBX protocols : 04 CoE details: 23 FoE details: 00 EoE details: 00 SoE details: 00 Ebus current: 0[mA] only LRD/LWR:0 PDO mapping according to CoE : SM2 inputs addr b index: sub bitl data_type name [0xD00E1BC0.0] 0x7000:0x01 0x10 UNSIGNED16 OUTPUT1 [0xD00E1BC2.0] 0x7000:0x02 0x10 UNSIGNED16 OUTPUT2 [0xD00E1BC4.0] 0x7000:0x03 0x10 UNSIGNED16 SubIndex 003 [0xD00E1BC6.0] 0x7000:0x04 0x10 UNSIGNED16 SubIndex 004 SM3 outputs addr b index: sub bitl data_type name End slaveinfo, close socket End program
new slaveinfo wireshark here: EC_DO64 modify ethercatcoe.zip
I don't know if it matters that this place is wrong.
I tried to modify 0x1c00 by using ec_slave[slc].PO2SOconfig = &ECDO64setup because I knew 0x1c00 should be 1234, but I got an error the slaveinfo sdo 0x1c00 the error my code
int ECDO64setup(uint16 slave)
{
int retval;
uint8 u8val;
uint16 u16val;
uint32 u32val;
retval = 0;
u8val = 0;
retval += ec_SDOwrite(slave, 0x1c00, 0x00, FALSE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 1;
retval += ec_SDOwrite(slave, 0x1c00, 0x01, FALSE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 2;
retval += ec_SDOwrite(slave, 0x1c00, 0x02, FALSE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 3;
retval += ec_SDOwrite(slave, 0x1c00, 0x03, FALSE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 4;
retval += ec_SDOwrite(slave, 0x1c00, 0x04, FALSE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 4;
retval += ec_SDOwrite(slave, 0x1c00, 0x00, FALSE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
ec_slave[slave].SMtype[2] = 3;
ec_slave[slave].SMtype[3] = 4;
while(EcatError) printf("%s", ec_elist2string());
qDebug()<< "ECDO64 setup slave" << slave << "set, retval = " << retval;
return 1;
}
void simpletest(char *ifname)
{
char ifbuff[51] = "\\Device\\NPF_{C2F61E97-62B7-4935-8427-BBE4866515A2}";
char* ifbuf = ifbuff;
ifname = ifbuff;
int i, j, oloop, iloop, wkc_count, chk, slc;
UINT mmResult;
needlf = FALSE;
inOP = FALSE;
qDebug("Starting simple test\n");
/* initialise SOEM, bind socket to ifname */
if (ec_init(ifname))
{
qDebug() << "ec_init on "<< ifname << " succeeded.";
/* find and auto-config slaves */
if ( ec_config_init(FALSE) > 0 )
{
qDebug() << ec_slavecount << " slaves found and configured.";
if((ec_slavecount > 0))
{
for(slc = 1; slc <= ec_slavecount; slc++)
{
if((ec_slave[slc].eep_man == 0x00000af0) && (ec_slave[slc].eep_id == 0x20240510))
{
qDebug() << "Found " << ec_slave[slc].name << "at position "<< slc;
// link slave specific setup to preop->safeop hook
ec_slave[slc].PO2SOconfig = &ECDO64setup;
}
}
}
for (int i = 1; i <= ec_slavecount; i++) {
ec_slave[i].blockLRW = 1; /* blocking LRW command */
}
int iomapsize = ec_config_map(&IOmap);
qDebug() << "iomapsize = "<<iomapsize;
ec_configdc();
qDebug("Slaves mapped, state to SAFE_OP.");
/* wait for all slaves to reach SAFE_OP state */
ec_statecheck(0, EC_STATE_SAFE_OP, EC_TIMEOUTSTATE * 4);
oloop = ec_slave[0].Obytes;
if ((oloop == 0) && (ec_slave[0].Obits > 0)) oloop = 1;
if (oloop > 8) oloop = 8;
iloop = ec_slave[0].Ibytes;
if ((iloop == 0) && (ec_slave[0].Ibits > 0)) iloop = 1;
if (iloop > 8) iloop = 8;
qDebug() << "segments : " << ec_group[0].nsegments << " : "<< ec_group[0].IOsegment[0] << " : "<< ec_group[0].IOsegment[1] << " : "<< ec_group[0].IOsegment[2] << " : "<< ec_group[0].IOsegment[3];
qDebug("Request operational state for all slaves");
expectedWKC = (ec_group[0].outputsWKC * 2) + ec_group[0].inputsWKC;
qDebug() << "Calculated workcounter " << expectedWKC;
ec_slave[0].state = EC_STATE_OPERATIONAL;
/* send one valid process data to make outputs in slaves happy*/
ec_send_processdata();
int wkc3=0;
wkc3 = ec_receive_processdata(EC_TIMEOUTRET);
qDebug() << "wkc3=" << wkc3;
/* start RT thread as periodic MM timer */
mmResult = timeSetEvent(80, 0, RTthread, 0, TIME_PERIODIC);
/* request OP state for all slaves */
ec_writestate(0); // if slave = 0 then write to all slaves
chk = 200;
/* wait for all slaves to reach OP state */
do
{
ec_statecheck(0, EC_STATE_OPERATIONAL, 50000); // Check actual slave state.
}
while (chk-- && (ec_slave[0].state != EC_STATE_OPERATIONAL));
if (ec_slave[0].state == EC_STATE_OPERATIONAL )
{
qDebug("Operational state reached for all slaves.\n");
wkc_count = 0;
inOP = TRUE;
/* cyclic loop, reads data from RT thread */
while(1)
{
if(wkc >= expectedWKC)
{
printf("Processdata cycle %4d, WKC %d , O:", rtcnt, wkc);
for(j = 0 ; j < oloop; j++)
{
printf(" %2.2x", *(ec_slave[1].outputs + j));
}
printf(" I:");
for(j = 0 ; j < iloop; j++)
{
printf(" %2.2x", *(ec_slave[1].inputs + j));
}
printf(" T:%lld\r",ec_DCtime);
needlf = TRUE;
}
osal_usleep(50000);
}
inOP = FALSE;
}
else
{
qDebug("Not all slaves reached operational state.");
ec_readstate();
for(i = 1; i<=ec_slavecount ; i++)
{
if(ec_slave[i].state != EC_STATE_OPERATIONAL)
{
qDebug()<< "Slave" << i << "State=" << QString("0x%1").arg(ec_slave[i].state,0 ,16) << "StatusCode=" << QString("0x00%1").arg(ec_slave[i].ALstatuscode, 0 ,16)<< ":" << ec_ALstatuscode2string(ec_slave[i].ALstatuscode);
}
}
}
/* stop RT thread */
timeKillEvent(mmResult);
qDebug("Request init state for all slaves");
ec_slave[0].state = EC_STATE_INIT;
/* request INIT state for all slaves */
ec_writestate(1);
}
else
{
printf("No slaves found!\n");
}
qDebug("End simple test, close socket");
/* stop SOEM, close socket */
ec_close();
}
else
{
printf("No socket connection on %s\nExcecute as root\n",ifname);
}
}
simple_test wireshark here: simple_test_SDOwriteERROR.zip
Next, I tried to change the CA parameter of ec_SDOwrite to TRUE, but there was a new ERROR code:
u8val = 0;
retval += ec_SDOwrite(slave, 0x1c00, 0x00, TRUE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 1;
retval += ec_SDOwrite(slave, 0x1c00, 0x01, TRUE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 2;
retval += ec_SDOwrite(slave, 0x1c00, 0x02, TRUE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 3;
retval += ec_SDOwrite(slave, 0x1c00, 0x03, TRUE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 4;
retval += ec_SDOwrite(slave, 0x1c00, 0x04, TRUE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
u8val = 4;
retval += ec_SDOwrite(slave, 0x1c00, 0x00, TRUE, sizeof(u8val), &u8val, EC_TIMEOUTRXM);
error :
Status 12 indicates a malfunction during the PREOP->SAfeOP. I am new to ethercat and can't analyze wireshark data, I didn't know what to do next. can you help me.
int ECDO64setup(uint16 slave)
{
// force SM types to SM2 = outputs and SM3 = inputs
ec_slave[slave].SMtype[2] = 3;
ec_slave[slave].SMtype[3] = 4;
// force SM3 to length 0 and not enabled.
ec_slave[slave].SM[3].SMlength = 0;
ec_slave[slave].SM[3].SMflags = 0;
qDebug()<< "ECDO64 setup slave" << slave;
return 1;
}
This should do it.
It is no use writing to a read only object as you tried in your code. That is why you get the error messages.
The manufacturer has some bugs in the firmware SDO descriptions. They fixed it in the XML (sort of) so TwinCAT works. I regard this company as incompetent EtherCAT suppliers.
Wow, that's it. After setting up the SMlength and SMflags, the slave can output correctly ! My main problem is solved. Thank you very much for your reply, ArthurKetels.
Another, I see that other issues can set 0x1c12 or other object(read only), but every time I try to appear the above error, is the hardware set read-only caused by unchangeable, or where not set well?
Hi, I had use SOEM with Beckhoff IOs sucessfully, but with EC_DO64 I have problems. EC_DO64 is slave with only 64-bit output. however,I found the output IO in slaveinfo changed to the input IO,why? I looked for many issues but didn't find the same problem. I tried similar issues, but it always prompt : Invalid input configuration.
here is the slaveinfo imformation SOEM (Simple Open EtherCAT Master) Slaveinfo Starting slaveinfo ecinit on \Device\NPF{C2F61E97-62B7-4935-8427-BBE4866515A2} succeeded. 1 slaves found and configured. Calculated workcounter 1 Not all slaves reached safe operational state. Slave 1 State=12 StatusCode= 1e : Invalid input configuration
Slave:1 Name:EC-DO64 Output size: 0bits Input size: 64bits State: 18 Delay: 0[ns] Has DC: 1 DCParentport:0 Activeports:1.0.0.0 Configured address: 1001 Man: 00000af0 ID: 20240510 Rev: 20240510 SM0 A:1000 L: 128 F:00010026 Type:1 SM1 A:1080 L: 128 F:00010022 Type:2 SM2 A:1100 L: 8 F:00010064 Type:4 SM3 A:1400 L: 2 F:00010020 Type:3 FMMU0 Ls:00000000 Ll: 8 Lsb:0 Leb:7 Ps:1100 Psb:0 Ty:01 Act:01 FMMUfunc 0:1 1:2 2:3 3:0 MBX length wr: 128 rd: 128 MBX protocols : 04 CoE details: 23 FoE details: 00 EoE details: 00 SoE details: 00 Ebus current: 0[mA] only LRD/LWR:0 PDO mapping according to CoE : SM2 inputs addr b index: sub bitl data_type name [0x0000.0] 0x7000:0x01 0x10 UNSIGNED16 OUTPUT1 [0x0002.0] 0x7000:0x02 0x10 UNSIGNED16 OUTPUT2 [0x0004.0] 0x7000:0x03 0x10 UNSIGNED16 SubIndex 003 [0x0006.0] 0x7000:0x04 0x10 UNSIGNED16 SubIndex 004 SM3 outputs addr b index: sub bitl data_type name End slaveinfo, close socket End program
Here is the xml file、wireshark capturing and slaveinfo -sdo EC_DO64.zip
I know there may be a problem with the firmware, but can we solve it through software configuration, after all, twincat can make it work through xml. Any suggestions for us, thank you.