Shop OBEX P1 Docs P2 Docs Learn Events
DCC error byte — Parallax Forums

DCC error byte

BasilBasil Posts: 380
edited 2009-02-13 06:01 in Propeller 1
Hi All,

Im in the process of building my own DCC command center for model railroads, but im stuck on something you might/will be able to help with.

(When I mention NMRA documents, I am refering to the standards developed by the NMRA for model railroads)

I am trying to figure out how to generate the error byte in a DCC pkacets.

With the general (baseline) packet format (according to NMRA S9.2) the error byte is simply:

address_byte ^ data_byte = error_byte

My confusion is with extended packets. NMRA RP9.2.1 says on page 2, line 97:
"The last byte of the packet is the Error Detection Byte, which is calculated the same as is done in the baseline packet using all address, and all instruction bytes (see S-9.2). "

Now lets take an example from page 11 of RP9.2.1 where an extended packet has the following format:

10AAAAAA 0AAA11VV VVVVVVVV DDDDDDDD EEEEEEEE
(EEEEEEEE being the error byte.)

To generate the error byte do I perform the following?
10AAAAAA ^ 0AAA11VV ^ VVVVVVVV ^ DDDDDDDD

Or this:
10AAAAAA ^ 0AAA11VV = temp
temp ^ VVVVVVVV = temp
temp ^ DDDDDDDD = EEEEEEEE

Im more inclined to think the second way but needed to check

Regards,

Alec

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Alec

Velden in N scale

Post Edited (Basil) : 2/12/2009 8:10:09 PM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-02-12 21:00
    Both will yield the same result.

    -Phil
  • BasilBasil Posts: 380
    edited 2009-02-12 21:38
    Oh :P I must have something wrong in my head then lol Thanks phil.

    Do you think there are any other ways to interpret the standard I quoted?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Alec

    Velden in N scale
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-02-12 23:11
    Basil -

    I believe there is a DCC object in the object exchange if you haven't seen that already. I haven't used it myself yet though so I can not comment on it. I was thinking of making a DCC base station someday, but that is further down my list of items to make/build at the moment. Do keep me posted on your progress.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
    www.tdswieter.com
  • BasilBasil Posts: 380
    edited 2009-02-12 23:55
    Hi Timothy,

    I found the DCC object but unfortunately it requires you send the error byte to it just as with all the other bytes :/

    I will surely keep you posted. My blog (see my sig) has updates of my progress also. Not much at the moment but it will grow [noparse]:)[/noparse]

    Phil,

    I drew up a drew truth tables and I think I must be bgetting something wrong because this

    10AAAAAA ^ 0AAA11VV ^ VVVVVVVV ^ DDDDDDDD

    gives me a different result to
    10AAAAAA ^ 0AAA11VV = temp
    temp ^ VVVVVVVV = temp
    temp ^ DDDDDDDD = EEEEEEEE

    Here are my truth tables. I must be doing something wrong in the first one.
    (All bytes are fabricated and mean nothing BTW)
    (Note I am using 4 bytes not 3, but its the same principle)

    Using method '10AAAAAA ^ 0AAA11VV ^ VVVVVVVV ^ DDDDDDDD':
    A 1011_0010
    B 1100_1010
    C 1010_0110
    D 0110_1101
    E 0001_0001 <----result

    And using method:
    10AAAAAA ^ 0AAA11VV = temp
    temp ^ VVVVVVVV = temp
    temp ^ DDDDDDDD = EEEEEEEE

    A 1011_0010
    B 1100_1010
    E 0111_1000

    E 0111_1000
    C 1010_0110
    E 1101_1110

    E 1101_1110
    D 0110_1101
    E 1011_0011 <----result

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Alec

    Velden in N scale
  • kuronekokuroneko Posts: 3,623
    edited 2009-02-13 03:51
    Basil said...
    Using method '10AAAAAA ^ 0AAA11VV ^ VVVVVVVV ^ DDDDDDDD':
    A 1011_0010
    B 1100_1010
    C 1010_0110
    D 0110_1101
    E 0001_0001 <----result
    You can simply check the result by counting the 1's. An even number will always yield 0, an odd number 1. So in columns (from left) 1, 3 and 7 you have 3 x 1 which means the result is 1 -> 1011_0011.
  • BasilBasil Posts: 380
    edited 2009-02-13 06:01
    Ahh ok. I misunderstood how xor works with more than 2 variables. I thought you get a '1' when there is only one instance of a '1' bit in a position.

    Thanks [noparse]:D[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -Alec

    Velden in N scale
Sign In or Register to comment.