Tuesday, February 10, 2009

How does First Zone work?

If this is the first time you visited this blog, you might want to read these posts first:
Hunting for the DCC system of the future.
Robotics and DCC.

Steve is a follower, he asked:
"So what are the benefits of having the terms the way you have them? Wouldn't the first zone be different depending on where the loco (for example) was first placed on the tracks? How does that distance help with the rest of the layout?"

This sounds like a good topic for today's blog.


When you power up the system for the very first time, you can place a loco anywhere on the track. When it is run, it will come to a zone boundary, ( the insulator that separates two zones. ) It then starts a timer. When it comes to the other end of that zone, it then notes how long it took to get THROUGH that FIRST ZONE (Fz).

From That point on, for every session, that section of track is the First Zone. It remains the First Zone until you perform a software reset.

The first zone is then assigned a length of ONE. Continuing around the track, the loco can time each of the other zones and assign them lengths that are based on the time it took to get through the "FIRST ZONE".
If the second zone takes twice as long, then it's length is two Fzs.
If the loco takes one fourth as long to get through a zone, it's length is 0.25 FZs.

To simplify the above explanation, we'll assume for now that the loco travels at one constant speed. However, we will see later that the loco can still do this, when the speed changes.

Remember, One goal is to have the system work without the tons of configurations needed by existing systems. In fact, no user input at all.

So, put yourself in the position of a robot.

You wake up and find yourself in a curving, twisted concrete tunnel.
You are on a remote controlled golf cart.
An on-board fax prints out instructions telling you to measure the lengths of all the "Zones" in the tunnel and draw a map.
There is a stopwatch, but instead of seconds, it is calibrated in TICKS.
The servo on the throttle is calibrated 0 through 127 and labeled "STEPS".

STEPS, not MPH of KPH. The golf cart does not have a speedometer.

The servo moves to 40 STEPS. The cart starts moving. You have no idea how fast a STEP is, or even what scale you are. You might be an N scale robot or a G scale robot.

You come to a line painted on the tunnel walls. A sign says, "You are leaving Zone B and entering Zone C". You reset the stopwatch to zero and start it.

You come to another line and a sign that says, "You are leaving Zone C and entering Zone A" You notice it took 1800 ticks.
You start drawing a map showing the first zone you have measured.

FIRST ZONE
ZONE C
1800 ticks at 40 steps
?--B/C-----1800@40----------C/A

You come to another line and a sign that says, "You leaving Zone A and are entering Zone B" You notice it took 900 ticks. Your servo holds steady at 40
You add to your map.

?--B/C-------1800@40--------C/A----900@40---A/B

You come a third line and a sign that says, "You are leaving Zone B and entering Zone C" You notice it took 900 ticks at 40 steps
You add to your map.

?--B/C-------1800@40--------C/A----900@40---A/B---900@40----B/C


At this point, You might think you are back in the First Zone, zone "C".

That would mean you are on a loop. However, there might be several zone "C"s. To be sure you are on a loop, you would predict that you should leave zone C and enter Zone A in 1800 ticks. Then, if the next two zones match your map and each take 900 ticks, you are confident that you have measured the entire loop.

When that is done,you can draw a sketch. The total time to go around the loop was 1,800 + 900 + 900 = 3,600 ticks, or 10 ticks per degree. You can start at zero degrees (12 noon) and going clockwise draw the first zone (C) 180 degrees to the 6 o'clock position. The other two zones each take 90 degrees.


To report this, you can send:
First zone = C
Zone C = 1
Zone A = 0.5
Zone B = 0.5

Notice that we don't know the actual length of any zone. But, we can describe the length of each zone in terms of the first zone.
It would also be useless to report back the time it took to go through each zone because we have no idea what speed the golf cart is going at STEP 40.

In reality, you need to send three other numbers for each Zone, Confidence, Accuracy and Resolution. Confidence has to do with changing speed while measurements are made. Accuracy has to do with variations in the number of ticks required to go through the same zone multiple times. Resolution has to do with the number of total ticks used for each zone.

Once all the numbers are crunched, the information can be shoved back into the golf carts fax machine and will be used by all the other robots that might need a map of this tunnel.

HOMEWORK
If you'd like to try this assignment and receive a grade, record your answers in this FORM. It will open in a separate window.

You are a robot. Another robot has already made a map. You will use its map.

You wake up to find yourself in a tunnel on a fax equipped, remote controlled moped with a stop watch.
The fax spews out the information shown above.
A servo is marked off in numbers from 1 to 14. It moves to the 10 mark and your moped lurches forward.

Exactly 155 ticks later, you see a sign that says "you are leaving Zone B and entering Zone A.

  • Question 1 - What direction are you traveling?
    (a) Clockwise.
    (b) Counterclockwise.
    (c) Unknown.
  • Question 2 - How long will it take you to get to Zone C?
    (a) 900 ticks.
    (b) At least 155 ticks or longer.
    (c) 745 ticks.

After entering Zone A, you found it took you 200 ticks to get all the way through Zone A to to Zone C.

  • Question 3 - When you enter zone C at step 10, how long do you predict it will take you to get to zone B?
    (a) 200 ticks.
    (b) 400 ticks.
    (c) 1800 ticks.
  • Question 4 - You just left zone C and entered Zone B. 600 ticks later, where are you?
    (a) In Zone A.
    (b) Lost.
    (c) At the 3 o'clock position on the diagram above.
  • Question 5 - You leave Zone B and enter Zone A, Still going at 10 steps. Starting at the time you enter Zone A, how many ticks later should you slam on the brakes to stop at your original starting point.
    (a) 645 ticks.
    (b) 45 ticks.
    (c) At the 3 o'clock position on the diagram above.

If you get all five answers right, then you realize that, without knowing any actual speeds or distances;

  • We can tell exactly where you are now.
  • We can tell where you will be in the future if you continue at that speed step.
  • We can tell you how long to continue running to arrive at any spot in the tunnel.



Click HERE to see the correct answers.

4 comments:

Steeeeve said...

Hmmm, Why do you have to be going counterclockwise? Can't zone A and B be switched on your diagram and achieve the same results only moving the opposite way? If this is true than you have no way to know which direction it is going other than to say it is going the same or opposite as it was before...or as another loco did before.

This is this true than that explains why I got question 1 and 4 wrong haha.

Steeeeve said...

Not sure if you got my last comment but I wrote but I basically was asking how you knew if you were going clockwise or counterclockwise. You can have zones C,B, and A look different can't you? for example you could have ABC going clockwise or BAC going the opposite way so how do you know direction other than to say it is the same or opposite as the first train?

Bob Grosh said...

Then the first loco was placed on the track, the first boundary it came to had a sign that said: "You are leaving Zone B and entering Zone C".

Now go back and look at the drawing.

There is only one spot on the circle where B and C touch. That's 12 o'clock.

OK. The first loco doesn't know it is going clockwise, counterclockwise, north , south, east or west for that matter.

However, I need to be able to tell which direction the loco is going, not just forward or backward, but it's orientation on the rails. Just in case someone picked it up and turns it around.

I could have said that the first loco is going forward in the Normal Direction of Travel, but, Direction of Travel is confusing to DCC users who have changed CV's to reverse the way the motor turns to go forward.

You are correct. the circle could have been drawn a number of different ways.

I chose, BY CONVENTION, to take the first FORWARD movement of the first loco to be either EASTBOUND (point to point) or CLOCKWISE starting at 12:00 for the first zone ( for a loop).

Granted, these have no meaning in the real world. Particularly for a figure eight, folded dog bone or pretzel track plan.)

However, I needed some way to consistently represent a "ROBOTS EYE VIEW" of the world.

OK, let's move on. We need a way to track the movement of a loco. Speed step 50 FORWARD is not enough. It does not take into account how the loco is oriented on the track, (IE: which way it is facing)

So the term Velocity is used instead. Velocity has a speed and vector component. So, + 50 indicates it is traveling east, or clockwise (by convention) and -50 is a loco running west or counterclockwise.

The golf cart robot drew us a map.
He had no idea if he was on a figure eight, or a pretzel. He just drew a circle and assumed he was going clockwise. (Even though he had no real idea.)

He faxed it out for the Moped Robot to use.

The Moped robots starts out moving and "Exactly 155 ticks later, you see a sign that says "you are leaving Zone B and entering Zone A."

If you look at the drawing furnished by the Golf Cart robot, you can see that there is only one place where zones A and B touch, That is where the blue and green zones meet at about 9 o'clock.

Since you left the blue line (zone B) and entered the green line (zone A), you know you are going counterclockwise ON THE FAX THE GOLF CART ROBOT FURNISHED)

This tells you that your vector is a negative number.

By looking at the drawing, you can also see that the green line is the same length as the blue line. Since you traveled 155 ticks on the blue line, it will take at least 155 ticks to reach the red line. This is sort of important. We always want to predict how long we can go before reaching some other point, be it another zone or some other train. It allows us to update information once a second instead of ten or a hundred times a second. We can run more trains with less processing power.

So, Why do I use Vector instead of Speed?
Let's say you are a robot at a speed of fifty and you are at 9 o'clock. The closest loco to you is also going fifty and he is at 10 o'clock. If both your vectors are the same, you are matching speeds. Not a problem.
If your velocity is positive and his is negative, then you are closing at 100. A huge problem.

Knowing that the other loco is going FORWARD or REVERSE is useless, we don't know how the loco is oriented.

A little off topic, but, also an important lesson to learn here.

"Why do I always say you have to have at LEAST three zones on a loop"?

You can see the answer if you draw a circle with only zones A and B.

When the robot sees a sign that says, "You are leaving Zone A and entering zone B." Where is the robot, and which direction is it traveling?

Good question Steve, Thanks for asking.

Bob.

Steeeeve said...

Ok, so "golf cart robot" just drew the map for convention as opposed to reality. I figured this might be true as it is irrelevant to have it accurate but relevant to know which way "moped robot" was moving in relation to "golf cart robot". It seems like you do this with +1 and -1 multipliers.

The two questions that bug be is what happens when you have a zone that doesn't connect to anything such as your yard? The second question would be what happens if you have two sidings that are the exact same length using the same zone (say zone B) and they are both located in zone A? For example you have a main with two sidings, one of the left and one of the right (like a subway/metro stop)? Could it be able to determine the difference by switch positioning?