The following is a tabulation of some prior art that presently appears relevant:
National Model Railroad Association (NMRA) standard documents S-9.1, S-9.1.1, S-9.1.2, S-9.2, S-9.2.1, and S-9.2.2 of the Digital Command Control (DCC) standard.
NMRA standard document S-9.3.2 of the DCC bi-directional standard.
An operator of a model railroad layout must often act as a signalman controlling turnouts and signals, but also as engine driver for all running locomotives. This is because no easy solution enables the locomotives to brake automatically at signals at danger. The human brain's limited capacity for multitasking essentially limits the number of simultaneously running locomotives—to a few. Removing the responsibility as engine driver from the operator will allow this person to operate many more simultaneously running locomotives and allow time for general enjoyment of the layout. Solutions for automatic braking at signals at danger has as a consequence been suggested through the past.
Since the introduction in the 1990s most model railroad layouts have become digitally controlled by having decoders in each locomotive receiving digital coded signals transmitted from a command station powering the tracks. This enables each locomotive to be individually controlled anywhere on the layout from the command station by the operator.
However, because the command station is unaware of the position of the locomotives, they cannot be controlled in an automatic manner based on location. A method for achieving location-based behavior is given in U.S. Pat. No. 7,137,600 to Lenz (2006). This patent describes an asymmetrical signal and an apparatus for injection the signal into an electrical isolated track section in front of the signal. Supported decoders detect this asymmetrical signal and brakes within a predetermine braking distance. This method has some drawbacks, where one is that the chosen braking distance must be equal for all signals on the entire layout. This introduces complexity because the chosen braking distance must be long enough to allow a realistic slow deceleration of high speed trains, yet not so long that:
Further the method suffers by having the chosen distance programmed into the locomotives. Consequently they cannot be used on other layouts without first being reprogrammed. Similarly cannot different layouts be combined together without haven been intentionally designed with the same chosen distance.
The challenge of getting location-based behavior can also be addressed by a different approach, by connecting a computer to the command station by a digital interface, e.g. Ethernet. From the prospective of the command station, the computer will act as a human operator issuing instructions. Therefore the command station does not have to utilize automation, as the computer does the necessary calculations. The computer can estimate the position of the locomotives from a number of different methods described below. The computer can e.g. run the TrainController program from Freiwald Software, Germany.
As said, a number of methods for getting the position of the locomotives exist. A first method is to have sensors along the track at known positions, hereafter called reference points. The sensors can be based on infrared light as in U.S. Pat. No. 7,028,955 to Young et al. (2006), U.K. application number 2,563,398 to Jones (2018), and U.S. Pat. No. 8,154,227 to Young et al. (2012), reed switches, RFID tags as in U.S. Pat. No. 6,539,292 to Ames (2003), and U.S. Pat. No. 8,154,227, RF transponders, ultrasound, proximity, camera, barcodes etc. Many of these principles are binary in nature, meaning that they only take two states; either they detect a locomotive or they do not. This raises an uncertainty principle between detection range and detection precision. In order to make sure the reference points are detected at high speed, the range of detection should be increased and consequentially the position is known with less precision.
A second method registers changes from track occupancy detectors, as changes happen when the locomotives pass intersections of electrical isolated track sections. Track occupancy detectors work by measuring whether there is a current consumption in the isolated track section. A problem is that only electrical conducting wheels affect the current consumption. Therefore poor cleanliness of tracks and wheels as well as cars with installation of current consuming elements such as light, has been reported by users to produce unreliable behavior. Also some trains e.g. multiple-unit trains can have the current consumption wheels only in one end or somewhere in the middle of the train, and therefore not breaking at the same position as other trains having a locomotive in the front.
Both methods though limit the computer's awareness of the position to the event at which the sensors or intersections are passed. In-between these events the computer calculates the position based on time since the event occurred multiplied by an estimated speed. The estimated speed is measured in a calibration process. When the remaining distance to any signal at danger is equal to the chosen braking distance, a command is issued to bring the locomotive to a stop. The decoder then decelerate the locomotive within the chosen distance.
This approach requires the locomotive to enter all braking sections with a constant speed that has been measured in a calibration process. The deceleration is solely determent by the decoder in the locomotive, and the computer does not receive any feedback. Any delay introduced from the locomotive enters the braking section until it receives the braking command, will introduce a displacement in the stop position equal to the delay multiplied by the estimated speed of the locomotive. It is therefore possible to use a second sensor closer to the signal, to indicate when the train is near the stop position. Instead of sending a stop command when the first sensor is activated, a threshold speed command is sent to let the train approach the signal at a lower speed. The stop command is sent when the second sensor is activated.
A third method has a computer receiving the position of each locomotive in a continuous manner, whereby the speed estimation and the related drawbacks above are eliminated. The positions must be transferred from the locomotives to the computer either by the track or by a wireless connection. The position must be calculated in the decoder by integrating the traveled distance. The suggested method for measuring the traveled distance is by using a tachometer in U.K. application number 2,563,398 and German application number 20 2004 001 035 to Kuhlmann (2004). None of these described solutions are commercial available and this could be due to the complexity of installing a tachometer. Many locomotives have the entire gearbox as an integrated part of the bogies leaving no space for detection on any rotating axis. Further, the applications use infrared light as reference points, and an infrared sensor must therefore be installed in a downward opening in the locomotive. On the layout infrared transmitters must be installed as reference points. The reference points need wiring—and electronics in case a unique ID is to be transmitted. Drilling is needed on the layout for installation and the transmitters will be visually observable.
In U.S. Pat. Nos. 6,539,292 and 8,154,227 is therefore suggested the use of passive RFID tags instead of infrared light. The problem with RFID is the size of the antenna in the locomotive and how to retrofit it inside the locomotive, as the location and orientation of the antenna is restricted. For reliable RFID detection the range of detection is assumed to have to be quite large and from the uncertainty principle this creates an imprecise location.
Yet a fourth method also involving a computer is to measure the position on the layout using ultrasound. The company GamesOnTrack A/S, Denmark, do this by having multiply transducers in the ceiling of the room and one in each running locomotive. Because of the slow speed of sound waves, the system can triangulate the position of the transducers in the three dimensional space, similar to the satellite based GPS system for outdoor use. The concern about this method is, that the transducers must be installed in openings in the locomotives. Many locomotives do not have this, and the manufacturer therefore shows marketing pictures, where the transducer is mounted on the roof of the locomotive. This visual appearance is not acceptable by many detail-oriented model collectors. Further, hidden areas on the layout is problematic for ultrasonic solutions and reflections from e.g. walls could affect the performance.
All the methods mentioned above suffer from a number of disadvantages:
Accordingly several advantages of one or more aspects are as follows: to provide a solution where the reference points are non-binary in nature, invisible and easily installed without the need of wiring nor drilling, that allow for easy installation in the locomotives by simply replacing the replaceable decoder at any given location and orientation, and that determents the location-based behavior depending on algorithms working without assumptions about initial speed nor a predetermined braking distance. Other advantages of one or more aspects will be apparent from a consideration of the drawings and the ensuing description.
One embodiment is illustrated in
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.
In
In
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.
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.
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.
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
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.
Placement of Magnets
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.
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.
In
Step (600)
This it the entry point of the software.
Step (601)
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
Step (602)
Hereafter it enters an infinite loop with no functionality and all functionality is accomplished by interrupt routines.
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
Step (620)
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.
Step (621)
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.
Step (622)
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
Step (623)
The speed is stored in a global register accessible by the other interrupt routines.
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
Step (640)
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.
Step (641)
The data from the magnetic field sensor is transferred into the microcontroller through a data interface, for example SPI or I2C.
Step (642)
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)
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.
Step (643)
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.
Step (644)
The register peak is cleared.
peak=0
Step (645)
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
Step (646)
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.
Step (647)
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
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.
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
Note that the sign of the signals can depend on the sign convention used by the manufacture of the magnetic field sensor.
Step (648)
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
Step (649)
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)
Step (650)
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.
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
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.
Step (660)
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.
Step (661)
It is checked whether the data packet is complete. Unless it is the last bit, the interrupt is returned.
Step (662)
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.
Step (663)
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.
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.
The data packets are received by the processing device described in the following. In
Step (700)
This it the entry point of the software.
Step (701)
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.
Step (702)
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.
The processing device receives data packets and waits for the magnetic information to change.
Waiting for the first data packet with new magnetic information.
Step (703)
Store the position of the magnet and magnetic type information.
magnet1=received magnetic type
position1=received position of magnet
Step (704)
Waiting for the second data packet with new magnetic information.
Step (705)
Store the position of the magnet and magnetic type information.
magnet2=received magnetic type
position2=received position of magnet
Step (706)
Waiting for the third data packet with new magnetic information.
Step (707)
Store the position of the magnet and magnetic type information.
magnet3=received magnetic type
position3=received position of magnet
Step (708)
Calculate the distances between the magnets as:
distance1=position2−position1
distance2=position3−position2
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.
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.
Step (709)
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
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
The length to_front value is measured by the user when installing the new decoder.
Step (710)
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:
etc.
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).
Step (711)
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.
Step (712)
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.
In
Step (720)
Data communication occurs every time the track voltage toggles. This step creates the data command packet similarly to step (660).
Step (721)
It is checked whether the data packet is complete. Unless it is the last bit, the interrupt is returned.
Step (722)
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).
Step (723)
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.
Step (724)
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.
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.
Step (725)
It is checked whether the command packet is related to signals or turnouts. If not, the interrupt is returned.
Step (726)
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.
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.
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
In
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.
Step (740)
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
Step (741)
Loops through all database elements. If end element is reached, the process jumps to step (750).
element=1, 2, 3, . . . , max
Step (742)
Check if the magnet type magnet1 matches the type of the element. If not, jump to step (741).
if element.type˜=magnet1 then jump
Step (743)
However, if it matches, the element number is updated by the clockwise linked list value.
element=element.clockwise
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
Step (744)
Similar to step (742), but checks against magnet2 instead.
Step (745)
Similar to step (743), but accumulates into sum2 instead.
Step (746)
Similar to step (742), but checks against magnet3 instead.
Step (747)
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)
Step (748)
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.
Step (749)
Store the new best candidate.
match=element
error=RMS
Step (750)
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.
In
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.
Step (760)
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
Step (761)
First the element type is checked against length.
if element.type=length, then continue with step (762).
Step (762)
The length of the element is accumulated in sum.
sum=sum+element.length
Step (763)
The element type is also check against clockwise signal.
If element.type=clockwise signal, then continue with step (764).
Step (764)
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).
Step (765)
Else check if the element type is clockwise turnout.
If element.type=clockwise turnout, then continue with step (768).
Step (766)
Else update the element to the next element in the linked list.
element=element.clockwise
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)
Else start over again with the new element number by jumping back to step (761).
Step (768)
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.
Step (769)
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)
Step (770)
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.
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.
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.
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.
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.
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
Step (200)
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.
Step (201)
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
Step (202)
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
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
If the value of position_front still exceeds the length of the element, repeat the above instructions.
Step (203)
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.
In
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
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
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.
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).
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
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.
There is no difference in the operation of the second embodiment compared to the first embodiment, except that the processes shown in
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.
In
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.
The mentioned control of the switches should occur only after packets addressed to the new decoder.
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
Step (723)
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.
In
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.
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.
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.
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
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.
Number | Date | Country | Kind |
---|---|---|---|
20191494 | Dec 2019 | NO | national |
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/NO2020/050323 | 12/19/2020 | WO |