The Eggbot coordinate system

From Evil Mad Scientist Wiki
Revision as of 20:20, 11 October 2010 by Dnewman (talk | contribs) (Created page with "'''This page is still being written and it could use some diagrams as well''' * How does the Eggbot frame my drawing on my egg? * Where does the Eggbot start drawing on my egg? ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is still being written and it could use some diagrams as well

  • How does the Eggbot frame my drawing on my egg?
  • Where does the Eggbot start drawing on my egg?
  • Where is (0,0) or some other coordinate on my egg?

These are natural questions to ask. However, the answers to these questions are somewhat unsatisfying if you do not first understand the nature of the Eggbot's drawing motors....

After reading this discussion, not only should you know the answers to the above questions and why, but you should also develop an understanding of

  • The conventions adopted for mapping your Inkscape drawings to the surface of your egg.
  • Most importantly, the intrinsically relative nature of the drawing motors.
  • And, how other mechanical aspects of the Eggbot impinge on drawing.

With that said, let's get down to business and discuss these "drawing" motors.

The Eggbot has mounted to its chassis two identical "drawing" motors. One motor rotates the egg while the other moves the pen arm along an arc. Either motor can rotate either clockwise or counter-clockwise. As the two motors are mounted with their shafts at 90 degrees to one another, the pen arm arc is at a right angle to the egg's direction of rotation. These two motors are of a type known as "stepper" motors. There's also a third, smaller motor which is mounted to the pen arm. We are not concerned with that motor in this discussion.

The first thing to understand about the two stepper motors is that they can be turned clockwise or counterclockwise in very precise, small steps. Hence the name, "stepper" motor. These steps are so small, that it takes 3200 steps total to turn either of the motor's shafts a complete turn (360 degrees). Consequently, turning either motor a total of 3200 steps in the same direction brings the motor shaft around to where it started. It follows that if you advance either motor N + 3200 steps, then that is the same as advancing it only N steps.

Now for a mechanical "gotcha". Can you rotate a loaded egg a ful circle? Yes, you can. Can you rotate that pen arm a full circle? No, you cannot: the pen arm hits the head or tailstocks of the chassis. So, while the pen arm's motor shaft can itself turn a full 360 degrees, the combination of the pen arm and chassis severely limits this range of motion. So much so that the pen arm can only move about 56 degrees either side of vertical. That makes for a total range of around 112 degrees or (conveniently) about 1000 motor steps.

So, let us recap what we know so far:

  • A stepper motor rotates the egg clockwise or counter clockwise
  • The egg can be rotated in either direction up to 3200 steps before comimg full circle back to where it started
  • A stepper motor moves the pen arm back and forth
  • The pen arm can be moved about 1000 steps of total travel

Armed with what we know so far, we can begin to adopt some conventions in mapping an Inkscape drawing to an Eggbot plot. Inkscape uses a two-dimensional Cartesian coordinate system. So, we can think of an Inkscape drawing in terms of (x,y) coordinates with the x-axis running horizontally across our computer screen and the y-axis running vertically. In keeping with scalable vector graphics, the units of measure used in an Inkscape drawing are arbitrary and only matter so far as rescaling the drawing to appear on a specific output device is concerned (e.g., a computer screen, a printer, or an Eggbot). In theory, the Eggbot could determine each plot's bounding box and then scale the drawing to fit on an egg. However, that's not very satisfactory and would require controls to limit how much of the egg to draw on (but I didn't want the pony to fill the entire egg). Rather than go that route, the Eggbot instead assumes that your Inkscape drawing is scaled one-to-one to your egg. This does *not* mean that what you see on your screen will be the same size as what you see on your egg. After all, Inkscape *is* rescaling your drawing when it maps it to your display. What this means is that each unit of length in your drawing will correspond to one stepper motor step.

With this 1:1 scaling convention, we identify Inkscape's x-axis with egg rotation and y-axis with pen arm travel. It this stands to reason that we take Inkscape drawing template to have a width of 3200 units and a height of 1000 units. The width of our template then corresponds to the complete circumference of an egg, and the height to the maximum range of pen travele Horizontal lines in our Inkscape drawings will travel around the egg's axis of rotation, while vertical lines will travel towards or away from the head and tailstocks (e.g., from or towards the egg's poles). For example, consider a horizonal line of length 1600 units in Inkscape. When we plot this line on the Eggbot, the pen arm will not move at all. It won't move because for a horizontal line, the y-coordinate is constant (unchanging). When the line is plotted, all that will happen is that the pen will be lowered and the egg rotated 1600 steps which corresponds to a half revolution (180 degrees). Note that in the above description, it was stated that the pen arm doesn't move at all. It doesn't even need to move to the starting point for the line. Odd? Interesting? More on this after we first explain a very important detail about the Eggbot's stepper motors.

Simple stepper motors such as those in your Eggbot do just one thing: rotate their shafts in discrete steps. These stepper motors do not -- repeat do not -- have fixed reference positions. Not even a single one. It's not possible to tell the motors to go to some specific angle of rotation or some location distinguishable from any other location. All you can do is tell the motors to turn a step in one direction or another. Moreover, it's not possible to "read" from the stepper motors their configuration. (Expensive, industrial stepper motors have built in encoders which allow this.) So, these stepper motors can only be controlled using "relative" coordinates; i.e., move N steps forwards or backwards from your present position.

So, a direct consequence of this relative nature of stepper motors is that the Eggbot has no idea what position the egg or pen arm is in when it begins a plot. Let's repeat that: the Eggbot has no idea where the pen or egg is when it begins a plot. At best, the Eggbot can track the cumulative number of forward (positive) and backwards (negative) steps each motor has taken since starting a plot [1]. Knowledge of the cumulative number of steps allows the Eggbot to return the pen to any previous position in the current plot, but that's all. The "Return to home" option is implemented this way: after finishing a plot, the each stepper motors is stepped the opposite number of cumulative steps that that motor took while drawing the plot. The net, overall travel for each motor then becomes zero steps.

Another direct consequence of this relativity, is that there is no utility to having absolute Eggbot coordinates. What's the use of an absolute position (0,0) in Eggbot plotting space when the Eggbot has no idea what asbolute position either stepper motor is in? Nonetheless, it sure would be nice to know where your drawing will land on your egg....

Enter the "Start with pen centered" option. What this option says, when checked, is that the pen is *assumed* to be positioned somewhere on the horizontal line y=500. That's the midline (equator) of a drawing page whose lower left corner is at (0, 0) and upper left corner is at (3200, 1000). The exact x starting coordinate isn't too critical, but what the Eggbot does is to assume that the pen's starting x-coordinate is that of the first point in your drawing. (This may not be the first point it plots as in the case of plotting only a single layer of the drawing.)

If you do not check the "Start with pen centered" option, then the Eggbot assumes that the pen is located at the first point in your drawing. For all but the simplest drawings, it's anyone's guess which point will be the first point in your drawing: it's all up to how Inkscape chose to order the data in the underlying SVG document (file). As such, operating without the "Start with pen centered" option is something of a gamble.

So, how does the Eggbot frame your drawing? It really doesn't frame it at all. Instead, if you use the "Start with pen centered" option, then it assumes that the pen is positioned over the midline of the drawing -- the drawing and not your egg. If you want the drawing's midline to correspond to the egg's equator *and* your drawing uses a document of height 1000 units, then you can position the pen over the egg's equator and then the drawing's midline and the egg's equator will coincide. What if your drawing is only 800 units high? Well, then the line y=500 will be 100 units above your drawing's midline. But it's this y=500 line which the Eggbot will assume the pen is over.

Where does the Eggbot begin drawing on your egg? Well, if the first line in your drawing starts at coordinate (x0, y0) *and* you use the "Start with pen centered", then the Eggbot will assume that the pen is pointed at the point (x0, 500) and it will move the pen arm y0 - 500 steps before starting to draw. If y0 > 500 this means moving the pen arm towards the headstock (positive number of steps). If y0 < 500, this means moving the pen arm towards the tailstock (negative number of steps). And if y0 = 500, then the pen arm need not move at all to reach the first point.

Where is (0, 0) on your egg? Turns out it really doesn't matter. But if you must know, then let (x0, y0) be the coordinate of the starting point of the first line segment in your drawing. Then, when you start the plot with "Start with pen centered", the point (0, 0) will be -x0 egg rotation steps to the left of the pen and 500 pen arm steps "down" towards the tailstock.

And, now that you understand that the Eggbot uses relative coordinates, what about the Inkscape drawing template? Does it need to be 3200 by 1000 units. Not really. Nor is it too important what the coordinates of its corners are. About all that really matters about the drawing template is whether or not you use the "Start pen centered" option. If you use that option, then you want to know where the y=500 line is in your drawing template. That's because the Eggbot will assume that the pen starts somewhere on that line. If the drawing template itself ranges from y=-500 to y=0, then everything plotted will be outside the travel range of the pen arm. But, if you do not use "Start with pen centered", then you could plot such a drawing just fine.

[1] Between plots, the process doing the plotting exits and this knowledge is lost. When a plot begins anew, the Eggbot doesn't know what happened the last time it plotted. The only exception to this is when you pause a plot with the PRG button on the EiBotBoard. In that case, the Eggbot saves some data in your drawing file. The plot can be resumed from where it left off assuming that you don't turn the egg or move the pen. (Or if you do that you can then manually restore the egg and pen to the position at which the plot was paused.)