METHODS AND DEVICES FOR DETERMINATION OF POSITION AND CONTROL OF LOCATION-BASED BEHAVIOUR ON A MODEL RAILROAD
20230043315 · 2023-02-09
Inventors
Cpc classification
B61C3/00
PERFORMING OPERATIONS; TRANSPORTING
G01C22/02
PHYSICS
B61L25/025
PERFORMING OPERATIONS; TRANSPORTING
International classification
B61L25/02
PERFORMING OPERATIONS; TRANSPORTING
B61C3/00
PERFORMING OPERATIONS; TRANSPORTING
B61L27/20
PERFORMING OPERATIONS; TRANSPORTING
Abstract
A method to determine the position of a locomotive (100) by having a first device (306) measuring the electromotive force from a propelling motor (105) and calculating the speed; combined with detection of fixed reference points by measuring of the magnetic field generated by permanent magnets (106) at known positions. At regular intervals this information is passed to a second device (108). By use of a pattern recognition algorithm the second device estimates the position and operates the locomotive according to location-based behavior. The first device characterized by having a magnetic field sensor (302) integrated on an ordinary model railroad decoder, which already supports motor measurement and packet transmission. The second device characterized by having a data packet receiver (403) and an Ethernet interface (405) for communication with a command station (109). A microcontroller (402) utilizes a parameterized representation of the model railroad layout to determine the position of the locomotive. From the position proper behavior is determined and corresponding speed commands are sent to the command station. Other methods and embodiments are described and shown.
Claims
1. A method for identifying a position of a locomotive on a model railroad layout which has a plurality of permanent magnets distributed at known positions, comprising: a) measuring an electromotive force generated by a motor propelling the locomotive; b) integrating the measured electromotive force to yield an estimate of change in position of the locomotive; c) measuring a magnetic field as the locomotive is moving on the model railroad layout; d) providing a memory which is able to store a parameterized representation of the model railroad layout including the known positions of the permanent magnets; wherein the improvement comprises, e) determining when the permanent magnets are passed based on the measured magnetic field; f) determining a first distance between a first passed magnet and a second passed magnet; g) determining a second distance between the second passed magnet and a third passed magnet; h) utilizing a means for searching the parameterized representation to determine an element with a best matching of the first distance and the second distance; whereby the element represents the position of the locomotive on the model railroad layout.
2. A method for automatic braking of the locomotive in a desirable position specified in the parameterized representation of the model railroad layout according to claim 1 further comprising: a) calculating a remaining distance to travel from the position of the locomotive to the desirable position by utilizing the parameterized representation of the model railroad layout; b) providing a memory which is able to store a predetermined listing of maximum allowed speed for the locomotive as function of the remaining distance; c) regulating the speed of the locomotive in according with the predetermined listing of maximum allowed speed for the locomotive based on the remaining distance;
3. A method for inserting a specific position of e.g. a signal in the parameterized representation of the model railroad layout according to claim 1 further comprising: a) having the user to drive and stop the front of the locomotive in the specific position; b) having the user to enter address of the locomotive and address of the signal; c) having the user to confirm to insert the specific position; d) calculate the specific position of the front of the locomotive related to the parameterized representation; e) modify the parameterized representation to include new elements;
4. A decoder device for installation in a locomotive comprising: a) circuit (300) for measuring an electromotive force from a motor propelling the locomotive; b) a magnetic field sensor (302) selected from the group consisting of Hall effect sensors, MEMS sensors, digital compasses, and inertial measurement units; wherein the improvement comprises, c) means (304) for transmitting a data packet to a processing device; d) means (301) for carrying out: i) an integration of the measured electromotive force to yield an estimate of a change in position of the locomotive; ii) an analyzation of the measured magnetic field to determine that one of the permanent magnets has been passed;
5. A decoder device of claim 4 further comprises: a) means (301) for carrying out an analyzation of the measured magnetic field to determine between a plurality of distinguishable classes of the permanent magnets;
6. A decoder device of claim 4 where the means (304) for transmitting a data packet is a circuitry which is signaling by current pulses;
7. A computer program comprising instructions to cause the device of claim 4, 5 or 6 to execute the mentioned steps.
8. A processing device comprising: a) a memory which is able to store a predetermined listing of maximum allowed speed for a locomotive as function of remaining distance; wherein the improvement comprises, b) means (403) for receiving a data packet from a decoder device; c) a memory which is able to store a parameterized representation of a model railroad layout including known positions of a plurality of permanent magnets and one or more desirable positions; d) means (402 or 411) for carrying out: i) a determination of a first distance between a first passed magnet and a second passed magnet; ii) a determination of a second distance between the second passed magnet and a third passed magnet; iii) a search in the parameterized representation to determine an element with a best matching of the first distance and the second distance;
9. A processing device according to claim 8 further comprising: a) means (406, 407) for disconnecting electrical connection between command station and track; b) means (400, 408) for establishing a low impedance current loop between the connections to the track;
10. A device according to claim 8 further comprising: a) means (402 or 411) for carrying out: i) a calculation which determines a specific position of the front of the locomotive related to the parameterized representation; ii) a data modification in the parameterized representation to include the specific position;
11. A computer program comprising instructions to cause the device of claim 8, 9 or 10 to execute the mentioned steps.
Description
DRAWINGS—FIGURES
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
DETAILED DESCRIPTION
First Embodiment
[0049]
[0050] One embodiment is illustrated in
[0051] The track is in one location electrically connected to a processing device (108) that is further connected to the user's command station (109). Both the command station and the processing device are connected with Ethernet cables to a network router (110). The network router provides a wireless network where a mobile device (111) is connected as well. The mobile device provides a user interface for interaction. The Ethernet protocol is just an example of a feasible network protocol but others can also be used. Further, the wired connections can be wireless.
[0052]
[0053] In
[0054]
[0055] In
Operation—First Embodiment
[0056] The easiest way to understand how the system of this embodiment operates, is to visualize it as a pattern recognition system in combination with a speed regulation scheme. The new decoder in the locomotive will continuously report data packets to the processing device regarding passed magnetic reference points as well as the travelled distance. The processing device will have a parameterized representation of the track layout, and compare the reports with the parameterized representation to recognize a matching pattern of magnetic types and distances between them. The description will first discuss the parameterized representation and the placement of the magnets, followed by details about the new decoder and the creation of the data packet. Lastly the processing device will be discussed with details about algorithms.
[0057]
[0058] The parameterized representation of the track layout can be implemented in a database, but is visually shown as a table in the description. It is not important how the database is implemented. Each row will be called an element in the following. An element comprising an element number, a clockwise reference, an anti-clockwise reference, type, and a parameter list. The clockwise and anti-clockwise references can be used as linked lists to find adjacent element numbers when traveling in the clockwise or anti-clockwise direction respectively. It will shortly be shown how the linked lists make it possible to easy find the route from one location to another. It will also be shown, how the distance between two magnets easily can be found by accumulating the length elements from first magnet to second magnet in the linked list.
[0059] The table can be created by running a locomotive over the tracks, whereby the processing device will receive the mentioned data packets, in which the type of passed magnets and the distance since last magnet can be read out. This information can be displayed to the user e.g. by the mobile device, such that the user can create the table.
[0060] An example of a layout and the corresponding database is viewed in table style in
length of 101=measured_length
length of 103=length_100_105−measured_length
length of 104=length_100_106−measured_length
[0061] Magnet types are defined in the clockwise direction, so when traveling in the anti-clockwise direction, the right side and left side notations are interchanged.
[0062] Placement of Magnets
[0063] To insure proper performance of the pattern recognition algorithm, the magnets must be distributed along the track in a pseudorandom manner to produce a unique pattern. This is achieved by separating the magnets approximately by a distance of 20 to 200 cm. The resolution of the measured distance has been observed to be within +1-1%, but even with a resolution of +1-2.5%, this will create 47 distinguishable distances in the range. For a 1:87 scaled layout the magnets should be located approximately 3 cm on either side of the track measured from the center of the track to the center of the magnet. The upward magnetic polarity should also be randomly chosen and together this defines the magnetic type.
[0064] From the observation of three magnets, the likelihood of any combination is 1:141,376 (4×47×4×47×4), because the observation provides three magnetic types and two distances between them. On the layout is assumed to be only a few hundred magnets. The processing device can therefore determine the identification of the last passed magnet, given that the processing device has the knowledge of the last three passed magnets. The knowledge is delivered by data packets from the new decoder to the processing device. In the following is described the new decoder and the creation of the data packets.
[0065]
[0066] In
[0067] Step (600)
[0068] This it the entry point of the software.
[0069] Step (601)
[0070] The software starts by initializing the clock domain and peripheral blocks. The traveled distance is per definition zero at power-up, therefore the register holding the position of the locomotive is cleared.
position=0
[0071] Step (602)
[0072] Hereafter it enters an infinite loop with no functionality and all functionality is accomplished by interrupt routines.
[0073]
[0074] The data packets are created based on the speed of the locomotive. The speed is measured from the voltage generated by the propelling motor when it is acting as a generator. Because the ordinary decoder also needs to measure this voltage in order to keep a constant speed compensated for load changes, it periodically stops driving the motor for a few milliseconds and the generated voltage can be measured. The generated electromotive force is proportional with the angular velocity of the motor shaft. The motor shaft has a fixed gear ratio with the wheels, and therefore the generated voltage is proportional with the speed. In
[0075] Step (620)
[0076] When the motor sensor detects that the motor is not powered by the ordinary decoder, this interrupt is called. The non-powered state is detected when the PWM-signal to the motor disappears. This can be detected and generate an interrupt when the voltage has not exceeded a threshold for a given period of time. For example the threshold can be half the supply voltage and the period of time can be twice the period of the PWM signal. The interrupt can be generated in the suggested microcontroller by utilizing one analog comparator block and one timer block. The analog comparator checks against the threshold and clears the timer when it is exceeded. The timer counts the period and signals an interrupt, when the period exceeds the chosen period.
[0077] Step (621)
[0078] While the PWM-signal is absent, the electromotive force generated by the motor is measured by an ADC in the microcontroller. An average value is taken after the value has stabilized.
[0079] Step (622)
[0080] The speed is proportional to the measured voltage. However, each motor will require a unique multiplication factor necessary to transform the read voltage into millimeters per second. Therefore the ADC value is multiplied by a predetermined constant. The constant can initially be set to 1, and by running the locomotive manually over two magnets with a known distance between, the constant can be calculated from the reported distance in the data packet.
constant=measured_distance/reported_distance
[0081] Step (623)
[0082] The speed is stored in a global register accessible by the other interrupt routines.
[0083]
[0084] The data packets are further created based on the passing of magnets. Now the measurement and detection of magnets will be described as illustrated in
[0085] Step (640)
[0086] The magnetic field sensor is initialized to generate an interrupt at a frequency of 300 Hz. The interrupt occurs when a new measurement of the magnetic field has finished and data is ready. The magnetic field sensor has a dedicated output pin for this interrupt generation.
[0087] Step (641)
[0088] The data from the magnetic field sensor is transferred into the microcontroller through a data interface, for example SPI or I2C.
[0089] Step (642)
[0090] The data consists of three values. They represent the magnetic field in the three dimensional orthogonal space of a reference frame. For simplicity the reference frame will match the frame of the locomotive such that is has the x-axis pointing in the forward direction, the y-axis pointing to the left side and the z-axis pointing upward. If the magnetic field sensor is not aligned like this, a three dimensional rotation of the recorded values is necessary for later processing. For now it holds to calculate the RMS-value, which is independent of the orientation.
RMS=SQRT(x{circumflex over ( )}2+y{circumflex over ( )}2+z{circumflex over ( )}2)
[0091] Other methods can be used to find an estimate of the magnetic strength. Especially when the orientation of the mentioned locomotive reference frame is known. In the event of passing a magnet, a specific pattern has been observed to occur in each of the three orthogonal magnetic fields. For the x-axis the field will have the strongest change and be zero exactly when passing the magnet. For the y-axis the field will peak exactly when passing the magnet. The z-axis is more complicated, but will be symmetrical around the magnet. Therefore, instead of using the RMS-value, many other values can be used, for instant:
value=y
or simply defining the passing to occur when the value of the x-axis changes polarity. However, in the following the RMS-value is used.
[0092] Step (643)
[0093] Check if the RMS-value is larger than a predetermined threshold. The purpose of the threshold is to remove peak detection based solely on fluctuations in the Earth's magnetic field. The value of the threshold should therefore be e.g. twice of the Earth's magnetic field.
[0094] Step (644)
[0095] The register peak is cleared.
peak=0
[0096] Step (645)
[0097] The register peak is set to the maximum value of RMS and peak itself. In another way, if the value of RMS is larger than peak, then:
peak=RMS
[0098] Step (646)
[0099] Check if the RMS-value is lower than 80% of the peak value. This indicates that the peak of the magnetic field has occurred and the magnet has been passed.
[0100] Step (647)
[0101] The information necessary for the data packet is the magnet type and the position of the locomotive when the magnet is passed. These values must be stored in global accessible registers accessible by the other interrupt routines. The current position of the locomotive is therefore remembered:
position_magnet=position
[0102] The magnetic type is determined based on two of the axes of the magnetic field of the reference frame. As said, if the measured magnetic field axes does not align with the frame of the locomotive, a three dimensional rotation must be performed. In the following alignment is assumed such that the rotation is not needed.
[0103] The measured signal in the x-axis when passing a magnet will increase toward a peak, then rapidly change toward a peak of opposite polarity, and finally go back toward the initial value. Therefore, at the closest position to the magnet, the value is crossing zero in a rapid change. Below is used a notation, where “x increasing” means that the transition goes from a negative peak toward a positive peak, and “x decreasing” means that the transition goes from a positive peak toward a negative peak.
If (y<0) & (x decreasing) then
type_magnet=right side, south up
If (y<0) & (x increasing) then
type_magnet=left side, north up
If (y>0) & (x decreasing) then
type_magnet=left side, south up
If (y>0) & (x increasing) then
type_magnet=right side, north up
[0104] Note that the sign of the signals can depend on the sign convention used by the manufacture of the magnetic field sensor.
[0105] Step (648)
[0106] The value of peak is doubled such that fluctuations will not trigger a new detection until the RMS-value has become less than the threshold and step (644) has cleared the peak.
peak=2×peak
[0107] Step (649)
[0108] The traveled distance is going to be calculated as an integration of the speed with respect to time. As the integration is carried out in a discrete manner by accumulation rather than a real mathematical integration, the time intervals between accumulations must be constant. Because this interrupt runs at a fixed frequency of 300 Hz, it is used to calculate the traveled distance. Since the locomotive is running on a guided track and always in one direction, the traveled distance corresponds with a position on the track. The traveled distance will therefore get the notation “position”.
position=position+(speed/300)
[0109] Step (650)
[0110] The data packet is created in case it is needed by the command receiver and data packet transmission interrupt routine described below. The data packet combines the position, position_magnet and type_magnet registers together into a bi-directional packet. As this has 32 bits available the first two registers should be 15 bits wide and the type register should be 2 bits wide. Both position and position_magnet are converted to integer numbers with a resolution of 1 mm.
[0111]
[0112] Now when the data packet has been created, it needs to be transmitted on the track. As this embodiment uses NMRA DCC bi-directional standard for that purpose, strictly timing to the received command data is needed. In
[0113] If the data packet is instead transmitted e.g. over a wireless connection, the data packet transmission will not have to be an integrated part of the command receiving interrupt. The data packet would then have to be transmitted periodically from 1 to 10 times per second.
[0114] Step (660)
[0115] Data communication occurs every time the track voltage toggles and this interrupt is triggered by the toggling. This step is assumed to gather the timing of toggles and translate this into a command data packet. This process is known to all developers of model railroad decoders and will therefore not be discussed further.
[0116] Step (661)
[0117] It is checked whether the data packet is complete. Unless it is the last bit, the interrupt is returned.
[0118] Step (662)
[0119] It is checked whether the data packet is addressed to this new decoder. If not, no transmission should occur and the interrupt is therefore returned. The address for the new decoder can be chosen arbitrary as long it is an unused address.
[0120] Step (663)
[0121] The data packet must now be transmitted. The timing of the transmission is given by the bi-directional standard. The actual encoding of the 32 bits is described in the standard. The standard also defines applicable opcodes for experimental usage which can therefore be used for this demonstration. The data packet has already been created in another interrupt routine and is globally accessible.
[0122] We now move our focus to the processing device. At this point the data packet has been created and transmitted. In the following is described how the data packet is received and processed.
[0123]
[0124] The data packets are received by the processing device described in the following. In
[0125] Step (700)
[0126] This it the entry point of the software.
[0127] Step (701)
[0128] The software starts by initializing the clock domain and peripheral blocks. Furthermore it sends a speed step command request for the new decoder using the arbitrary chosen address. The request goes to the command station by the Ethernet interface. This request makes the command station periodically send packets addressed to the new decoder. As only the response from the new decoder is of interest, the speed can be anything except zero. This is because some command stations will terminate the transmission of packets after a while for stopped locomotives. The format of the speed step command to be sent is defined by the command station manufacture.
[0129] Step (702)
[0130] After the processing device has been initialized, there will periodically be sent data packets to the address of the new decoder. The new decoder will answer these command packets with data packets. As the locomotive travels along the track, the data packet will have the position value increased by one for each millimeter it runs. The information regarding the last passed magnet will for must packets be equal to the information in the preceding packet. Only when a magnet is passed, will the content of this information be updated. The content is a copy of the position value when the magnet is passed in addition to the magnetic type.
[0131] The processing device receives data packets and waits for the magnetic information to change.
[0132] Waiting for the first data packet with new magnetic information.
[0133] Step (703)
[0134] Store the position of the magnet and magnetic type information.
magnet1=received magnetic type
position1=received position of magnet
[0135] Step (704)
[0136] Waiting for the second data packet with new magnetic information.
[0137] Step (705)
[0138] Store the position of the magnet and magnetic type information.
magnet2=received magnetic type
position2=received position of magnet
[0139] Step (706)
[0140] Waiting for the third data packet with new magnetic information.
[0141] Step (707)
[0142] Store the position of the magnet and magnetic type information.
magnet3=received magnetic type
position3=received position of magnet
[0143] Step (708)
[0144] Calculate the distances between the magnets as:
distance1=position2−position1
distance2=position3−position2
[0145] Search the database for an initial position based on the five registers above, magnet1, magnet2, magnet3, distance1 and distance2. Detailed description of this process follows shortly. The search algorithm should be called twice with the clockwise and anti-clockwise linked list calls used respectively. The best overall match should be used. The direction is determined from the overall best match from the clockwise and anti-clockwise searches. The direction should be remembered, because this is a used parameter elsewhere in the algorithms.
[0146] Assuming the initial position of the locomotive has now been found, the regulation of the speed of the locomotive can begin. The locomotive will run at the highest chosen speed until a signal at danger is found in the route the locomotive is going to take.
[0147] Step (709)
[0148] Search the database and calculate the distance to the next signal at danger. Detailed description of this process follow shortly. The process returns a value which is equal to the distance from the last passed magnet to the signal. The remaining distance to go should be subtracted by the distance already traveled since the last magnet was passed, which is equal to the received position subtracted by the received position of the magnet:
position_since_magnet=position−position_magnet
distance to_go=returned value−position_since_magnet
[0149] Because the position of the locomotive is actually the position of the new decoder inside the locomotive, the remaining distance should further be subtracted by a value equal to the length from the new decoder to the front of the locomotive. This way the front of the locomotive will stop in front of the signal regardless of the position of the new decoder in the locomotive:
distance to_go=distance to_go−length_to_front
[0150] The length to_front value is measured by the user when installing the new decoder.
[0151] Step (710)
[0152] Based on a calibration of the locomotive, the braking distance for each speed step has been automatically measured and is stored in a list. Alternatively the list is created from a user defined deceleration curve. A part of the list could be:
Step 3: 30 mm
Step 4: 50 mm
Step 5: 90 mm
[0153] etc.
[0154] If the distance_to_go calculated in the step (709) is between 30 and 49 mm, then the locomotive should be running at speed step 3. If this is the case, then no change in speed is necessary and the flow proceeds to step (712).
[0155] Step (711)
[0156] However, if the locomotive is not running at speed step 3, then a new speed step command must be issued to the command station by the Ethernet interface. The new speed step should be as high as possible, but such that the distance in the table do not exceed the calculated distance_to_go. For example would a calculated distance_to_go of 85 mm results in a wanted speed step of 4. The list leads to a staircase step-down regulation of the speed of the locomotive all the way down to the stop position in front of the signal. The regulation is based on the received position from the data packet that is based on the measured motor voltage. It is observed that any delay in communication causes less inaccuracy as the speed gets lower. The final stop position is therefore very accurate and deviates only by a few millimeters. Furthermore, there is no demand for a constant speed when the braking starts. Neither must be braking have a fixed length, and the list above could be dynamically changed, e.g. when traveling downhill or when a large load is added to the locomotive. Further, the braking can start at any position regardless of the position of turnouts and the length to the previous signal. Many of the advantages of this invention come from this continuously regulation of speed based on the actual travelled distance, instead of the approach based on pre-measured calibration data and a predetermined braking length.
[0157] Step (712)
[0158] The steps (709, 710 and 711) forms a regulator that regulates the speed of the locomotive. The regulator must run at a periodic interval. Depending on the microcontroller the implementation can either be based on a timer or an inserted delay. The accuracy of the periodic interval is not important, anything between 1 to 10 times per second is acceptable, and therefore 3 times per second has been chosen as a target and is created by a delay of 333 milliseconds.
[0159]
[0160] In
[0161] Step (720)
[0162] Data communication occurs every time the track voltage toggles. This step creates the data command packet similarly to step (660).
[0163] Step (721)
[0164] It is checked whether the data packet is complete. Unless it is the last bit, the interrupt is returned.
[0165] Step (722)
[0166] It is checked whether the command packet is addressed to the new decoder. If this is not the case, then no data packet of interest will follow either, and the process can jump to step (725).
[0167] Step (723)
[0168] However, if the new decoder is addressed, it will send a data packet in return. The data packet is in this step received and decoded.
[0169] Step (724)
[0170] If the initial position has not been found, the execution of this step is omitted. Else, if the data packet contains new magnetic data, the element number found by the initial search will be updated. The element number will be equal to the element number of the next magnet in the database. This is found by following the element number in the linked list until the element type equals a magnet. The linked list to be used is equal to the direction of traveling. At this stage the interrupt is returned.
[0171] However, the travelled distance since last magnet can further be checked against the length of the database elements between the magnets. If the measured distance deviates considerable from the database length, an error handling can be implemented. Also the magnetic type reported by the data packet should match the magnetic type stored in the database.
[0172] Step (725)
[0173] It is checked whether the command packet is related to signals or turnouts. If not, the interrupt is returned.
[0174] Step (726)
[0175] If the packet is related to either a signal or a turnout, then the state of that is remembered. This can be as simple as a single bit in a global accessible array of signals and turnouts. The interrupt is then returned.
[0176] The states of signals and turnouts are necessary for carrying out the search in the database for next signal at danger. This is because the turnouts are responsible for determining which route the locomotive is going to take. On this route only approaching signals at danger are of interest.
[0177] In the following will be described the two processes referred to above. The descriptions use a notation where pointer.name refers to the value in the database of the row where “pointer” equals the element number and where “name” equals the wanted value, for example:
100.type=magnet,
105.clockwise=103 and
110.length=897 mm,
as seen in the database example in
[0178]
[0179] In
[0180] The search is demonstrated carried out in the clockwise direction only, but by replacing the clockwise linked list calls with the anti-clockwise linked list calls, the search will be carried out in the anti-clockwise direction. Further, for the anti-clockwise direction the right/left notation of magnetic types should be interchanged.
[0181] Step (740)
[0182] Initialize the match register that should hold the element number of the found location and set the error register to an unrealistic high value.
match=0
error=1,000,000
[0183] Step (741)
[0184] Loops through all database elements. If end element is reached, the process jumps to step (750).
element=1, 2, 3, . . . , max
[0185] Step (742)
[0186] Check if the magnet type magnet1 matches the type of the element. If not, jump to step (741).
if element.type˜=magnet1 then jump
[0187] Step (743)
[0188] However, if it matches, the element number is updated by the clockwise linked list value.
element=element.clockwise
[0189] Now accumulate the length of all elements until an element of type magnet is reached.
sum1=0
while element.type˜=magnet then
sum1=sum1+element.length
element=element.clockwise
[0190] Step (744)
[0191] Similar to step (742), but checks against magnet2 instead.
[0192] Step (745)
[0193] Similar to step (743), but accumulates into sum2 instead.
[0194] Step (746)
[0195] Similar to step (742), but checks against magnet3 instead.
[0196] Step (747)
[0197] The two accumulated database lengths are compared to the two measured distances. An error is calculated as:
RMS=SQUARE_ROOT((distance1−sum1){circumflex over ( )}2+(distance2−sum2){circumflex over ( )}2)
[0198] Step (748)
[0199] Compares the RMS-value to the error register. If the RMS-value is lower than the error register, a new candidate for initial position has been found, and it is the best candidate so far. Therefore continue to next step.
[0200] Step (749)
[0201] Store the new best candidate.
match=element
error=RMS
[0202] Step (750)
[0203] Return the found element number in the register “match” to the calling function. Also store the register “error” such that the best overall result can be found.
[0204]
[0205] In
[0206] The search is carried out in the clockwise direction only, but by replacing the clockwise linked list calls with the anti-clockwise linked list calls, the search will be carried out in the anti-clockwise direction. Also the check of element types should be changed from clockwise to anti-clockwise. The linked list to be used is equal to the direction of traveling.
[0207] Step (760)
[0208] The search for next signal at danger is initialized with one input; the element number to the last passed magnet. The lengths in the database will be accumulated into the register sum. A loop counter is sat to 100 to prevent an infinite loop scenario in case no signal is found at danger.
element=input to process, an element number
sum=0
loop=100
[0209] Step (761)
[0210] First the element type is checked against length.
if element.type=length, then continue with step (762).
[0211] Step (762)
[0212] The length of the element is accumulated in sum.
sum=sum+element.length
[0213] Step (763)
[0214] The element type is also check against clockwise signal.
[0215] If element.type=clockwise signal, then continue with step (764).
[0216] Step (764)
[0217] Check if the signal is red. This is achieved by finding the signal number in the parameter list and check if the corresponding bit in the array of signals and turnouts has been asserted. If this is the case, terminate the search by jumping to step (770).
[0218] Step (765)
[0219] Else check if the element type is clockwise turnout.
[0220] If element.type=clockwise turnout, then continue with step (768).
[0221] Step (766)
[0222] Else update the element to the next element in the linked list.
element=element.clockwise
[0223] Step (767) Check if the search has run through the element check enough times. If this is the case, continue to step (770).
loop=loop−1
If loop=0 then continue with step (770)
[0224] Else start over again with the new element number by jumping back to step (761).
[0225] Step (768)
[0226] If the element type was a clockwise turnout, now it is time to check which direction it takes. This is achieved by finding the turnout number in the parameter list and check if the corresponding bit in the array of signals and turnouts has been asserted. If this is not the case, the turnout is straight and the process jumps to step (766), because the element number in the linked list holds the straight element number.
[0227] Step (769)
[0228] However, if the turnout is diverging, the next element number is found in the parameter list. Then jump to step (767).
element=(element number from parameter list)
[0229] Step (770)
[0230] The distance from the last passed magnet to the signal at danger is equal to the value in “sum”. The result is returned from the process.
[0231] Now all the processes to exchange information, control locomotives and utilize the database has been described. In the following is described a user friendly approach to insert new signals in the database.
[0232]
[0233] In order for the control algorithm to know when to brake a locomotive, the physical location of signals must be known and related to elements in the database.
[0234] In currently available commercial solutions the braking in front of signals is activated either by a dedicated piece of electronics connected to an isolated track section in front of each signal, or by a computer having a number of occupancy sensors connected to electrical isolated track sections. In either case, the position of a signal can be determined relative to the isolated track section.
[0235] However, this invention do not have isolated track sections nor does it utilizes visually identifiable reference points. It is therefore difficult for the user to determine the location of signals based on the reference points. Further, the magnets cannot be observed from a normal perspective at the layout because they are placed underneath the baseboard.
[0236] The invention therefore include a method for locating a point of interest and storing it in the database. The method is described for a signal, but the same approach can be used to locate turnouts, block sections etc. In
[0237] Step (200)
[0238] The user drives a locomotive to the location, where the signal should be placed. It is assumed that the calculation of the initial position has occurred such that the processing device at this state knows the position of the locomotive.
[0239] Step (201)
[0240] From a computer, a dedicated hardware device, or a mobile device (111), the user is provided with a user interface. An example of a mobile device application is shown in
[0241] Step (202)
[0242] The API calculates the position of the front of the locomotive. Because the position data received from the locomotive is actually representing the position of the new decoder inside the locomotive, the position of the front should be calculated by adding a value equal to the length from the new decoder to the front of the locomotive. This way the front of the locomotive will be known as position_front:
position_front=position+length to_front
[0243] If the value of position_front exceeds the length of the current element, the linked list is used to determine a new element number. When the locomotive is facing in the clockwise direction:
position_front=position_front−element.length
until element.type=length do:
element=element.clockwise
[0244] If the value of position_front still exceeds the length of the element, repeat the above instructions.
[0245] Step (203)
[0246] Modify the database to include the signal at the given position of the front of the locomotive. The steps of this process is given in the following example.
[0247]
[0248] In
[0249] First two new elements are inserted in the database, called Y (element 115) and Z (element 116). Y becomes the signal, which will have the type clockwise signal. The address will be stored in the parameter column. Z is of the type length, and holds the remaining length of the element X (element 114) after subtraction of the distance the front has traveled into the element. W (element 113) is the original clockwise element to X. Insert in the database:
Z.length=X.length−front_into_element
X.length=front_into_element
Y.type=clockwise signal
Y.parameter=the address of the signal
Y.anti-clockwise=X
Z.anti-clockwise=Y
W.anti-clockwise=Z
X.clockwise=Y
Y.clockwise=Z
Z.clockwise=W
[0250] It is seen, that two new elements have been added and that three numbers in the old rows have been updated. These changes are marked with bold text in
[0251] From a user experience point of view, the method of defining a position based on the actual position of a locomotive, is a huge advantage from the ordinary trial and error approach used by commercial solutions today. The method can further be used to define other point of interests on the layout, e.g. turnouts.
Second Embodiment
[0252] This embodiment describes a variant of the new decoder, which is based on an ordinary decoder. Some ordinary decoders have the motor sensor (300) for load compensation purpose and the data packet transmitter (304) for programming on the main track. They therefore have all the necessary hardware parts except for the magnetic field sensor (302).
[0253] This second embodiment is a combination of the new decoder functionality and the ordinary decoder functionality in a new single device called a compound decode (306), as shown in the
[0254] The compound decoder is beneficial because the locomotives only have one socket for a decoder. The user can then easily replace the ordinary decoder with the compound decoder in order to use this invention. At this point the benefit of having a three dimensional magnetic field sensor should be noticed. From the description of the first embodiment, it was seen: that the y-axis would had been enough to detect the magnets; and that the y-axis and the x-axis would have been enough to determine the magnetic type. However, with all three axes the decoder can obtain any orientation inside the locomotive. This ensures that the compound decoder will work regardless of the placement of the decoder socket.
Operation—Second Embodiment
[0255] There is no difference in the operation of the second embodiment compared to the first embodiment, except that the processes shown in
Third Embodiment
[0256] In the first embodiment, the command station is assumed to support the DCC bi-directional standard. The standard defines a cutout period where the power to the track is removed and the track output is shorted to form a low impedance current loop. The decoders can then generate a current signal through the loop by introducing a small voltage on the track. In order to support as many modern command stations from different vendors as possible, the bi-directional functionality can be integrated into this invention. This way the invention can be used by more DCC command stations and even multi-protocol systems.
[0257] In
Operation—Third Embodiment
[0258] There is no difference in the operation of the third embodiment compared to the first embodiment, except that the primary switches (406) and (407) and secondary switch (408) must be controlled. The DCC bi-directional standard gives the timing requirements. It says that the primary switches must open 26 to 32 microsecond after the command receiver (401) has detected the last bit in a command packet. The switches must close again 454 to 488 microsecond after the last bit in a command packet. The secondary switch must be closed only while the primary switches are open and otherwise it must be open. The secondary switch should be closed as long as possible without introducing shoot-through of the output of the command station (109). The timing of the secondary switch therefore depends on the specifications of the solid state relays.
[0259] The mentioned control of the switches should occur only after packets addressed to the new decoder.
[0260] Most microcontrollers, including the one specified in the first embodiment, have dedicated peripherals to control switches in a timely manner. The software therefore needs only to activate a timer in the microcontroller, when the last bit in a packet is addressed for the new decoder. This modification can be added to step (723) in
[0261] Step (723)
[0262] This step additionally starts a timer. When the timer reaches 26 microseconds an interrupt is started, which opens the primary switches and closes the secondary switch. When the timer reaches 454 microseconds, yet another interrupt is started, which opens the secondary switch and closes the primary switches again.
Fourth Embodiment
[0263] In
Operation—Fourth Embodiment
[0264] There is no difference in the operation of the fourth embodiment compared to the first embodiment, except that the software described for the microcontroller (402) of the processing device must be integrated and combined with the software of the microcontroller in the command station (109). Alternatively, parts of the software can run on a computer (411) or similar processing device. In this alternative, the command station must provide the command packets via the computer network, such that the processing algorithms in the computer know the state of signals and turnouts, speed of locomotives etc.
CONCLUSION, RAMIFICATION, AND SCOPE
[0265] Accordingly, the reader will see that methods and devices of the various embodiments can quite effortless be implemented to determine the position of a locomotive on a model railroad. With a known position of the locomotive, location-based behaviors can easily take place and greatly improve the user experience. Both in terms of installation and performance the solution is superior.
[0266] The first and second embodiments describe two versions of the decoder and the first, third and fourth embodiments describe three versions of the processing device. Even though only four embodiments have been described, it should be understood, that all six combinations of the two decoder versions and three processing device versions are feasible variations.
[0267] Although the description above contains many specificities, these should not be construed as limiting the scope of the embodiments but merely providing illustrations of some of several embodiments. For example the peak detection algorithm of
[0268] Thus the scope should be determined not by the embodiments illustrated but the appended claims and their legal equivalents, rather than by the examples given.