Support für Hersteller
Userkonfiguration
Beispielcode
Analysewerkzeuge
Support für BiDiB
Fahrbefehl, Geschwindigkeitskodierung
In Gleisausgabegeräten werden Lokbefehle immer mit einem Byte kodiert, welches 127 Fahrstufen und das Richtungsbit enthält. Erst das Gleisausgabegerät macht dann entsprechend der Vorgabe die Konvertierung auf das jeweilige Zielformat. Die Fahrstufe 1 wird als Nothalt (emergency stop, ES) verwendet.
Die Umwandlungsformeln sind identisch zum p50x-Protokoll, bekannt von Tams EasyControl oder Uhlenbrock Intellibox.
Die Gleisformate für die Motorola-Kodierung (MM) verwenden die gleiche Umrechnung wie DCC. Zusätzlich gibt es bei den Gleisformaten MM auch noch ein 'emuliertes' Format mit 27 Fahrstufen (MM27a/MM27b), das aus dem 14-stufigen Format abgeleitet ist und durch abwechselnde Übertragung des darunter liegenden / darüber liegenden MM14 Wertes an den Fahrzeugdecoder übermittelt wird.
BiDiB Speed-Wert | DCC128 | DCC28 | DCC14 | |||
---|---|---|---|---|---|---|
0 | 0 | 0x00 | 0 | 0b00000 | 0 | 0b0000 |
1 | ES | 0x01 | ES | 0b00001 | ES | 0b0001 |
2 | 1 | 0x02 | 1 | 0b00010 | 1 | 0b0010 |
3 | 2 | 0x03 | 1 | 0b00010 | 1 | 0b0010 |
4 | 3 | 0x04 | 1 | 0b00010 | 1 | 0b0010 |
5 | 4 | 0x05 | 1 | 0b00010 | 1 | 0b0010 |
6 | 5 | 0x06 | 1 | 0b00010 | 1 | 0b0010 |
7 | 6 | 0x07 | 2 | 0b10010 | 1 | 0b0010 |
8 | 7 | 0x08 | 2 | 0b10010 | 1 | 0b0010 |
9 | 8 | 0x09 | 2 | 0b10010 | 1 | 0b0010 |
10 | 9 | 0x0a | 2 | 0b10010 | 1 | 0b0010 |
11 | 10 | 0x0b | 3 | 0b00011 | 2 | 0b0011 |
12 | 11 | 0x0c | 3 | 0b00011 | 2 | 0b0011 |
13 | 12 | 0x0d | 3 | 0b00011 | 2 | 0b0011 |
14 | 13 | 0x0e | 3 | 0b00011 | 2 | 0b0011 |
15 | 14 | 0x0f | 3 | 0b00011 | 2 | 0b0011 |
16 | 15 | 0x10 | 4 | 0b10011 | 2 | 0b0011 |
17 | 16 | 0x11 | 4 | 0b10011 | 2 | 0b0011 |
18 | 17 | 0x12 | 4 | 0b10011 | 2 | 0b0011 |
19 | 18 | 0x13 | 4 | 0b10011 | 2 | 0b0011 |
20 | 19 | 0x14 | 5 | 0b00100 | 3 | 0b0100 |
21 | 20 | 0x15 | 5 | 0b00100 | 3 | 0b0100 |
22 | 21 | 0x16 | 5 | 0b00100 | 3 | 0b0100 |
23 | 22 | 0x17 | 5 | 0b00100 | 3 | 0b0100 |
24 | 23 | 0x18 | 5 | 0b00100 | 3 | 0b0100 |
25 | 24 | 0x19 | 6 | 0b10100 | 3 | 0b0100 |
26 | 25 | 0x1a | 6 | 0b10100 | 3 | 0b0100 |
27 | 26 | 0x1b | 6 | 0b10100 | 3 | 0b0100 |
28 | 27 | 0x1c | 6 | 0b10100 | 3 | 0b0100 |
29 | 28 | 0x1d | 7 | 0b00101 | 4 | 0b0101 |
30 | 29 | 0x1e | 7 | 0b00101 | 4 | 0b0101 |
31 | 30 | 0x1f | 7 | 0b00101 | 4 | 0b0101 |
32 | 31 | 0x20 | 7 | 0b00101 | 4 | 0b0101 |
33 | 32 | 0x21 | 7 | 0b00101 | 4 | 0b0101 |
34 | 33 | 0x22 | 8 | 0b10101 | 4 | 0b0101 |
35 | 34 | 0x23 | 8 | 0b10101 | 4 | 0b0101 |
36 | 35 | 0x24 | 8 | 0b10101 | 4 | 0b0101 |
37 | 36 | 0x25 | 8 | 0b10101 | 4 | 0b0101 |
38 | 37 | 0x26 | 9 | 0b00110 | 5 | 0b0110 |
39 | 38 | 0x27 | 9 | 0b00110 | 5 | 0b0110 |
40 | 39 | 0x28 | 9 | 0b00110 | 5 | 0b0110 |
41 | 40 | 0x29 | 9 | 0b00110 | 5 | 0b0110 |
42 | 41 | 0x2a | 9 | 0b00110 | 5 | 0b0110 |
43 | 42 | 0x2b | 10 | 0b10110 | 5 | 0b0110 |
44 | 43 | 0x2c | 10 | 0b10110 | 5 | 0b0110 |
45 | 44 | 0x2d | 10 | 0b10110 | 5 | 0b0110 |
46 | 45 | 0x2e | 10 | 0b10110 | 5 | 0b0110 |
47 | 46 | 0x2f | 11 | 0b00111 | 6 | 0b0111 |
48 | 47 | 0x30 | 11 | 0b00111 | 6 | 0b0111 |
49 | 48 | 0x31 | 11 | 0b00111 | 6 | 0b0111 |
50 | 49 | 0x32 | 11 | 0b00111 | 6 | 0b0111 |
51 | 50 | 0x33 | 11 | 0b00111 | 6 | 0b0111 |
52 | 51 | 0x34 | 12 | 0b10111 | 6 | 0b0111 |
53 | 52 | 0x35 | 12 | 0b10111 | 6 | 0b0111 |
54 | 53 | 0x36 | 12 | 0b10111 | 6 | 0b0111 |
55 | 54 | 0x37 | 12 | 0b10111 | 6 | 0b0111 |
56 | 55 | 0x38 | 13 | 0b01000 | 7 | 0b1000 |
57 | 56 | 0x39 | 13 | 0b01000 | 7 | 0b1000 |
58 | 57 | 0x3a | 13 | 0b01000 | 7 | 0b1000 |
59 | 58 | 0x3b | 13 | 0b01000 | 7 | 0b1000 |
60 | 59 | 0x3c | 13 | 0b01000 | 7 | 0b1000 |
61 | 60 | 0x3d | 14 | 0b11000 | 7 | 0b1000 |
62 | 61 | 0x3e | 14 | 0b11000 | 7 | 0b1000 |
63 | 62 | 0x3f | 14 | 0b11000 | 7 | 0b1000 |
64 | 63 | 0x40 | 14 | 0b11000 | 7 | 0b1000 |
65 | 64 | 0x41 | 15 | 0b01001 | 8 | 0b1001 |
66 | 65 | 0x42 | 15 | 0b01001 | 8 | 0b1001 |
67 | 66 | 0x43 | 15 | 0b01001 | 8 | 0b1001 |
68 | 67 | 0x44 | 15 | 0b01001 | 8 | 0b1001 |
69 | 68 | 0x45 | 15 | 0b01001 | 8 | 0b1001 |
70 | 69 | 0x46 | 16 | 0b11001 | 8 | 0b1001 |
71 | 70 | 0x47 | 16 | 0b11001 | 8 | 0b1001 |
72 | 71 | 0x48 | 16 | 0b11001 | 8 | 0b1001 |
73 | 72 | 0x49 | 16 | 0b11001 | 8 | 0b1001 |
74 | 73 | 0x4a | 17 | 0b01010 | 9 | 0b1010 |
75 | 74 | 0x4b | 17 | 0b01010 | 9 | 0b1010 |
76 | 75 | 0x4c | 17 | 0b01010 | 9 | 0b1010 |
77 | 76 | 0x4d | 17 | 0b01010 | 9 | 0b1010 |
78 | 77 | 0x4e | 17 | 0b01010 | 9 | 0b1010 |
79 | 78 | 0x4f | 18 | 0b11010 | 9 | 0b1010 |
80 | 79 | 0x50 | 18 | 0b11010 | 9 | 0b1010 |
81 | 80 | 0x51 | 18 | 0b11010 | 9 | 0b1010 |
82 | 81 | 0x52 | 18 | 0b11010 | 9 | 0b1010 |
83 | 82 | 0x53 | 19 | 0b01011 | 10 | 0b1011 |
84 | 83 | 0x54 | 19 | 0b01011 | 10 | 0b1011 |
85 | 84 | 0x55 | 19 | 0b01011 | 10 | 0b1011 |
86 | 85 | 0x56 | 19 | 0b01011 | 10 | 0b1011 |
87 | 86 | 0x57 | 19 | 0b01011 | 10 | 0b1011 |
88 | 87 | 0x58 | 20 | 0b11011 | 10 | 0b1011 |
89 | 88 | 0x59 | 20 | 0b11011 | 10 | 0b1011 |
90 | 89 | 0x5a | 20 | 0b11011 | 10 | 0b1011 |
91 | 90 | 0x5b | 20 | 0b11011 | 10 | 0b1011 |
92 | 91 | 0x5c | 21 | 0b01100 | 11 | 0b1100 |
93 | 92 | 0x5d | 21 | 0b01100 | 11 | 0b1100 |
94 | 93 | 0x5e | 21 | 0b01100 | 11 | 0b1100 |
95 | 94 | 0x5f | 21 | 0b01100 | 11 | 0b1100 |
96 | 95 | 0x60 | 21 | 0b01100 | 11 | 0b1100 |
97 | 96 | 0x61 | 22 | 0b11100 | 11 | 0b1100 |
98 | 97 | 0x62 | 22 | 0b11100 | 11 | 0b1100 |
99 | 98 | 0x63 | 22 | 0b11100 | 11 | 0b1100 |
100 | 99 | 0x64 | 22 | 0b11100 | 11 | 0b1100 |
101 | 100 | 0x65 | 23 | 0b01101 | 12 | 0b1101 |
102 | 101 | 0x66 | 23 | 0b01101 | 12 | 0b1101 |
103 | 102 | 0x67 | 23 | 0b01101 | 12 | 0b1101 |
104 | 103 | 0x68 | 23 | 0b01101 | 12 | 0b1101 |
105 | 104 | 0x69 | 23 | 0b01101 | 12 | 0b1101 |
106 | 105 | 0x6a | 24 | 0b11101 | 12 | 0b1101 |
107 | 106 | 0x6b | 24 | 0b11101 | 12 | 0b1101 |
108 | 107 | 0x6c | 24 | 0b11101 | 12 | 0b1101 |
109 | 108 | 0x6d | 24 | 0b11101 | 12 | 0b1101 |
110 | 109 | 0x6e | 25 | 0b01110 | 13 | 0b1110 |
111 | 110 | 0x6f | 25 | 0b01110 | 13 | 0b1110 |
112 | 111 | 0x70 | 25 | 0b01110 | 13 | 0b1110 |
113 | 112 | 0x71 | 25 | 0b01110 | 13 | 0b1110 |
114 | 113 | 0x72 | 25 | 0b01110 | 13 | 0b1110 |
115 | 114 | 0x73 | 26 | 0b11110 | 13 | 0b1110 |
116 | 115 | 0x74 | 26 | 0b11110 | 13 | 0b1110 |
117 | 116 | 0x75 | 26 | 0b11110 | 13 | 0b1110 |
118 | 117 | 0x76 | 26 | 0b11110 | 13 | 0b1110 |
119 | 118 | 0x77 | 27 | 0b01111 | 14 | 0b1111 |
120 | 119 | 0x78 | 27 | 0b01111 | 14 | 0b1111 |
121 | 120 | 0x79 | 27 | 0b01111 | 14 | 0b1111 |
122 | 121 | 0x7a | 27 | 0b01111 | 14 | 0b1111 |
123 | 122 | 0x7b | 27 | 0b01111 | 14 | 0b1111 |
124 | 123 | 0x7c | 28 | 0b11111 | 14 | 0b1111 |
125 | 124 | 0x7d | 28 | 0b11111 | 14 | 0b1111 |
126 | 125 | 0x7e | 28 | 0b11111 | 14 | 0b1111 |
127 | 126 | 0x7f | 28 | 0b11111 | 14 | 0b1111 |
BiDiB Speed-Wert | M4/MFX | MM28 | MM27 | MM14 |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
1 | ES | ES | ES | ES |
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 | 42 | 10 | 9 | 5 |
44 | 43 | 10 | 10 | 5 |
45 | 44 | 10 | 10 | 5 |
46 | 45 | 10 | 10 | 5 |
47 | 46 | 11 | 10 | 6 |
48 | 47 | 11 | 10 | 6 |
49 | 48 | 11 | 11 | 6 |
50 | 49 | 11 | 11 | 6 |
51 | 50 | 11 | 11 | 6 |
52 | 51 | 12 | 11 | 6 |
53 | 52 | 12 | 11 | 6 |
54 | 53 | 12 | 12 | 6 |
55 | 54 | 12 | 12 | 6 |
56 | 55 | 13 | 12 | 7 |
57 | 56 | 13 | 12 | 7 |
58 | 57 | 13 | 12 | 7 |
59 | 58 | 13 | 13 | 7 |
60 | 59 | 13 | 13 | 7 |
61 | 60 | 14 | 13 | 7 |
62 | 61 | 14 | 13 | 7 |
63 | 62 | 14 | 14 | 7 |
64 | 63 | 14 | 14 | 7 |
65 | 64 | 15 | 14 | 8 |
66 | 65 | 15 | 14 | 8 |
67 | 66 | 15 | 14 | 8 |
68 | 67 | 15 | 15 | 8 |
69 | 68 | 15 | 15 | 8 |
70 | 69 | 16 | 15 | 8 |
71 | 70 | 16 | 15 | 8 |
72 | 71 | 16 | 16 | 8 |
73 | 72 | 16 | 16 | 8 |
74 | 73 | 17 | 16 | 9 |
75 | 74 | 17 | 16 | 9 |
76 | 75 | 17 | 16 | 9 |
77 | 76 | 17 | 17 | 9 |
78 | 77 | 17 | 17 | 9 |
79 | 78 | 18 | 17 | 9 |
80 | 79 | 18 | 27 | 9 |
81 | 80 | 18 | 17 | 9 |
82 | 81 | 18 | 18 | 9 |
83 | 82 | 19 | 18 | 10 |
84 | 83 | 19 | 18 | 10 |
85 | 84 | 19 | 18 | 10 |
86 | 85 | 19 | 19 | 10 |
87 | 86 | 19 | 19 | 10 |
88 | 87 | 20 | 19 | 10 |
89 | 88 | 20 | 19 | 10 |
90 | 89 | 20 | 19 | 10 |
91 | 90 | 20 | 20 | 10 |
92 | 91 | 21 | 20 | 11 |
93 | 92 | 21 | 20 | 11 |
94 | 93 | 21 | 20 | 11 |
95 | 94 | 21 | 20 | 11 |
96 | 95 | 21 | 21 | 11 |
97 | 96 | 22 | 21 | 11 |
98 | 97 | 22 | 21 | 11 |
99 | 98 | 22 | 21 | 11 |
100 | 99 | 22 | 22 | 11 |
101 | 100 | 23 | 22 | 12 |
102 | 101 | 23 | 22 | 12 |
103 | 102 | 23 | 22 | 12 |
104 | 103 | 23 | 22 | 12 |
105 | 104 | 23 | 23 | 12 |
106 | 105 | 24 | 23 | 12 |
107 | 106 | 24 | 23 | 12 |
108 | 107 | 24 | 23 | 12 |
109 | 108 | 24 | 23 | 12 |
110 | 109 | 25 | 24 | 13 |
111 | 110 | 25 | 24 | 13 |
112 | 111 | 25 | 24 | 13 |
113 | 112 | 25 | 24 | 13 |
114 | 113 | 25 | 25 | 13 |
115 | 114 | 26 | 25 | 13 |
116 | 115 | 26 | 25 | 13 |
117 | 116 | 26 | 25 | 13 |
118 | 117 | 26 | 25 | 13 |
119 | 118 | 27 | 26 | 14 |
120 | 119 | 27 | 26 | 14 |
121 | 120 | 27 | 26 | 14 |
122 | 121 | 27 | 26 | 14 |
123 | 122 | 27 | 26 | 14 |
124 | 123 | 28 | 27 | 14 |
125 | 124 | 28 | 27 | 14 |
126 | 125 | 28 | 27 | 14 |
127 | 126 | 28 | 27 | 14 |
Konvertierung von BiDiB auf Gleisformat
Dieses Beispiel zeigt exemplarisch, wie diese Konvertierung kodiert werden kann:
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); // true rail format
}
Konvertierung von Gleisformat auf BiDiB
Entsprechend sieht die Gegenrichtung aus:
// 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);
}