-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Decoder Tolerance/Compatibility Improvement when not in High Accuracy Waveform Mode #193
Comments
Can you give more information on what decoders you are referring to that are incompatible with DCC++EX? I've seen some Arduino decoder libraries that are non-compliant with NMRA, but DCC+EX is fully compliant with NMRA pulse length requirements in the high accuracy mode. I would be surprised if there is a commercial decoder that cannot handle 116us pulses. The bottom line is, if a decoder rejects 116us pulses for '0' bits, it is non-compliant with NMRA standards. The standard has narrow requirements for '1' bits, but for '0' bits decoders are required to accept a wide range of pulse lengths up to 10,000us half-length. So it would seem inadvisable to reduce our leeway on the '1' bit in order to adjust the '0' bit unnecessarily. Bear in mind also, that if an interrupt is delayed, the preceding half-pulse will be extended as you say, but the following one will be shortened. And moving the '1' bit half-length away from 58us will increase the number of packets that are out-of-spec due to jitter significantly. |
Not disagreeing; as intended by the subject line, this thread does not pertain to behavior when running in the High Accuracy Mode of DCC++EX.
From the High Accuracy Waveform Mode documentation—
Correct, as per the initial post, I don't think there is any debate about that here; this is simply with respect to the aforementioned caveat noted in the documentation for DCC++EX.
Agree regarding High Accuracy Mode, but this thread is not with respect to the use of hardware timers in High Accuracy Mode; with software routines (such as are used when not in High Accuracy mode), the interval can be additive (instead of fixed), eliminating the potential risk of a shortened interval. |
I should explain my comments above. As I said, in HA mode there is no jitter. However, when pulses are generated through software in interrupt code, interrupts such as the serial port handler, clock and others may delay the generation of the DCC pulse transition. Observations show that the pulse is delayed by up to 6us every clock interrupt, for example. So the preceding half pulse will be extended, potentially to 64us. However, the next interrupt transition is very likely to be back on schedule, so the next half pulse will be 52us (116us total cycle time). These variations can be seen on a logic analyser. No such variations exist in HA mode, it is accurate to within 100 nanoseconds (at the Arduino pin output), which is why we encourage its use. |
Thank you; perhaps some clarification with respect to the documentation might be in order? While jitter is a potential concern when not in High Accuracy Mode, it has seemed that deviation from the specified nominal transmit duration is also of concern. Per the documentation [emphasis mine]:
For non-HA setups, then, the intent was to bring the overall deviation closer to the specified nominal values—specifically reducing the larger variance of "0" from the specified nominal—by slightly deviating from the nominal for "1". High Accuracy would certainly improve timing consistency, but bringing "tighter to the nominal values" would imply reducing DCC++EX's target half-bit duration for "0" from 116 µSec to something closer to the specified nominal of 100 µSec. (Grammatically, making a 116 µSec interval more consistent does not bring that interval it closer to the "nominal value"; it simply has eliminated potential timing variance while maintaining a target duration of 116 µSec.) Stated another way, the documentation currently reads that bringing timings closer to the specified nominal durations (which in the case of the "0" half-bit duration is deviates from the specified nominal by 16 µSec) can help improve compatibility. The next paragraph then also states that High Accuracy Mode helps "to tighten up any jitter." So, is High Accuracy Mode really only "tighten[ing] up any jitter," or—as the first paragraph on that documentation page implies—is it also changing the target durations so that they more closely match with the specified nominal values? If the target timings in High Accuracy Mode are not substantively closer to the specified nominal durations than when not in High Accuracy Mode, then the "The High Accuracy mode makes the waveform…even tighter to the nominal values in the specification" verbiage should be struck (while retaining the verbiage about reducing jitter). |
Thanks for your complete report. We don't often get such detail. It has been difficult keeping the documentation up with developmemt and recruiting others to help me write everything on the web page. Proofreaders and Documenters are in high demand, and suggestions as you have offered are appreciated. I am always looking for ways to make the documentation more clear and accurate. When you find something, please continue to report it. Fred |
The jitter is symmetrical as explained above. For '1' bits, being close to the nominal value also gives the greatest margin to the limits (3us either way for a CS). For '0' bits the limits are not symmetrical and the margin is higher (5us at 100us half-pulse length, or 21us at 116us). So it's the 1 bit that merits closer alignment. With a nominal 58us value, we have margin for 3us jitter before the CS goes beyond the NMRA spec. If we change the value to 56us we have a margin of only 1us. But your points about the documentation are understood and welcomed. Some issues are described in a simplified way in order to make them easier for a non-expert to appreciate! PS I tested a commercial loco decoder today and found that it responds to a much wider range of pulse lengths than the standards require, so immunity to jitter, for that decoder, is fairly high. But one decoder library in particular will start rejecting packets if the jitter exceeds 2us. |
I appreciate the feedback. Particularly on Open Source projects, documentation can be an underappreciated (and even neglected) aspect, so my hat's off to those who have invested the time and effort. I'm familiar with some past discussion on the TrainBoard forum, so that background might factor into a few suggestions here. PersonasI like the personas concept (Conductor, Tinkerer, Engineer) and would suggest introducing the personas at the very outset, on the "Getting Started" landing page. From there, it could then advance to "Components" and "What You Need." The Conductor PersonaAt the risk of perhaps creating too many personas, the Conductor persona could potentially be split into three personas—specifically, splitting off two simple use cases from the current Conductor persona and leaving the remainder under the existing Conductor persona. Feel free to come up with other persona names (in fact, I'm sure someone can probably come up with better names, lol); the idea is more the role.
OK, but I thought this issue was about setups that don't support High Availability Mode?Yes, it was, lol. :-) From the documentation, it appears use of Arduino Mega and the Arduino Motor Shields would automatically enable "High Accuracy Mode"; however, that tidbit of information doesn't seem to be noted until very deep into the advanced setup on a page that is tagged for Tinkerers or Engineers. We might be able to help steer less-experienced users away from potential pitfalls and caveats like this by essentially providing "Recommended Starter Packs" for the "Passenger" and "First-Class Passenger" personas. So about the "High Accuracy Waveform Mode" page…Based on my current understanding, might the following rewording of the first two paragraphs be appropriate:
|
* Getting started * Initial draft page ready for review/content * Minor updates from feedback * List started, feedback template created
Synopsis
Reduce DCC-EX's half-bit transmit duration for "1" to 54 µSec (or at least 55 µSec).
Background
As described in the High Accuracy Waveform Mode documentation and defined in the code in DCCTimer.cpp, the half-bit transmit duration for "1" is 58 µSec. This aligns with the nominal value defined in the NMRA S-9.1 DCC Electrical Standard document (see Table 2.1, "DCC Bit Timing").
The specification is tighter for transmission, with receiving having (for "1") an additional 3 µSec of tolerance added at either end.
Thresholds
Defined Minimum Half-Bit Durations for "1" (nominal 58 µSec)
Defined Minimum Half-Bit Durations for "0" (nominal 100 µSec)
For "1" (as defined), the half-bit maximum durations simply mirror the offsets for the minimum threshold.
However, it seems possible that in some cases where there have been decoder tolerance/compatibility issues, the implementers perhaps also defined the maximum half-bit duration threshold for "0" to follow—in at least some cases—the same pattern as for the "1" maximum half-bit transmit/receive durations. Hypothetically, these maximum half-bit durations for "0" might then have been implemented as follows:
DCC-EX Implementation and Potential Implications
The above would potentially explain why some decoders don't work unless High Accuracy Waveform Mode is enabled—DCC-EX's half-bit "0" duration of 116 µSec is longer than the 110 µSec that would be the theoretical receive cutoff in an implementation that followed the same duration timing pattern for both "0" and "1".
Mitigating
Particularly when running on something such as Arduinos, efforts to simplify and conserve resources—such as by reusing timers—is understandable. While still facilitating reuse of timers, compatibility could perhaps potentially be improved by reducing DCC-EX's half-bit transmit duration for "1" to 54 µSec (or at least 55 µSec).
If nothing else, defining the half-bit duration for "1" at a value below the spec-defined nominal value should provide better buffer protection against jitter-induced timing delays
The text was updated successfully, but these errors were encountered: