Manipulate[
 (*by Nasser M. Abbasi, version Dec 19, 2013*)
 
 tick;
 Module[{x0, y0, z0, point, d = 0.5},
  
  If[state == "running" || state == "step",
   t = t + speed;
   phi = currentW1*t + 1/2 w1dot*t^2;
   theta = currentW2*t + 1/2 w2dot*t^2;
   currentW1 = currentW1 + w1dot*t;
   currentW2 = currentW2 + w2dot*t;
   currentRaoV = currentRaoV + raoAcc*t;
   rr = currentRaoV*t + 1/2 raoAcc*t^2;
   If[state == "running",
    tick += del
    ],
   If[state == "reset",
    t = -speed; phi = 0; theta = 0; rr = 0; x = 0; y = 0; z = 0; 
    currentRaoV = raoV; currentW1 = w1; currentW2 = w2; phi = 0; 
    theta = 0; rr = 0; line = {LL}; tick = 0
    ]
   ];
  
  x0 = L1 + r Cos[theta];
  y0 = -L3 + r Sin[theta];
  z0 = L4 + L2 + d;
  
  x = L1 + rr Cos[theta];
  y = -L3 + rr Sin[theta];
  z = L4 + L2 + d;
  
  point = {x, y, z};
  AppendTo[line, point];
  
  g = Text@Grid[{
      {
       Grid[
        {
         {Style[
           "Simulation for problem 1, HW3, EMA 542, Fall 2013, Univ. \
Of Wisconsin, Madison", Small], SpanFromLeft},
         {Style["ant coordinates", Bold], SpanFromLeft},
         {Grid[
           {
            {"(w2) disk", "w1 (frame)", "inertial"},
            {Grid[{
               {"x", "y", "z"},
               {padIt1[
                 If[Abs[#] > 1000, Sign[#]*1000, #] & /@ rr , {7, 3}],
                 0, 0}
               }, Frame -> All, Spacings -> {.2, .4}
              ],
             Grid[{
               {"X", "Y", "Z"},
               {padIt1[If[Abs[x] > 1000, 1000*Sign[x], x], {7, 3}], 
                padIt1[If[Abs[y] > 1000, Sign[y]*1000, y], {7, 3}], 
                padIt1[L2, {7, 3}]}
               }, Frame -> All, Spacings -> {.2, .4}],
             Grid[{
               {Style["X", Bold], Style["Y", Bold], Style["Z", Bold]},
               {padIt1[
                 L1 Cos[phi] + L2 Sin[phi] + 
                  rr Cos[theta] Cos[phi], {7, 3}],
                padIt1[-L3 + rr Sin[theta], {7, 3}],
                padIt1[-L1 Sin[phi] + L2 Cos[phi], {7, 3}]}
               }, Frame -> All, Spacings -> {.2, .4}]
             }
            }, Spacings -> {.2, .2}, Frame -> True, 
           FrameStyle -> Directive[Thickness[.001], Gray]
           ], SpanFromLeft
          }
         }, Frame -> True, 
        FrameStyle -> Directive[Thickness[.001], Gray], 
        Alignment -> Center
        ]
       },
      {
       Graphics3D[
        {
         Text["inertial", {-r - 5, 0, 3}],
         {Arrowheads[Medium], 
          Arrow[{{-r - 5, -2, 3}, {-r - 4, -2, 3}}]},
         Text[Style["X", Bold, 12], {-r - 3.5, -2, 3}, {-1, 0}],
         
         {Arrowheads[Medium], 
          Arrow[{{-r - 5, -2, 3}, {-r - 5, -1, 3}}]},
         Text[Style["Y", Bold, 12], {-r - 5, -.8, 3}, {-1, 0}],
         
         {Arrowheads[Medium], 
          Arrow[{{-r - 5, -2, 3}, {-r - 5, -2, 2}}]},
         Text[Style["Z", Bold, 12], {-r - 5, -2, 1.8}, {-1, 0}],
         
         GeometricTransformation[
          {
           
           If[showW2Coordinates,
            {
             {Arrowheads[Medium], 
              Arrow[{LL, LL + {r Cos[theta], r Sin[theta], 0}}]},
             
             Text[Style["x", 12], 
              LL + {1.1 r Cos[theta], 1.1 r Sin[theta], 0}, {-1, 0}],
             {Arrowheads[Medium], 
              Arrow[{LL, 
                LL + {r Cos[theta + Pi/2], r Sin[theta + Pi/2], 0}}]},
             
             Text[Style["y", 
               12], {LL + {1.1 r Cos[theta + Pi/2], 
                 1.1 r Sin[theta + Pi/2], 0}}, {-1, 0}],
             {Arrowheads[Medium], Arrow[{LL, LL + {0, 0, r}}]},
             Text[Style["z", 12], {1.1*(LL + {0, 0, r})}, {-1, 0}]
             },
            {}
            ],
           {Red, Thin, Line[line]},
           {Red, PointSize[Medium], Point[point]},
           
           {Opacity[Dynamic@op], 
            Cylinder[{{L1, -L3, L4 + L2}, {L1, -L3, L4 + L2 + d}}, r]},
           {Red, Cylinder[{{0, -0.2, 0}, {0, 0.2, 0}}, 0.2]},
           
           {Blue, Cylinder[{{0, -0.8, 0}, {0, 2, 0}}, 0.1]},
           
           Tube[{{0, 0, 0}, {L1, 0, 0}, {L1, 0, L2}, {L1, -L3, 
              L2}, {L1, -L3, L4 + L2}}, 0.06],
           Cylinder[{{L1, -L3, L2}, {L1, -L3, L4 + L2}}, 0.2],
           
           If[showW1Coordinates,
            {
             {Arrowheads[Medium], Arrow[{{0, 0, 0}, {1, 0, 0}}]},
             Text[Style["X", 12], {1.1, 0, 0}, {-1, 0}],
             
             {Arrowheads[Medium], Arrow[{{0, 0, 0}, {0, 3, 0}}]},
             Text[Style["Y", 12], {0, 3.1, 0}, {-1, 0}],
             
             {Arrowheads[Medium], Arrow[{{0, 0, 0}, {0, 0, 1}}]},
             Text[Style["Z", 12], {0, 0, 1.1}, {-1, 0}]
             },
            {}
            ]
           
           
           },
          RotationTransform[phi, {0, 1, 0}]
          ]
         }
        , ImageSize -> {400, 400}, Boxed -> False, 
        AxesLabel -> {"x", "y", "z"}, ViewVertical -> {0, 1, 0}, 
        ViewPoint -> {1, .5, 2}, SphericalRegion -> True, 
        PlotRange -> {{-r - 5, r + 3}, {-r - 3, r + 2}, {-r - 3, 
           r + 3}}, ImagePadding -> 1, Axes -> None, 
        ViewAngle -> Dynamic[zoom*Pi/180.0]
        ]
       }}, Spacings -> {0, .1}, Alignment -> Center];
  g
  ],
 
 Text@Grid[{
    {
     Grid[{
       {
        Button[Text[Style["run", 11]], state = "running"; tick += del,
          ImageSize -> {50, 35}],
        Button[Text[Style["pause", 11]], state = "paused"; 
         tick += del, ImageSize -> {50, 35}],
        Button[Text[Style["step", 11]], state = "step"; tick += del, 
         ImageSize -> {50, 35}],
        Button[Text[Style["reset", 11]], state = "reset";
         tick = 0, ImageSize -> {50, 35}]
        }
       }, Spacings -> {0.4, .2}, Alignment -> Center
      ]
     },
    {
     Grid[{
       {
        "slow",
        Manipulator[
         Dynamic[speed, {speed = #} &], {0.0001, 0.001, 0.0001}, 
         ImageSize -> Tiny, ContinuousAction -> True],
        "fast", SpanFromLeft
        },
       {
        "disk r",
        Manipulator[
         Dynamic[r, {r = #; state = "paused"; tick += del} &], {0.5, 
          2.3, 0.1}, ImageSize -> Tiny, ContinuousAction -> True],
        Dynamic[padIt2[r, {2, 1}]], "ft"
        },
       {
        "w1",
        Manipulator[Dynamic[w1, {w1 = #; state = "reset";
            tick += del} &], {0.001, 10, 0.001}, ImageSize -> Tiny, 
         ContinuousAction -> True],
        Dynamic[padIt2[w1, {4, 3}]], "rad/sec"
        },
       {
        "w2",
        Manipulator[Dynamic[w2, {w2 = #; state = "reset";
            tick += del} &], {0.001, 30, 0.001}, ImageSize -> Tiny, 
         ContinuousAction -> True],
        Dynamic[padIt2[w2, {5, 3}]], "rad/sec"
        },
       {
        "d/dt(w1)",
        Manipulator[Dynamic[w1dot, {w1dot = #; state = "reset";
            tick += del} &], {0.001, 1, 0.001}, ImageSize -> Tiny, 
         ContinuousAction -> True],
        Dynamic[padIt2[w1dot, {4, 3}]], "rad/sec^2"
        },
       {
        "d/dt(w2)",
        Manipulator[Dynamic[w2dot, {w2dot = #; state = "reset";
            tick += del} &], {0.001, 1, 0.001}, ImageSize -> Tiny, 
         ContinuousAction -> True],
        Dynamic[padIt2[w2dot, {4, 3}]], "rad/sec^2"
        },
       {
        "ant speed",
        Manipulator[Dynamic[raoV, {raoV = #; state = "reset";
            tick += del} &], {0.001, 3, 0.001}, ImageSize -> Tiny, 
         ContinuousAction -> True],
        Dynamic[padIt2[raoV, {4, 3}]], "ft/sec"
        },
       {
        "ant acc",
        Manipulator[Dynamic[raoAcc, {raoAcc = #; state = "reset";
            tick += del} &], {0.001, 3, 0.001}, ImageSize -> Tiny, 
         ContinuousAction -> True],
        Dynamic[padIt2[raoAcc, {4, 3}]], "ft/sec^2"
        },
       {
        "disk opacity",
        Manipulator[Dynamic[op, {op = #} &], {0.1, 1, 0.1}, 
         ImageSize -> Tiny, ContinuousAction -> True],
        Dynamic[padIt2[op, {1, 1}]], SpanFromLeft
        },
       {
        "zoom",
        Manipulator[Dynamic[zoom, {zoom = #} &], {10, 130, 1}, 
         ImageSize -> Tiny, ContinuousAction -> True],
        Dynamic[padIt2[zoom, 2]], SpanFromLeft
        }
       }, Alignment -> Left
      ]
     },
    {
     Grid[
      {
       {"time", Dynamic@padIt2[t, {7, 5}], "sec"}
       }, Spacings -> {.5, .2}]
     },
    {
     Grid[{
       {"show disk coordinates", Spacer[4], 
        Checkbox[
         Dynamic[showW2Coordinates, {showW2Coordinates = #; 
            tick += del} &]]
        },
       {"show bar coordinates", Spacer[4], 
        Checkbox[
         Dynamic[showW1Coordinates, {showW1Coordinates = #; 
            tick += del} &]]
        }
       
       }
      ]
     }
    
    
    }, Frame -> All, Alignment -> Left],
 
 {{showW2Coordinates, True}, None},
 {{showW1Coordinates, False}, None},
 {{speed, 0.001}, None},
 {{r, 2.3}, None},
 {{tick, 0}, None},
 {{del, $MachineEpsilon}, None},
 {{state, "reset"}, None},
 {{t, 0}, None},
 {{x, 0}, None},
 {{y, 0}, None},
 {{z, 0}, None},
 {{line, {{0, 0, 0}}}, None},
 {{w1dot, 1}, None},
 {{w2dot, 0.2}, None},
 {{w1, 1}, None},
 {{w2, 11}, None},
 {{raoV, 0.5}, None},
 {{raoAcc, 0.1}, None},
 {{currentRaoV, 0.01}, None},
 {{currentW1, 0.6}, None},
 {{currentW2, 0.01}, None},
 {{op, 0.1}, None},
 {{phi, 0}, None},
 {{theta, 0}, None},
 {{rr, 0}, None},
 {{zoom, 32}, None},
 TrackedSymbols :> {tick},
 
 ControlPlacement -> Left,
 SynchronousUpdating -> False,
 SynchronousInitialization -> False,
 ContinuousAction -> False,
 Alignment -> Center,
 ImageMargins -> 0,
 FrameMargins -> 0,
 Paneled -> True,
 Frame -> False,
 AutorunSequencing -> {1},
 
 Initialization :>
  (
   L1 = 2.5;
   L2 = 0.7;
   L3 = 1.4;
   L4 = 1;
   LL = {L1, -L3, L4 + L2 + 0.5};
   (*definitions used for parameter checking*)
   integerStrictPositive = (IntegerQ[#] && # > 0 &);
   integerPositive = (IntegerQ[#] && # >= 0 &);
   numericStrictPositive = (Element[#, Reals] && # > 0 &);
   numericPositive = (Element[#, Reals] && # >= 0 &);
   numericStrictNegative = (Element[#, Reals] && # < 0 &);
   numericNegative = (Element[#, Reals] && # <= 0 &);
   bool = (Element[#, Booleans] &);
   numeric = (Element[#, Reals] &);
   integer = (Element[#, Integers] &);
   (*--------------------------------------------*)
   padIt1[v_?numeric, f_List] := AccountingForm[v,
     f, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"}, 
     SignPadding -> True];
   (*--------------------------------------------*)
   padIt1[v_?numeric, f_Integer] := AccountingForm[Chop[v],
     f, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"}, 
     SignPadding -> True];
   (*--------------------------------------------*)
   padIt2[v_?numeric, f_List] := AccountingForm[v,
     f, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"}, 
     SignPadding -> True];
   (*--------------------------------------------*)
   padIt2[v_?numeric, f_Integer] := AccountingForm[Chop[v],
     f, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"}, 
     SignPadding -> True];
   (*--------------------------------------------*)
   
   
   )
 ]