industrialNETworXnetx

sandmann

sandmann

| 27.08.2010 | 10:10 | 6 replies

EtherCAT master stack buffering

I have a question about the buffering mechanism of the cifX 50-RE master stack.

If I am not mistaken, the Ethercat master stack stores the process data of all successfull bus cycles in an internal buffer. If I want to read this data, I have to toggle an input handshake flag, then the stack copies the data to the DPM input data image. After this, I can copy the DPM input image for myself, then I have to give back the control to the stack. If I use the driver, it does all this for me.

My question is: is the internal buffer a simple triple buffer, or can it store more than 3 bus cycles? If it is a triple buffer, how can I manage under Windows to store all the data?

The problem is, that under Windows, I can't read the process image that often. The scheduler has a 10 ms granularity, so if the data acquisition task has normal priority, it can be interrupted for 10-s of milliseconds, and I miss some bus-cycles accordingly. If the task is high priority (or real-time priority) and I keep reading with xChannelIORead() in a cycle, no normal task can interrupt it, so the user interface will freeze.

Is there a solution to store all the bus-cycles under Windows? Does the driver do some internal buffering, or it is just a simple interface to read the dual-port memory?

thx.
sandmann

Johnny

Johnny

| 30.08.2010 | 15:46

Hello Sandmann,
to clearify the "triple buffer" mechanism:
this buffer allows to get always the LAST received data, not the three last cycles. A double buffer is not enough, because this causes blocking, so a triple buffer is used inside the netX.
So you get always the last received data. The data from the bus cycle before is lost.
Sorry the say this, but if your windows is too slow to read the data every bus cycle, you miss some cycles.
(The behaviour is independent of the protocol.)

Johnny

sandmann

sandmann

| 30.08.2010 | 16:18

That means, that I can't use other threads, just the one reading the card in a cycle?

Is there a mechanism to indicate new data, so that I can make a buffer from software on a higher level?

thx.

sandmann

Johnny

Johnny

| 31.08.2010 | 09:37

Hello Sandmann,
In my understanding there is no way in windows (without real time extension) to implement a fast mechanism which is never blocked. Maybe you can use a windows multimedia timer (resolution is in ms (?)), but if your windows blocks, you will miss bus cycles anyway.

Are you sure, that you really need all bus cycles and not only the latest received data?
Johnny

sandmann

sandmann

| 31.08.2010 | 14:32

Yes, I need the input data from an instrument in regular intervals, so I may calculate it's characteristics (mean, standard deviation etc.).

sandmann

sandmann

| 02.09.2010 | 12:57

Is there a way to buffer all messages from software, using the C toolkit? If I understood correctly, it works with interrupts... does that mean, that after transaction the data could be buffered by the interrupt service routine?

 

thx.

sandmann

sandmann

sandmann

| 08.09.2010 | 13:12

I managed to solve the problem, by running the program on a multi-core processor. I set the priority of the thread, that reads the data from the cifX card to the maximum (time critical), and designated an extra core for it, by using the windows api: SetThreadIdealProcessor(). The acquisition thread sends the data through a queue, and the other thread displays and stores it. This way, I don't lose any bus cycles.

regards

sandmann

Login