Support for BiDiB

Drive Command, Coding of Speed Setting

Speed values are always coded with 127 step plus additional direction bit. The node which includes the command station should translate this speed code to the appropriate format. Speed = 1 is used as coding for emergency stop.

The formula is the same as in the p50x protocol known from Tams EasyControl or Uhlenbrock Intellibox.

Coding for the Motorola format uses the same conversion as DCC. Additionally, on MM systems there is a 'emulierted' format with 27 speed steps (MM27). This coding is derived from MM14 and uses an alternate transmission of lower / upper MM14 value for the intermediate steps in MM27.

Conversion of speed to DCC
BiDiB speed valueDCC128DCC28DCC14
0 00x00 00b00000 00b0000
1 ES0x01ES0b00001ES0b0001
2 10x02 10b00010 10b0010
3 20x03 10b00010 10b0010
4 30x04 10b00010 10b0010
5 40x05 10b00010 10b0010
6 50x06 10b00010 10b0010
7 60x07 20b10010 10b0010
8 70x08 20b10010 10b0010
9 80x09 20b10010 10b0010
10 90x0a 20b10010 10b0010
11 100x0b 30b00011 20b0011
12 110x0c 30b00011 20b0011
13 120x0d 30b00011 20b0011
14 130x0e 30b00011 20b0011
15 140x0f 30b00011 20b0011
16 150x10 40b10011 20b0011
17 160x11 40b10011 20b0011
18 170x12 40b10011 20b0011
19 180x13 40b10011 20b0011
20 190x14 50b00100 30b0100
21 200x15 50b00100 30b0100
22 210x16 50b00100 30b0100
23 220x17 50b00100 30b0100
24 230x18 50b00100 30b0100
25 240x19 60b10100 30b0100
26 250x1a 60b10100 30b0100
27 260x1b 60b10100 30b0100
28 270x1c 60b10100 30b0100
29 280x1d 70b00101 40b0101
30 290x1e 70b00101 40b0101
31 300x1f 70b00101 40b0101
32 310x20 70b00101 40b0101
33 320x21 70b00101 40b0101
34 330x22 80b10101 40b0101
35 340x23 80b10101 40b0101
36 350x24 80b10101 40b0101
37 360x25 80b10101 40b0101
38 370x26 90b00110 50b0110
39 380x27 90b00110 50b0110
40 390x28 90b00110 50b0110
41 400x29 90b00110 50b0110
42 410x2a 90b00110 50b0110
43 420x2b100b10110 50b0110
44 430x2c100b10110 50b0110
45 440x2d100b10110 50b0110
46 450x2e100b10110 50b0110
47 460x2f110b00111 60b0111
48 470x30110b00111 60b0111
49 480x31110b00111 60b0111
50 490x32110b00111 60b0111
51 500x33110b00111 60b0111
52 510x34120b10111 60b0111
53 520x35120b10111 60b0111
54 530x36120b10111 60b0111
55 540x37120b10111 60b0111
56 550x38130b01000 70b1000
57 560x39130b01000 70b1000
58 570x3a130b01000 70b1000
59 580x3b130b01000 70b1000
60 590x3c130b01000 70b1000
61 600x3d140b11000 70b1000
62 610x3e140b11000 70b1000
63 620x3f140b11000 70b1000
64 630x40140b11000 70b1000
65 640x41150b01001 80b1001
66 650x42150b01001 80b1001
67 660x43150b01001 80b1001
68 670x44150b01001 80b1001
69 680x45150b01001 80b1001
70 690x46160b11001 80b1001
71 700x47160b11001 80b1001
72 710x48160b11001 80b1001
73 720x49160b11001 80b1001
74 730x4a170b01010 90b1010
75 740x4b170b01010 90b1010
76 750x4c170b01010 90b1010
77 760x4d170b01010 90b1010
78 770x4e170b01010 90b1010
79 780x4f180b11010 90b1010
80 790x50180b11010 90b1010
81 800x51180b11010 90b1010
82 810x52180b11010 90b1010
83 820x53190b01011100b1011
84 830x54190b01011100b1011
85 840x55190b01011100b1011
86 850x56190b01011100b1011
87 860x57190b01011100b1011
88 870x58200b11011100b1011
89 880x59200b11011100b1011
90 890x5a200b11011100b1011
91 900x5b200b11011100b1011
92 910x5c210b01100110b1100
93 920x5d210b01100110b1100
94 930x5e210b01100110b1100
95 940x5f210b01100110b1100
96 950x60210b01100110b1100
97 960x61220b11100110b1100
98 970x62220b11100110b1100
99 980x63220b11100110b1100
100 990x64220b11100110b1100
1011000x65230b01101120b1101
1021010x66230b01101120b1101
1031020x67230b01101120b1101
1041030x68230b01101120b1101
1051040x69230b01101120b1101
1061050x6a240b11101120b1101
1071060x6b240b11101120b1101
1081070x6c240b11101120b1101
1091080x6d240b11101120b1101
1101090x6e250b01110130b1110
1111100x6f250b01110130b1110
1121110x70250b01110130b1110
1131120x71250b01110130b1110
1141130x72250b01110130b1110
1151140x73260b11110130b1110
1161150x74260b11110130b1110
1171160x75260b11110130b1110
1181170x76260b11110130b1110
1191180x77270b01111140b1111
1201190x78270b01111140b1111
1211200x79270b01111140b1111
1221210x7a270b01111140b1111
1231220x7b270b01111140b1111
1241230x7c280b11111140b1111
1251240x7d280b11111140b1111
1261250x7e280b11111140b1111
1271260x7f280b11111140b1111
Conversion of speed to MM
BiDiB speed valueM4/MFXMM28MM27MM14
0 0 0 0 0
1 ESESESES
2 1 1 1 1
3 2 1 1 1
4 3 1 1 1
5 4 1 1 1
6 5 1 1 1
7 6 2 2 1
8 7 2 2 1
9 8 2 2 1
10 9 2 2 1
11 10 3 2 2
12 11 3 3 2
13 12 3 3 2
14 13 3 3 2
15 14 3 3 2
16 15 4 4 2
17 16 4 4 2
18 17 4 4 2
19 18 4 4 2
20 19 5 4 3
21 20 5 5 3
22 21 5 5 3
23 22 5 5 3
24 23 5 5 3
25 24 6 5 3
26 25 6 6 3
27 26 6 6 3
28 27 6 6 3
29 28 7 6 4
30 29 7 7 4
31 30 7 7 4
32 31 7 7 4
33 32 7 7 4
34 33 8 7 4
35 34 8 8 4
36 35 8 8 4
37 36 8 8 4
38 37 9 8 5
39 38 9 8 5
40 39 9 9 5
41 40 9 9 5
42 41 9 9 5
43 4210 9 5
44 431010 5
45 441010 5
46 451010 5
47 461110 6
48 471110 6
49 481111 6
50 491111 6
51 501111 6
52 511211 6
53 521211 6
54 531212 6
55 541212 6
56 551312 7
57 561312 7
58 571312 7
59 581313 7
60 591313 7
61 601413 7
62 611413 7
63 621414 7
64 631414 7
65 641514 8
66 651514 8
67 661514 8
68 671515 8
69 681515 8
70 691615 8
71 701615 8
72 711616 8
73 721616 8
74 731716 9
75 741716 9
76 751716 9
77 761717 9
78 771717 9
79 781817 9
80 791827 9
81 801817 9
82 811818 9
83 82191810
84 83191810
85 84191810
86 85191910
87 86191910
88 87201910
89 88201910
90 89201910
91 90202010
92 91212011
93 92212011
94 93212011
95 94212011
96 95212111
97 96222111
98 97222111
99 98222111
100 99222211
101100232212
102101232212
103102232212
104103232212
105104232312
106105242312
107106242312
108107242312
109108242312
110109252413
111110252413
112111252413
113112252413
114113252513
115114262513
116115262513
117116262513
118117262513
119118272614
120119272614
121120272614
122121272614
123122272614
124123282714
125124282714
126125282714
127126282714

Convert from BiDiB to Track Format

The following code snippet shows the translation from BiDiB format to DCC (rail format):


unsigned char convert_speed_to_rail(unsigned char speed128, t_format format)
  {
    unsigned char retval, myspeed, direction;
    retval = speed128;             // by default
    myspeed = speed128 & 0x7F;     // mask direction
    direction = speed128 & 0x80;

    switch(format)
      {
        case DCC14:
            if (myspeed > 1)
              {
                retval = (myspeed - 2) / 9 + 2;
                retval |= direction;
              }
            break;
        case DCC28:
            if (myspeed > 1)
              {
                retval = (myspeed - 2) * 2 / 9 + 2;
                retval |= direction;
              }
            break;
        case DCC128:
            break;
      }
    return(retval);
  }

Convert from Track Format to BiDiB

The following code snippet shows the translation from DCC to BiDiB:


// convert a speed given in true rail format (incl. E-Stop) into full 127 step format
unsigned char convert_speed_from_rail(unsigned char speed, t_format format)
  {
    unsigned char retval, myspeed, direction;
    retval = speed;             // by default
    myspeed = speed & 0x7F;     // mask direction
    direction = speed & 0x80;

    switch(format)
      {
        case DCC14:
            if (myspeed > 1)
              {
                retval = (myspeed - 2) * 9 + 2;
                retval |= direction;
              }
            break;
        case DCC28:
            if (myspeed > 1)
              {
                retval = ((myspeed - 2) * 9 + 1 )/ 2 + 2;
                retval |= direction;
              }
            break;
        case DCC128:
            break;
      }
    return(retval);
  }