I'm currently working with the BiSS protocol using the GPIO pins on a Teensy 4.0 and RLS Encoder (18bit), While I’m able to read data from the encoder, the output isn’t consistently reliable the status LED remains green, indicating valid communication, but I'm unable to parse the data correctly. I suspect the issue might be related to timing, either when reading the data or setting the clock signal.Any help here is appreciated! and attached the sample code to read from encoder.
Using BiSS Protocal (Bit Banging) and TEENSY4.0 GPIO pins to provide clock and receive the data from encoder (18bit resolution, single turn encoder)//MB029 readhead
Please read the forum guide to understand how to post code correctly so that it is readable for others. The guide will tell you what other things you need to post.
delayNanoseconds() provides approximate delays based on CPU cycles but cannot guarantee precise nanosecond accuracy due to interrupt handling, instruction pipeline, and other system activities. It is intended for very short delays but not for exact timing critical applications like high-speed synchronous protocols.
➜ So I would explore unstable clock timing in the bit-banged code, where delayNanoseconds() cannot guarantee precise, jitter-free timing, causing data to be sampled too early or too late (unequal delays can shift the sample point out of the valid data window, flipping bits despite valid communication).
i am not using RS422, directly using Teensy4.0 GPIO pins to create the clock as well as to read the data from Encoder.
By using GPIO pins i am creating the clock and reading the data from encoder, but not getting the expected output as in timing diagram. as of now i am just reading the output data by creating the clock.
Below is the 64 bit output i am getting from Encoder.
If you can switch to a Teensy 4.1, you could potentially use its FlexIO peripheral to generate the BiSS clock and capture the data in hardware, avoiding the timing jitter caused by delayNanoseconds and keeping the sample point stable.
Alternatively, as suggested, adding RS-422 line receivers to your current setup could improve signal integrity and reduce bit errors even without changing the timing method. (With only a 5-inch cable, RS-422 receivers are less about overcoming long-distance noise and more about ensuring proper differential signal termination and conversion to clean logic levels, which can still help reduce subtle skew or threshold issues that cause bit errors.)