The present invention relates to data protocols, and in particular command protocols for model trains.
A variety of control systems are used to control model trains. In one system, the power to the track is increased, or decreased, to control the speed and direction of the train. Multiple trains can be controlled by providing different power levels to the different sections of the track having different trains (see, e.g., U.S. Pat. No. 5,638,522). In another system, a coded signal is sent along the track, and addressed to the desired train, giving it a speed and direction. The train itself controls its speed by converting the AC voltage on the track into the desired DC motor voltage for the train according to the received instructions. The instructions can also tell the train to turn on or off its lights, horns, etc. U.S. Pat. Nos. 5,749,547 and 5,638,522 issued to Neil Young et al. show such a system. The instructions, or commands, have a particular format for a particular model train manufacturer. Trains already in customer's hands are designed to respond to only that format, limiting the options for future expansion.
The current Lionel Trainmaster command format uses 23 bits to assemble a command. These bits are grouped together as 4 bit nibbles (a nibble is half of an 8 bit byte) and are represented in hexadecimal (hex). The first four nibbles translate directly to the Train Master command set, instructing the train on speed, use of horns, smoke, lights, etc. The fifth nibble is a unique number used to detect errors, an error code. The error code represents the addition of the first four nibbles without a carry. The following is and example of a Train Master Engine 1 horn command.
The error check nibble is calculated by adding 0+0+9+C=15Hex. The upper digit 1 is dropped and the error check nibble becomes 5. The receiver then recovers the first 4 nibbles directly and converts them into Trainmaster Commands. The receiver then looks for a 5 and only a 5 in the fifth nibble position. If a 5 is received the transmission is considered good and is allowed to pass. If a nibble other than 5 is received the message is rejected. The three trailer bits at the end of the message are not used by current receivers for data information. Two bits are used to fill the time until the next command packet, and a third bit is set to offset any DC bias imparted by the combination of bits in the command, as discussed in more detail below.
All of the commands in the current command structure have been used, to both designate a variety of commands and address different trains or other controlled devices on a train set. No new commands are possible, but it would be desirable to add new commands for additional features, and to have the system backward compatible with existing model trains.
The present invention provides a method and apparatus for expanding the capacity of a fixed digital field. The invention uses a unique number calculated from the digital field, such as an error code. An error code or other unique number is calculated using a particular algorithm, such as an addition or exclusive OR (X-OR) of the bits in the digital field. The present invention provides a different algorithm to calculate a different unique number or error code from the same command bits. This different number indicates that a second command set is being used. This different error code or unique number thus allows a second command to be interpreted independently from the original command giving an entirely new set of numbers for the digital field, thereby doubling the capacity of the command set.
In one embodiment, the unique number or error code is calculated using the same method as the original, and is then inverted to give the second, new command set for the digital field. An inversion produces a number which is least likely to occur simply as a result of bit errors during the reception and calculation of the unique error number. The invention maintains error protection, although at only a very slightly degraded level, since if the error by coincidence was the inverted new code, it wouldn't be flagged as an error.
Another aspect of the invention is directed to using fill bits, such as the three extra bits used in the command transmission for Lionel Trains. These extra bits fill up the time in between command packets, with one of the extra bits being calculated to be a 1 or 0 to ensure that the command signal does not produce a DC offset. The present invention utilizes two of those bits to transmit additional data, thus multiplying by a factor of three the available number of commands and compensating for the reduction in error code possibilities stated earlier. The additional bit used to counter DC offset takes into account, under the present invention, the value of the two fill bits in determining whether DC offset is present that needs to be counteracted.
For further understanding of the nature and advantages of the invention, reference should be made to the following description taken in conjunction with the accompanying drawings.
Example Control System
Power master unit 150 modulates AC track power to the track 16 and also superimposes DC control signals on the track to control special effects and locomotive 24′. Locomotive 24′ is, e.g., a standard Lionel locomotive powered by AC track power and receptive to DC control signals for, e.g., sound effects.
Base unit 14 transmits an RF signal between the track and earth ground, which generates an electromagnetic field indicated by lines 22 which propagates along the track. This field will pass through a locomotive 24 and will be received by a receiver 26 inside the locomotive an inch or two above the track. Locomotive 24 may be, e.g., a standard locomotive retrofitted or designed to carry a special receiver 26.
The electromagnetic field generated by base unit 14 will also propagate along a line 28 to a switch controller 30. Switch controller 30 also has a receiver in it, and will itself transmit control signals to various devices, such as the track switching module 32 or a moving flag 34.
The use of both base unit 14 and power master unit 150 allows operation and control of several types of locomotives on a single track layout. Locomotives 24 which have been retrofitted or designed to carry receiver 26 are receptive to control signals delivered via base unit 14. Standard locomotives 24′ which have not been retrofitted may be controlled using DC offset signals produced by power master unit 150.
The remote unit can transmit commands wirelessly to base unit 14, power master unit 150, accessories such as accessory 31, and could transmit directly to train engines instead of through the tracks. Such a transmission directly to the train engine could be used for newer engines with a wireless receiver, while older train engines would continue to receive commands through the tracks.
Train Circuitry
The microcontroller also has separate, dedicated output pins which can control a sound generator unit 94, a light switch 96, a coupler 98 and an auxiliary switch 100. The microcontroller is powered by an on-board clock 102.
A three position manual switch 104 is provided. In a first mode, the switch indicates on a line 106 that the train is to start in the forward direction. When in a second position, a signal on a line 108 indicates that the train is to start in the reverse direction. When the switch is in-between the two lines, in a “lock” mode, the microcontroller knows to start the train in the last direction it was in.
The same switch 104 can perform a second function. When a control command is received by the microcontroller, it knows to use the position of switch 104 to indicate either a “run” mode when the switch is in position 106, or a “program” mode when the switch is in the position on line 108.
In order to program an address into a train, the manual switch is moved into the program mode and the train is put on the track. The remote unit is then used to provide an address program command with a designated address for that train. This command is received by the receiver 26 and provided to microcontroller 84, which knows it should write into its memory that address as its designated address. Thereafter, in the run mode, the microcontroller will respond only to commands associated with that address.
New Command Set
As can be seen, each of the command nibbles contains four cells, each with a bit of data. Looking at the first command byte 200, it is shown as encoding 0010. The 0 level is either high or low for the entire width of the cell. The protocol requires that the signal transition at each cell boundary. This transitioning helps ensure that the signal switches constantly to prevent a DC offset being imposed. As can be seen from the third cell in byte 200, a value of 1 is indicated by a transition in the middle of a cell. The start bit is distinguishable from the rest of the cells because it lasts one and one-half cell lengths at the same level, 0 level, thus indicating the new command packet is beginning.
Due to the clock timing used to generate the packet, there is a little extra time between command packets, which is filled by three filler or trailer bits 210. The last two bits are always a 1 in the existing Train Master protocol, while the bit in position or cell 20 is used for two purposes. The first is to offset any DC value generated by a particular combination of the command and error bytes by alternately setting cell 20 to a 0 or a 1 to compensate. The second function is to insure that the last transition bit time is smaller than 1 cell time. This insures proper start bit detection by the receivers.
The invention provides a method in which the command structure is expanded while maintaining full backwards compatibility. The solution is to send a command or message with a different method of calculating the error nibble in a manner other than what is currently being used, allowing unique identification of an old and new command structure. The ideal method is to create a pattern that is the exact opposite of the current method. This allows the current command set to be doubled and is fully compatible with all old receivers. The addition to the structure allows for an additional 65,536 commands for the Lionel Train Master protocol.
New receivers would make two checks. The first using the old method and in addition checking the bit 210 for a value of 11—if it passes, then it is considered an old command. If the bits of 210 are 00, 01 or 10 the error nibble is complemented and a second check is made. If the second check passes, it is considered the new style message and is identified uniquely as one of the three extended command sets. In the case presented there are 16 possible error combinations. In the old method 1 out of 16 is correct. With the new system 2 out of 16 would be correct. This reduces the error detection capability by half but the complemented selection is the best out of the 16 possible for the second choice. By using the addition bits contained in 210, the command and error detection is not reduced but rather enhanced because of the introduction and inclusion of these two bits in the command and error interpretation. This is not a concern due to the serial stream transmission format used where individual bit errors are the concern.
The following change is introduced to double the current command set structure without changing bits 210.
Second enhancement using trailer 210 bits to extend the command set and recover lost error code possibilities.
The above embodiment is only one example of the applicability of the present invention. Any method that relies on two unique error values for selection by using or comparing the first value to the second value could be used. This can be done, for example, by performing a math function such as adding, subtracting, logical ORing, logical ANDing, logical X-ORing or comparing and regenerating a value to the original calculation to create a second unique number. The generation of a second unique number is based and computed on the information received.
Use of Trailer or Fill Bits
Another aspect of the present invention utilizes the last three bit positions shown in
The present invention adds three new combinations as illustrated, with the last two bits being either 00, 01 or 10. This means in the Lionel implementation that three additional sets of 65,536 commands will be added to the existing structure. These combinations can be used to separately expand the command set, using only the old error nibble, or could be combined with use of the new error nibble. Using these two bits creates additional bits to include in the calculation of the error nibble. The best way to calculate the new error nibble would be to use only the combinations that would provide the greatest differences in bit pattern from the original error nibble. The most preferred method would be to X-OR the two bits of the trailer with the error nibble, removing any combination that would have a difference less than three bits (the combination of 11 is not used in the X-ORed calculation; only 00, 01 and 10). Reserving this 11 combination provides an additional check between the old and new command set structure. X-ORing holds bit places and is preferred because it insures at least three bit differences between the original and new error nibble calculation. This along with reserving the 11 trailer bit combinations provides a method that can further distinguish between an error nibble in the old and new methods.
Bit position 20 is a phase bit used to control the ending waveform to insure the last cell width is less than one cell time and provides the best neutralization of the DC offset.
The old system had only one check on the receiver data, the checksum. The new protocol and receivers add additional checks on the old data method along with new checks described below.
Existing Check
The new check of bit position 20 for old TMCC commands will be an additional way to detect an error, with the error either being in the command or the phase bit itself. This is done by the receiver of the command re-doing the calculation of what the phase bit should be to provide the desired DC offset compensation, and then determining if that is in fact its value received. An error in the phase bit could be a problem with the calculation on the transmission side, or interference in the transmission corrupting the phase bit, or the command therefore the phase bit 209 is calculated after the data and trailer results have been calculated. The phase bit 209 is then adjusted to the proper value as previously described.
The new checksum calculation will include the two fill bits, 21 and 22, by exclusive-ORing them into the check sum. The algorithm for the new checksum, in a preferred embodiment, is (1) adding the values of the four nibbles, (2) dropping the most significant bit, (3) inverting the resulting number, and (4) exclusive-ORing with bits 21 and 22 in bit positions <1 and 0> of the error nibble. Alternately, other algorithms could be used, such as exclusive-ORing or some other combination before or after the inversions, or some operation other than an inversion. Or, an entirely different algorithm could calculate a unique number directly from the command and fill bits.
Although one embodiment has been described above, the present invention can embodied in other specific ways without departing from the essential characteristics of the invention. For example, the error nibble could simply be a number calculated from the preceding digital field. Although a command with four nibbles of four bits each has been shown, other command sizes could be used. Also, different sizes of the unique number or error nibble could be used, such as 2, 3, 4, 6, 8, or any other number of bits. The error number could be a checksum, CRC, or any other error code, such as a Reed Solomon code, or some other code not used for error detection. The commands or other digital data could be provided for any type of system, not just model trains. The data need not be command, but could be simply messages or other digital data. Accordingly, the foregoing description is intended to be illustrative, but not limiting, of the scope of the invention which is set forth in the following claims.
Number | Name | Date | Kind |
---|---|---|---|
5638522 | Dunsmuir et al. | Jun 1997 | A |
5749547 | Young et al. | May 1998 | A |
6019289 | Sung | Feb 2000 | A |
6220552 | Ireland | Apr 2001 | B1 |
6275739 | Ireland | Aug 2001 | B1 |
6281606 | Westlake | Aug 2001 | B1 |
6318678 | Ireland | Nov 2001 | B2 |
6367742 | Ireland | Apr 2002 | B1 |
6441570 | Grubba et al. | Aug 2002 | B1 |
6457681 | Wolf et al. | Oct 2002 | B1 |
6485347 | Grubba et al. | Nov 2002 | B1 |
6491263 | Sung et al. | Dec 2002 | B1 |
6513763 | Ireland | Feb 2003 | B1 |
6533223 | Ireland | Mar 2003 | B1 |
6533224 | Ireland | Mar 2003 | B1 |
6536716 | Ireland et al. | Mar 2003 | B1 |
6539292 | Ames | Mar 2003 | B1 |
6545886 | Ireland | Apr 2003 | B1 |
6550000 | Minematsu et al. | Apr 2003 | B1 |
6604641 | Wolf et al. | Aug 2003 | B2 |
6619594 | Wolf et al. | Sep 2003 | B2 |
6624537 | Westlake | Sep 2003 | B2 |
6655640 | Wolf et al. | Dec 2003 | B2 |
6662917 | Wolf et al. | Dec 2003 | B1 |
6729584 | Ireland | May 2004 | B2 |
6745319 | Balmer et al. | Jun 2004 | B1 |
6747579 | Ireland | Jun 2004 | B1 |
6765356 | Denen et al. | Jul 2004 | B1 |
20010005001 | Ireland | Jun 2001 | A1 |
20030015626 | Wolf et al. | Jan 2003 | A1 |
20030127570 | Ireland | Jul 2003 | A1 |
20030142796 | Ames | Jul 2003 | A1 |
20040079841 | Wolf et al. | Apr 2004 | A1 |
20040239268 | Grubba et al. | Dec 2004 | A1 |
20050023416 | Wolf et al. | Feb 2005 | A1 |