First Spiral Example

This chapter provides a step-by-step procedure that takes you through using the Graphical Cell Compiler to generate a model for a square (four-sided) spiral. It starts at the very beginning and traces each trial-and-error step as the model is created.

Create the Source Layout

When creating a Parameterized Artwork Macro (PAM) using the Graphical Cell Compiler, we start by placing the required items in a source layout:

  1. Create a new design
  2. Use the positional coordinate readout at the bottom of the window to insert a path with square corners between 50,50 and 50,-50.
    Note You must use square corners; otherwise, your results will not be accurate.
  3. Insert a construction line below the path. Do not touch the path.
  4. Insert a port at coordinates 50,0.
    Now we are ready to create a spiral.

Define a Polar Control

  1. Choose the command Macro > Polar .

    Note the message displayed in the Polar control Definition dialog box. This appears because we opened the dialog box before we selected a control line and the shape that we want the control to apply to. This is not a problem.
  2. Select the path and the control line. Do not select the port at this time (for now we will just work with the path).
  3. We will try using the Polar control default values, so click OK.

    Again the program keeps us from making a mistake. We must define the radius we want to use.
  4. In the Radius field, enter 0.0 (no units are needed when the value is 0). Now each field has an entry.
  5. Click OK.
  6. Choose Macro * > * View/Edit . The polar control that we defined is listed here.
  7. Click Detail .
    The detail list shows:
    Control: Polar
    Delete Ends: False
    Units: Radians
    Start: 0.0
    Stop: PI
    Step: PI/8.0
    Radius: 0.0
    X Offset: 0.0 mil
    Y Offset: 0.0 mil
  8. Click OK in both the List and the Viewer dialog boxes.
  9. Choose Macro * > * Compile .
  10. Click Save Design .
    Since you saved this design after placing the items, the program simply resaves the design to the same name. Although we have not made any changes to the design (so the save is not necessary) you are reinforcing a good habit by saving before you compile.
  11. Click Compile .
    The Compile Messages window displays:
    • The path and name of the design
    • Model parameters (none, in this case)
    • The type of control (Polar)
    • Any errors or warnings
      If any model parameters had been defined, we would now set their default values, but at this point there are no parameters to set.
  12. Click OK.
  13. In the Main window, open a new Layout window.
  14. Click the Display component library list icon and select the Compiled Artwork Macros library.
  15. Double-click the component we just created and insert it in the Layout window:

    Since this does not look anything like a spiral, it is pretty obvious that we made an (artificial) mistake.
    We need to cut the path with the construction line, so that the control stretches the path, rather than copying it.

Edit the Source Design and Check the Effects

  1. In the source design, move the construction line up so that it crosses the port (and 0,0), as shown.
  2. Choose Macro * > * Compile .
  3. Click Save Design to save the change that you just made, then click Compile .
  4. In the Layout window that contains the model, note that the inserted model did not change. Once you insert a model, it stays as defined by the macro when you inserted it. Either delete the old model, or move it out of the way.
  5. Insert the updated model from the Compiled Artwork Macros library.

    This is better, but we need to remove the straight parts of the path that are caused by the original shape. It is as if the control inserted a curve in the center of the original shape. All we want is the curve.

Remove the Ends of the Path

  1. In the source design, choose Macro > View/Edit .
  2. In the Viewer, select the Polar control and click Edit .
  3. In the Polar Definition dialog box, click the button at the top of the dialog box to turn on the Delete End-Points feature. If you check the Detail List now, you will see that the control is defined as follows:
    Control: Polar
    Delete Ends: True
    Units: Radians
    Start: 0.0
    Stop: PI
    Step: PI/8.0
    Radius: 0.0
    X Offset: 0.0 mil
    Y Offset: 0.0 mil
  4. Save the design and recompile the macro. Then reinsert the model.

    This looks much better.
    We know that a spiral needs to go around several times, and that it must spiral out. For this example, we want it to go around twice.

Set the Spiral for Out, Twice Around

  1. In the Polar Definition dialog box, enter 4.0*PI (twice around) in the Stop parameter field.
  2. We know the model needs to spiral out, so we will set the radius of the spiral as a function of Angle. Enter 50.0_angle mil* in the Radius parameter field.
    This time you must include the units, or you will get something very big.
    The Detail List now looks like:
    Control: Polar
    Delete Ends: True
    Units: Radians
    Start: 0.0
    Stop: 4.0*PI
    Step: PI/8.0
    Radius: 50.0*_angle mil
    X Offset: 0.0 mil
    Y Offset: 0.0 mil

    Note the use of the Global Variable. For more information, see Using Variables in the Radius & Offset Parameters".

  3. Save the design, recompile the macro, and reinsert the model.

    Well, we have a spiral. It is difficult to tell in this figure, but you will notice on your screen that this spiral is very big. This is because the variable _angle goes from 0 to 6.28 for the first time around, multiplied by our desired spacing of 50.0 (set in the Radius parameter).

Normalize Angle

If we change the value of Radius to normalize _angle :

Control: Polar
Delete Ends: True
Units: Radians
Start: 0.0
Stop: 4.0*PI
Step: PI/8.0
Radius: _angle/(2.0*PI)*50.0 mil
X Offset: 0.0 mil
Y Offset: 0.0 mil


At this point we have a pretty good definition for a rounded spiral. We would want to decrease the step size (by increasing the number of steps) so that it would be smoother, but this is pretty close.

Increase the Step Size

For a square spiral, though, we need to increase the step size so we have only four points (steps) per cycle.

Control: Polar
Delete Ends: True
Units: Radians
Start: 0.0
Stop: 4.0*PI
Step: 2.0*PI/4.0
Radius: _angle/(2.0*PI)*50.0 mil
X Offset: 0.0 mil
Y Offset: 0.0 mil

We still have several problems. The first is simply that we would like the spiral to be oriented vertically rather than based on the Angle points. To do this, we add a Rotate/Move/Mirror control.

Add a Rotate/Move/Mirror Control


Control: Polar
Delete Ends: True
Units: Radians
Start: 0.0
Stop: 4.0*PI
Step: 2.0*PI/4.0
Radius: _angle/(2.0*PI)*50.0 mil
X Offset: 0.0 mil
Y Offset: 0.0 mil
   
Control: Mirror
Units: Degrees
Angle: -45.0
X Offset: 0.0 mil
Y Offset: 0.0 mil
X Mirror: FALSE
Y Mirror: FALSE

The next problem, which you may have noticed, is that the lines are not far enough apart. Because we used 50.0 for the space, and the path is 25.0 wide, we would expect the space between lines to be the same as the width of the lines. The problem is in the radius formula, which specifies a distance of 50.0 from one corner to the next corner, but we want a distance of 50.0 from one side to the next side . The corner-to-corner distance must be larger than 50.0.

A Short Geometry Lesson

We must look into a little geometry to resolve this. We will use an angle greater than 90° (as if we had more than four sides) so we will be forced to come up with a general case.

Using our two-turn spiral, the following is what we know about the triangle formed between two vertex points:


  1. (line width plus spacing).
  2. Since the sides are parallel and b is the distance between sides, then
    .
  3. Because
    , the more sides the spiral has the smaller the incremental angle at each vertex.
    For this case:
    .
  4. Because
    ,
    .
  5. The Law of sines states that:
    . Since
    , we get

    .
    If we substitute the above values:

Switching to radians:

We could evaluate the constant, but we will leave it like this so it is easier to replace the 4 with a variable for the number-of-sides later.

Note A general purpose spiral would use user-supplied values for the line width, spacing, number of turns, and perhaps number of sides. For now we are using constants for all of these. Once the basic model works, we will go back and add the parameters.

Use the More Accurate Equation for Radius

Control: Polar
Delete Ends: True
Units: Radians
Start: 0.0
Stop: 4.0*PI
Step: 2.0*PI/4.0
Radius: _angle/(2.0*PI)*50.0 mil/sin(PI/2.0-PI/4.0)
X Offset: 0.0 mil
Y Offset: 0.0 mil
   
Control: Mirror
Units: Degrees
Angle: -45.0
X Offset: 0.0 mil
Y Offset: 0.0 mil
X Mirror: FALSE
Y Mirror: FALSE

The last problem (why the spiral is not square ) is much more serious. For a simple rounded spiral, each point is placed at an ever-increasing radius from the center. As is obvious, that does not work for a square spiral (or any n -sided spiral where n is small). Basically, each point needs to be pushed along the direction of the side by a fraction of the distance between spirals.

Add an Offset

Given that we are at some angle Theta (as we step around the spiral) we need to push the vertex point for the current side out. The angle B is the same as we derived above. Since each time we move around the spiral we move 50.0 mil out, we move 1/4 (1/sides actually) that amount for each side. Our offset needs to be 1/2 that amount, so we need to move (remembering that most of these constants will become variables later) 50.0 / (4 * 2).

Next, we need to rotate that amount based on the current step angle Theta plus the angle B.
Since rotation is defined as

X = r * cos(a) - r * sin(a)
Y = r * cos(a) + r * sin(a)

we can substitute everything and we're ready to go. This is where the X and Y offset fields become useful. We take all this and fill it in:

Control: Polar
Delete Ends: True
Units: Radians
Start: 0.0
Stop: 4.0*PI
Step: 2.0*PI/4.0
Radius: _angle/(2.0*PI)*50.0 mil/sin(PI/2.0-PI/4.0)
X Offset: 50.0 mil/(4*2)
*(cos(_angle+PI/2.0-PI/4.0)-sin(_angle+PI/2.0-PI/4.0))
   
Y Offset: 50.0 mil/(4*2)
*(cos(_angle+PI/2.0-PI/4.0)+sin(_angle+PI/2.0-PI/4.0))
   
Control: Mirror
Units: Degrees
Angle: -45.0
X Offset: 0.0 mil
Y Offset: 0.0 mil
X Mirror: FALSE
Y Mirror: FALSE

Now it is time to do something about pins.

Include the Port

We start by simply including the port in both controls. Nothing else changes.

  1. In the source design, choose Macro > View/Edit .
  2. In the Viewer, select the Polar control and click Edit .
  3. In the design, select the path, the control line, and the port, then click OK.
  4. Save the design, recompile the macro, and reinsert the model.

    We need to use the same polar equations for the ports, but we do not want all the steps. In fact, we want only one step (the last one).

Add a Polar Control for the Port

In order to fix the previous problem of too many ports being created, we need to create a new Polar control that acts just on the port. This means we need to edit the existing Polar control and remove the port from its selected shapes. We then create a new Polar control to operate on just the port. The two Polar controls will be identical except that this second one will have the Step set to the same value as the Stop so that it creates only one copy of the port at the end of the spiral.
It is important that the two Polar controls take place before the Mirror control so that the generated spiral and the ports line up correctly.
Be sure that when all the additions are done, each control is operating on the listed shapes:

Replace the Constants with Parameters

  1. We use the following parameters in the two Polar controls:
    • Turns = the number of complete revolutions
    • Sides = the number of sides
    • Width = the width of the path
    • Space = the space between the revolutions
  2. We also add a Width control to the path so that it resizes in response to the width parameter:
    • Control: Width
    • Change: Absolute
    • Width: width
      Up until now, we used constants and had to include the mil unit designator. In the following equations we use parameters we will define to be in mils (in step 2), so a designator is no longer needed. If we left it in we would basically be converting to mils twice, and the results of the equations would be too small. Filling everything in and doing a little equation cleanup, we get:
      Control: Width
      Change: Absolute
      Width: width
         
      Control: Polar
      Delete Ends: True
      Units: Radians
      Start: 0.0
      Stop: turns*2*PI
      Step: 2.0*PI/sides
      Radius: _angle/(2.0*PI)*(width+space)/sin(PI/2.0-PI/sides)
      X Offset: (width+space)/(sides*2)
      *(cos(_angle+PI/2.0-PI/sides)
      -sin(_angle+PI/2.0-PI/sides))
      Y Offset: (width+space)/(sides*2)
      *(cos(_angle+PI/2.0-PI/sides)
      +sin(_angle+PI/2.0-PI/sides))
         
      Control: Polar
      Delete Ends: False
      Units: Radians
      Start: 0.0
      Stop: turns*2.0*PI
      Step: turns*2.0*PI
      Radius: _angle/(2.0*PI)*(width+space)/sin(PI/2.0-PI/sides)
      X Offset: (width+space)/(sides*2)
      *(cos(_angle+PI/2.0-PI/sides)
      -sin(_angle+PI/2.0-PI/sides))
      Y Offset: (width+space)/(sides*2)
      *(cos(_angle+PI/2.0-PI/sides)
      +sin(_angle+PI/2.0-PI/sides))
         
      Control: Mirror
      Units: Degrees
      Angle: -360/(sides*2)
      X Offset: 0.0 mil
      Y Offset: 0.0 mil
      X Mirror: FALSE
      Y Mirror: FALSE
  3. After compiling the macro, we must set default values for the parameters we have defined. Note that the parameters are listed in the Compile Messages window.
    Note Depending on your setup, the messages displayed can differ from those shown.
  4. Click Design/Parameters .
  5. In the dialog box that appears, click the Parameters tab.
    The parameters are listed in the Select Parameters window. Set them as follows:
    Turns = 3, Unitless
    Sides = 4, Unitless
    Width = 20.0 mil, Length
    Space = 15.0 mil, Length
  6. Click Save AEL , then OK.
  7. In the PAM Compiler dialog box, click OK.
  8. Place the new component.

Simplifying Long Equations

In this example, the equations in the Polar controls are pretty long and there is a lot of duplication in them. There is a way to simplify them.

Warning These types of modifications must be done with extreme care. If you reorder the controls or make other changes, it is easy to create a situation where constants are referenced before they are defined. It is much safer to leave expressions long, with a lot of duplication.

Because the Start/Stop/Step equations are evaluated before the Radius/Offset equations, and since any local variables are visible during the evaluation of the Radius/Offset equations, it is possible to define a local constant to use in them. Using local constants, the controls look like:

Control: Polar
Delete Ends: True
Units: Radians
Start: 0.0; decl temp_a = PI/2.0-PI/sides;
Stop: turns*2*PI
Step: 2.0*PI/sides
Radius: _angle/(2.0*PI)
*(width+space)/sin(temp_a)
X Offset: (width+space)/(sides*2)
*(cos(_angle+temp_a)-sin(_angle+temp_a))
   
Y Offset: (width+space)/(sides*2)
*(cos(_angle+temp_a)+sin(_angle+temp_a))
Control: Polar
Delete Ends: False
Units: Radians
Start: 0.0
Stop: turns*2.0*PI
Step: turns*2.0*PI
Radius: _angle/(2.0*PI)*(width+space)/sin(temp_a)
X Offset: (width+space)/(sides*2)
*(cos(_angle+temp_a)-sin(_angle+temp_a))
Y Offset: (width+space)/(sides*2)
*(cos(_angle+temp_a)+sin(_angle+temp_a))
   
Control: Mirror
Units: Degrees
Angle: -360/(sides*2)
X Offset: 0.0 mil
Y Offset: 0.0 mil
X Mirror: FALSE
Y Mirror: FALSE

The constant is declared as part of the first Polar control's Start parameter as it is evaluated in AEL. It is then available for each evaluation of the Radius and Offset expressions for the first and second Polar controls.
By editing the AEL file, you can use the spiral model to create spirals with different widths, as shown.

 

Privacy Statement  | Terms of Use  | Legal | Contact Us  | © Agilent 2000-2008 

Contents
Additional Resources