Troubleshooting
Why RevPi EtherCAT slave bits repeat across 512 bytes
Short answer
A slave that reaches OP with a stable working counter is moving bytes, so a bit repeated at bit 0 of every byte in the 512-byte span, and outputs that never arrive, are mapping faults. Compare raw bytes at four boundaries — sending variable, gateway image, EtherCAT PDO, master input image — and correct the first offset that differs instead of rebuilding the project.

On this page
- What does a green EtherCAT link actually prove?
- Why does one set bit appear in every one of 512 bytes?
- Why do RevPi 1's output bits never reach RevPi 2?
- Which raw bytes do you compare at each boundary?
- How do you fix the first mismatched mapping?
- How do you verify both directions before restoring the program?
- Questions asked
Two RevPi Connect units running CODESYS runtimes, a RevPi Gate EtherCAT Slave on the first unit, and an EtherCAT master on the second unit's eth1 can show every status green while the data is wrong: one output bit set on the master appears at bit 0 of every one of 512 bytes, and bits set on the first unit never arrive at all. Neither symptom is a network fault. A slave that reaches OP with a stable working counter is moving its bytes; the fault sits in the mapping between application variables and the process image, and you find it by comparing raw bytes at each boundary.
What does a green EtherCAT link actually prove? #
A green link proves the gateway reached OP and answers every cycle: one slave that consumes outputs and produces inputs adds 3 to the working counter of each read-write datagram, and that value must sit stable, not merely nonzero. The EtherCAT specification (ETG.1000) defines the state machine — INIT, PREOP, SAFEOP, OP — and only in OP does the slave apply outputs as well as produce inputs, with the working counter incremented by every slave access that completes inside a datagram. A constant counter therefore means every cycle completed, and anything else is a frame-loss fault, not this one.
What green cannot prove is where the bytes went. The state machine and the counter watch the frame on the wire; they cannot see which variable the application wrote to which offset, or what the gateway's local copy did after the frame delivered the byte. So treat "all green" as the reported condition, not your measurement: open the master's diagnostics, confirm the gateway is in OP, and watch the working counter for a minute while both applications run. If it holds steady, stop looking at the network.
Why does one set bit appear in every one of 512 bytes? #
The pattern is replication, not corruption: one value is being written at a stride of one byte, so a single set bit lands at bit 0 of byte 0, byte 1, and every byte up to byte 511. In bit addressing the copies run from bit 0 to bit (512 − 1) × 8 = 4088, and the reported image is 512 × 8 = 4096 bits in total. A stride of exactly 8 bits is the tell: something advances the destination one byte per write while re-reading the same source, or one variable owns every byte position.
A network never duplicates payload — each frame carries each byte once — so replication needs a writer. Three can produce it:
- One application variable mapped to many channels of the EtherCAT I/O Mapping: write the variable once and every mapped position changes, which is exactly "I set the first bit and the first bit of every byte went true".
- A copy on the gateway side that moves one source byte across the whole local image with a wrong length or stride, so every destination byte inherits bit 0.
- A loop in the application that writes the same value across an array, or writes to overlapping variables.
The report also fixes the observer: RevPi 2 both wrote the bit and watched the copies. Establish whether the repeated bits sit in the master's own output image, in its input image after the round trip, or only in application variables — that one check separates a local mapping fault from anything the gateway did.
Why do RevPi 1's output bits never reach RevPi 2? #
The second symptom is the same disease from the other side: the RevPi 1 application writes a local image region the gateway does not exchange, or the master maps its input variables to different offsets, so the bytes never meet. Two traps produce it. The first is direction: the gateway's local side and the EtherCAT master name the same bytes from opposite ends, so a field labelled output on the slave side can be the master's input; matching two fields because they share a label wires the test to the wrong region. Resolve direction from the gateway's documented process-image definition, not from labels.
The second trap is PDO order: the process image is laid out in the order of the PDO assignment the master configured, and that order can differ from the slave's own 0x1C12 assignment list. If the two hosts assumed different orders, whole bytes trade places and a bit written at one offset is read at another. If your case is harsher — the write never reaches the gateway's output image at all, rather than landing at wrong offsets — that is the separate failure traced in why CODESYS cannot write the RevPi gateway output image.
Which raw bytes do you compare at each boundary? #
Compare four snapshots of the same test byte: the value in the sending variable, the byte in the gateway's local image, the byte in the EtherCAT PDO, and the byte in the master's input image — the first pair that differs is the fault. Work in this order:
- Record before you touch anything. The reported pair ran RevolutionPiBridgeV1.1.0.0 with CODESYS Control for Raspberry Pi 4.0.1.0 on both units; write down your versions and every active mapping — direction, byte offset, bit position, type and variable.
- Confirm the physical path matches the configuration: the master's eth1 cabled to the gateway's upper port, and the gateway where the RevPi 1 configuration places it.
- Confirm the gateway appears in the master's discovered slave list, holds OP, and keeps a stable working counter while the applications run.
- Open the gateway's PDO mapping detail in the master's device configuration — the Sync Managers, PDO Assignment, PDO List and PDO Contents sections — and write down each channel's offset and the byte total.
- Open the EtherCAT I/O Mapping and write down which variable sits on which channel; flag any variable that appears more than once.
Compare raw bytes, not toggled BOOLs: a BOOL test mixes program logic, bit addressing, gateway access and PDO mapping into one result, while a raw byte isolates direction, offset and length. The same offset discipline applies when a write misses the process image entirely, covered in why CODESYS writes miss the process image offsets.
| First boundary that differs | What it means | Where the fix goes |
|---|---|---|
| sending variable to gateway local image | the application writes a region the gateway does not exchange | remap the variables into the exchanged region |
| gateway local image to EtherCAT PDO | the gateway-side copy or the PDO assignment is wrong | correct the copy length and stride, or the PDO order |
| EtherCAT PDO to master input image | the master's mapping uses the wrong offset or width | remap the master's variables |
| master input image to receiving variable | the application reads the wrong byte or bit address | correct the bit address as byte × 8 + bit |
How do you fix the first mismatched mapping? #
Fix the one boundary that failed and change nothing else: give each test byte exactly one address and one writer, because the repeated bit means one writer currently owns every byte of the span. In order:
- Delete duplicate mappings: the test variable stays on exactly one channel of the EtherCAT I/O Mapping, with no other occurrence anywhere.
- Test with a BYTE at a single offset before any BOOL; bytes must travel correctly before individual bits mean anything.
- Audit the application for loops, array indexing, copy lengths and writes to overlapping variables, and remove competing writers so each test byte has one.
- Check the gateway-side copy between the exchanged region and the application variables against the gateway's documented process-image definition — a one-byte stride comes from a wrong length or a re-read source.
- Put both hosts on the same PDO assignment, since the master's assignment defines the image order and may differ from the slave's 0x1C12; then activate with the project's required procedure and confirm both hosts run the intended configuration.
- Follow the gateway vendor's documented CODESYS integration procedure for the bridge configuration: importing the ESI describes the EtherCAT device to the master but does not connect the gateway's local image to the application.
How do you verify both directions before restoring the program? #
Verify with a walking byte pattern, not a single BOOL: write different values at the first two offsets and at the last offset, then confirm each value arrives once, at its own offset, in both directions. If the gateway's outputs drive anything real, run this test with the machine in a safe state, because arbitrary bytes at arbitrary offsets command whatever is mapped there.
Assume the configured image matches the reported 512 bytes — confirm by summing the PDO assignment first. From the master, write 0x01 at byte offset 0, 0x02 at byte offset 1 and 0x80 at byte offset 511. At the far end exactly those three bytes must be non-zero, each at its own offset, and the reverse direction must pass the same test. Read the outcome:
- 0x01 at every offset: replication is still alive — one writer still owns the span; go back to the duplicate mappings and the gateway copy.
- Correct values at offsets 0 and 1 but nothing at 511: the exchanged region is shorter than the mapped span; the PDO byte total is the real length, so map only inside it.
- All three bytes correct in both directions: the byte path is fixed. Add BOOL variables only now, and check every bit address as byte × 8 + bit: bit 3 of byte 5 is bit 5 × 8 + 3 = 43 of the image, and bit 0 of byte 511 is bit 511 × 8 = 4088.
The decision, per case. Repeated bits with a stable working counter: a mapping or copy fault — fix the duplicate mapping or the copy stride, and leave the cable, port and ESI alone. One direction's bytes absent: the write dies before the exchanged region — remap into it and settle direction from the gateway's process-image definition. Bytes right but program bits wrong: the fault is the application's bit arithmetic — remap with byte × 8 + bit.
Questions asked
Can a wrong ESI file cause the repeated bits?
Not with a green link. The gateway checks the configured process-data lengths against its own object dictionary when it moves into OP, so an ESI that selects the wrong length normally stops the slave before OP instead of letting it run with duplicated bits. Once the slave holds OP with a stable working counter, it has accepted the layout the master configured, and the repetition is coming from a writer above the network.
Do the IP settings on eth1 affect this exchange?
No. Cyclic EtherCAT process data rides Ethernet frames directly on the wire, addressed by each slave's position in the logical ring, so the IP address, subnet and any TCP or UDP port on eth1 play no part in moving PDOs. What matters is that the master configuration names eth1 and that eth1 is the port physically wired to the gateway. IP settings matter only for engineering access and other traffic on that interface.
What does a working counter that changes value mean?
A working counter that holds its expected value proves every cycle completed. One that dips to a lower value or to zero on some cycles means frames are being lost or a slave skipped an access — the signature of a cable, connector, EMC or termination problem, which looks nothing like repeated bits. A constant but unexpected value means a slave is processing only one direction, so check the PDO assignment before the wiring.
Should you update the bridge or runtime before tracing?
No. Record what is installed first — the reported pair was RevolutionPiBridgeV1.1.0.0 with CODESYS Control for Raspberry Pi 4.0.1.0 — because a version change before you locate the failing boundary destroys the evidence and adds a second variable to the test. Trace with the installed versions and correct the mapping; change software only if the raw-byte comparison then proves the gateway's local copy itself is at fault.

