CNC-Cog

 view release on metacpan or  search on metacpan

Cog.pm  view on Meta::CPAN

  insert
  cut

=head4 new

Creates a new stack object to which other objects may latter be added. 

Parameters are as follows: 

 cuttersize
 passes
 passdepth

These values are used as defaults or for new objects created as part of the
stacking process, not for the objects in the stack itself. 

=head4 add

Takes 1 or more objects and adds them into the stack. The objects should 
be in the order, the object nearest the top to be first. Add should 
be used only to add larger objects if it is used more than once. 


=head4 insert

like add, alo takes 1 or more objects and inserts them into the stack , except
that objects are inserted before all those that currently exist.  Smaller
objects should be inserted. They will be machined nearer the surface. 


=head4 cut

All the objects in the stack will be cut at the x and y co-ordinates
given, starting at the z co-ordinate given with further objects plotted
lower down to suit. 

Takes parameters x, y, z. 

=head3 Grahamwheel

This is subclassed from wheel and so all wheel methods apply. A Graham wheel
is defined as a a wheel with straight sided teeth, the sides being 
inline with a point offset from the wheel center so that the teeth slope. The
teeth may be narrower at the top than the bottem, and the relative amont of 
space on the wheel circumference given to the tooth and the intertooth gap 
may be controlled. The tooth is topped with a shape that may be chosen from 
a number of alternatives. 

=head4 new

The new function of the Grahamwheel class needs to passed a hash with some 
or all of the following parameters: 

  lift              If a flat tooth top is used then this parameter can be 
                    used to increase the height of the trailing edge of the
                    tooth top. 
  nteeth            How many teeth to have.
  externald         The external diameter of the wheel. 
  toothdepth        How deep the spaces between teeth should be.
  toothtop          Size in degrees of the top of the tooth. 
  toothtoppc        Alternatively, size as a percentage of 1 tooth-and-gap. 
  toothbase         Size in degrees of the tooth at the base
  toothbasepc       Alternatively, size as % of tooth-and-gap. 
  offset            In degrees of top of tooth from bottom. 
  holesize          If set, gives a hole at center of wheel. 
  topshape          Should be one of the following strings: 
                       flat       Gives a flat tooth top
                       circ       Similar to flat, but give a circular
                                  shape centered on the wheel center. As
                                  This is a large distance, this is nearly 
                                  flat. Flat may work better with the lift
                                  parameter set. 
                       bicirc     Two approx quarter circles are used with 
                                  a flat piece in between them 
                       circlead   The leading edge only is rounded. 
                       circtrail  The trailing edge only is rounded
                       semi       A (near) semi circle of the right diameter 
                                  is used. 
  toothradius       The radius used in bicirc, circlead and circtrail
  toothradiuspc     Alternative using percentage of tooth-and-gap
  filletradius      radius used at botto of tooth. Must be greater than cutter
                    radius. 
  

=head4 cut

The cut function takes an optional extra rotation parameter theta as well as
conventional x,y and z parameters. See below. 

=head3 Grahamyoke

=head4 new

New takes a has which may contain any of the following parameters:
Nearly all parameters may have l or r added to the end in case different 
parameters are required for left and right, otherwise both left and right
sides will be the same. This does not of course mean symetric since 
lift is always applied in such a way as to lift the yoke. 

Parameters that may have l and/or r applied are as follows: 

    lift 
    r 
    angle
    leradius
    droopangle

Parameters and their meanings are as follows: 

    lift        lift degrees (of pendulum swing)
                This is the angle that force would be applied to the pendulum
                if no rounding on wheel or yoke tooth edges is used. If these 
                are used then the angle of applied force will be greater. 
    r           Innerradius of yoke.   
    armwidth    This is the thickness of the non-tooth part of the yoke. 
    width       Thickness of the teeth. 
    innerradius Cosmetic - This is the radius of inner curves, except
                for the lower one. 
    outerradius Cosmetic - This is the radius of outer curves, except 
                for the upper one. 
    topradius   Cosmetic - radius of top curve
    botradius   Cosmetic - radius of bottom curve
    angle       This is the angle subtended by the tooth at the suspension 
                point. 
    holesize    Diameter of a hole (if any) place at the pivot point. 
    leradius    Leading edge radius, if any. (Otherwise, sharp) Trailing edge
                is always sharp. 
    droopangle  Angle that yoke top makes with horizontal. 

Quantities marked cosmetic are cosmetic only in the sense that they do not
affect opperation directly. The inner radii need to be bigger than the cutter
as otherwise cutting will not be possible. All of these as well as being 
specified in arbitrary units in the normal way, may also be specified
as percent in which case this is taken as percent of armwidth. For example

  "120%" 

Where angles are supplied, these can be supplied in radians by appending an r
to the value: 

"1.01r"

Such values are lift angle droopangle

As is normally the case, linear dimentions may have units appended and will 
be converted. These are 

r armwidth width innerradius outerradius botradius topradius holesize leradius

and l-r varients. 

=head4 Example Code For Graham

The Graham wheel and yoke are in a more experimental state than the rest of
the code. The code below is the code I used: 

  my $nteeth=40; 
  my $w=new Grahamwheel({
                nteeth=>$nteeth, 
                externald=>1.75,
                toothdepth=>0.1,
                offset=>2,      # degrees 
                toothbase=>30,  # percent of whole tooth gap. 
                toothtoppc=>8,   # percent of whole tooth gap, ie of 360/nteeth
                toothradiuspc=>50,
                lift=>0.00,  # inches
                filletradius=>0.033,    # radius used to cut tooth gap, in 
                               # inches, should be just greater than cutter. 
                holesize=>5/32, 
                topshape=>'semi'});


  my $sheetthickness=0.135; # Nominally an 1/8 inch sheet, Make slightly more
                            # to get a clean cut 
  $w->cutset(1/16,5,-$sheetthickness/5); # cuttersize, passes, passdepth
  
  $w->trepan(8,0.5,0.2,0.050,0.05,6.0,0.1);
  $w->bossindent(0.25,-0.015,1);  # diameter indent, depth indent, num passes

  my $cuty=0;  # set non zero, eg -0.9 to seperate parts for cutting. 
                                  
  $w->cut($g,0,$cuty-0.2,0,0); # cut the wheel. 

  my $pi=4.0 * atan2(1, 1);

  my $ns=8.75;  # how many teeth to span, more gives less swing 
  my $angle=16;  # working face angle, from center line.
  
  my $a=360*$ns/$nteeth/2; # angle between yolk tooth and vertical at wheel center

  # externald - toothdepth/2 from above   
  my $h=(1.75-0.1/2)/2/cos($a*$pi/180); # This is dist between centeres of 
                                        # yoke and wheel. Gives 90 deg line 
                                        # of action. 
  my $R=sqrt($h**2-(1.75/2)**2);        # length of arm

  my $droop=$a-$angle; # Droop angle. 
  my $ltg=2*$pi*(1.75-0.2)/2/40;        # linear tooth gap, used to get 
  print "ltg=$ltg\n";                   # size of yoke teeth about right

  $w=new Grahamyoke({ droopangle=>$droop,
                      leradius=>0.015,
                      angle=>$angle,
                      r=>$R,
                      width=>$ltg/4, 
                      lift=>1,
                      armwidth=>0.25, 
                      innerradius=>0.07, 
                      outerradius=>0.1,
                      topradius=>0.2,
                      botradius=>0.2,
                      holesize=>5/32,
                   });

  $w->cutset(1/16,5,-$sheetthickness/5); # cuttersize, passes, passdepth
  $w->cut($g,0,$cuty+$h-0.2,0,3); 

  $g->gend(); 

=head4 Comments On The Code

There is a lot of ugliness here. Many constants are added in and then
written in explicitly further down. I know this. Its clear that some further
encapsulation is needed. I've not done that yet because I've not yet 



( run in 1.991 second using v1.01-cache-2.11-cpan-0fb53d1c279 )