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.

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

Conversion of speed to running notch
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

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);
  }