Monitoring EtherCAT

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi,

My project spec calls for dynamic usage monitoring and reporting (0 to 100%), of each comms line.
I'm fine for my Serial, CAN, and Ethernet lines, I've got the code done.
But I'm stuck on EtherCAT, in terms of where to insert the necessary 'accumulator' code, within the EtherCAT SSC (Slave Stack Code).
I'm happy to count bytes, or frames, both are fine.
I'm happy to do so myself, or use some built-in counters if they exist, or use a hybrid approach.
But I do need to count all incoming and outgoing activity, regardless of which EtherCAT feature, is being used.
Can anyone direct me to the relevant places, within the SSC code ?
I've been trawling through it all morning, also the Infineon XMC43 manual, and the Beckhoff Application Note ET9300.
Nothing on the forum or google.

Best regards,

David King
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi David,

Please have a look at Diagnostics with EtherCAT: monitoring of master/slaves.
You have available error counters built in hardware, look to error counters section in the register description of the reference manual.

Regards,
Jesus
0 Likes
Not applicable
Hi Jesus,

Many thanks for the link, it made for an interesting read. Apologies I've not responded earlier.

Unfortunately, it didn't quite accord with what I've been asked to report on. But meanwhile, I've made *some* progress:

The code I have is almost wholly based on the DAVE example project for EtherCAT.

With this, I have the PC Visual Studio 2010 based TwinCAT 3 (TC3) EtherCAT master, set to the maximum Freerun Cycle figure, of 1ms.

Within the XMC4300 code, I call the EtherCAT Slave Stack Code (SSC) 'MainLoop' function, every 1ms, per the example project.

I first tried looking at how often the SSC calls back to the example project 'process_app' function, where the data to be sent and received via EtherCAT, is populated.

I found that 'process_app' is called every 1ms. I though, ah ha, from that, I can calculate the usage of the comms line.

But then, I tried 'pulling' the comms line, and found that 'process_app' continues to be called every 1ms!

And further, if I tried altering the 'MainLoop' call interval, from 1ms to say 2ms, then the 'process_app' call interval likewise changes, from 1ms to 2ms.

Argh! So seems that it's just 'MainLoop' that calls-back to 'process_app'!

I then tried looking deeper, and found the following, within the DAVE generated ECAT_SSC APP xmc_eschw.c file. And found it is the below,
that is called with 1ms interval, presumably at or soon after the start of each packet as it passes through. And that if I pull the comms line,
the below stops being called. And if I alter TC3, from 1ms to say 4ms, then the below is likewise called with 4ms interval.

/* ECAT slave interrupt handler function */
void ECAT0_0_IRQHandler(void)
{
PDI_Isr();
}

Further, 'PDI_Isr' also calls 'process_app'. So seems, with EtherCAT, there are two calls to 'process_app'. But the call from 'MainLoop', seems to serve no purpose..

Anyway, I can now insert after the 'PDI_Isr( )' call, a simple counter. And from that, determine the bits flowing. Without going into too much
detail, and with due acknowledgement to Wireshark, which I'd not used before, I reached the following conclusion:

With just my XMC4300 EtherCAT slave on the line, my data, as populated in 'process_app', is a total of 512 bits. And that is framed by a total of 688 bits. Making a grand total of 1200 bits.

But my question is, what would the grand total be if there were 2 slaves on the bus? 5? 10? Etc? Indeed, those slaves could be another
product, by our company, or any other company.

In other words, is there anyway of finding out, the simple total size, of an EtherCAT packet, flowing through the XMC4300 ?

I imagine, that is 'known', deep within the XMC4300 silicon. But maybe, that information just can't be 'got out', through any of the EtherCAT registers, or any other means.

It'd be a pity though to admit defeat, if the information can infact be had..

I was mentioning that I need to count all incoming and outgoing activity, regardless of which EtherCAT feature, is being used. I *believe* 'void ECAT0_0_IRQHandler(void)' is the sole place I will see activity. Certainly if I add a breakpoint to 'void SYNC0IRQHandler(void)' and 'void SYNC1IRQHandler(void)' from the example project, the breakpoints never trigger, even after several days running. So correct me if I'm wrong, but I don't *think* synchronization is occurring. Perhaps the example code is configured with synchronization disabled. I don't know if that's a good thing, or a bad thing.

To finish, a couple of technical details:

The 688 is the entire bit load, from the start of the 7-octet Layer 1 Ethernet packet preamble, to the end of the 12-octet Interpacket Gap.
The actual 512 bits, looks to sit within a 'Logical Read' datagram frame.

Interestingly, it's the middle of 3 frames within the packet (thanks Wireshark). The preceding frame, is another 'Logical Read' (address 0x9000000 len 1 byte). And the following frame, is a 'Broadcast Read' datagram (slave address 1, offset address 0x130, len 2 bytes).

Perhaps, those two frame are always there. And it's the middle frame, that there would be eg 3 instances of, if there were 3 slaves on the line..

Best regards,

David
0 Likes