Difference between revisions of "FreeCad Gear Box"

From OpenCircuits
Jump to navigation Jump to search
Line 36: Line 36:
 
Two classes have been found useful so far.
 
Two classes have been found useful so far.
  
* Part3D
+
* Part3D This is a set of z values, top, bottom.... , a name for the part, some simple calculations, and a print method to show the values.  Easy way to set values and see them.
* PartStack
+
* PartStack This is an list of parts ( Part3D ) to be stacked up in the z direction.  It has a name, an order of parts, simple relations between the parts, and a nice way of printing the values.
 +
* Nothing very complicated, but have proved to be handy and not error prone.
  
 +
== Sample Calculation ==
  
  
 +
<pre>
 +
import gear
  
 +
print"""Set some standards
 +
"""
 +
 +
washer_thick  = .1
 +
gear_clear    = .5
 +
gear_thick    = 5.
 +
plate_thick    = 1.
 +
 +
 +
a_stack    =  gear.PartStack( "two gears" )
 +
 +
 +
l_plate  = gear.Part3D( "l_plate", plate_thick )
 +
a_stack.add_up( l_plate )
 +
a_stack.comp_z_top_mid()
 +
 +
l_washer = gear.Part3D( "l_washer", washer_thick )
 +
a_stack.add_up( l_washer )
 +
a_stack.comp_z_top_mid()
 +
 +
 +
l_spacer = gear.Part3D( "l_spacer", 5.0 )
 +
a_stack.add_up( l_spacer )
 +
a_stack.comp_z_top_mid()
 +
 +
 +
l_gear = gear.Part3D( "l_gear", gear_thick )
 +
a_stack.add_up( l_gear )
 +
l_gear.comp_z_top_mid()
 +
 +
 +
u_gear = gear.Part3D( "u_gear", gear_thick + gear_clear )
 +
a_stack.add_up( u_gear )
 +
u_gear.comp_z_top_mid()
 +
 +
 +
u_spacer = gear.Part3D( "u_spacer", 5. )
 +
a_stack.add_up( u_spacer )
 +
u_spacer.comp_z_top_mid()
 +
 +
 +
u_washer = gear.Part3D( "l_washer", washer_thick )
 +
a_stack.add_up( u_washer )
 +
a_stack.comp_z_top_mid()
 +
 +
 +
u_plate = gear.Part3D( "u_plate", 5. )
 +
a_stack.add_up( u_plate )
 +
u_plate.comp_z_top_mid()
 +
 +
 +
print( "-----------------------" )
 +
 +
a_stack.print_stack()
 +
</pre>
 +
 +
=== Output ===
 +
<pre>
 +
Set some standards
 +
 +
-----------------------
 +
 +
------------ Stack: two gears ------------
 +
l_plate
 +
    bot  = 0.0
 +
    thick= 1.0
 +
    mid  = 0.5
 +
    top  = 1.0
 +
l_washer
 +
    bot  = 1.0
 +
    thick= 0.1
 +
    mid  = 1.05
 +
    top  = 1.1
 +
l_spacer
 +
    bot  = 1.1
 +
    thick= 5.0
 +
    mid  = 3.6
 +
    top  = 6.1
 +
l_gear
 +
    bot  = 6.1
 +
    thick= 5.0
 +
    mid  = 8.6
 +
    top  = 11.1
 +
u_gear
 +
    bot  = 11.1
 +
    thick= 5.5
 +
    mid  = 13.85
 +
    top  = 16.6
 +
u_spacer
 +
    bot  = 16.6
 +
    thick= 5.0
 +
    mid  = 19.1
 +
    top  = 21.6
 +
l_washer
 +
    bot  = 21.6
 +
    thick= 0.1
 +
    mid  = 21.65
 +
    top  = 21.7
 +
u_plate
 +
    bot  = 21.7
 +
    thick= 5.0
 +
    mid  = 24.2
 +
    top  = 26.7</pre>
  
  
  
 
[[Category:Python]] [[Category:FreeCad]]
 
[[Category:Python]] [[Category:FreeCad]]

Revision as of 09:39, 10 February 2017

What

This is a little record of my work to make and print a gearbox using FreeCad

Issues

A Python Helper Program

In my approach to the problem each part needs to be positioned ( so far in the z axis ) so that all the parts come together correctly. I started to do this by making a sketch of a side view of the gearbox ( will add here later ). Then I began a spreadsheet of the z positions. I do not really like spreadsheets because I find them very error prone and compared to programming a bit tedious. So I wrote a Python program. Initially I just set up a large number of variables and did the math. This was using Python as pretty much a general purpose calculator. Then I began to see a pattern in the calculations.

A Pattern

The pattern goes like this:

  • Each part has a bunch of values that effect z positions
    • Bottom of the part.
    • Thickness of the part.
    • Midpoint of the part.
    • Top of the part.
  • Clearly there are some simple relations between these values.
  • Parts are often stacked up. In the gear box:
    • Bottom plate
    • Washer
    • Spacer
    • Lower Gear
    • Upper Gear
    • Spacer
    • Washer
    • Upper Plate
  • Some calculations:
    • A part's bottom z position + part's thichness = part's top z position
    • One part's top z position becomes the next part's bottom z position.

Pattern into Python

Two classes have been found useful so far.

  • Part3D This is a set of z values, top, bottom.... , a name for the part, some simple calculations, and a print method to show the values. Easy way to set values and see them.
  • PartStack This is an list of parts ( Part3D ) to be stacked up in the z direction. It has a name, an order of parts, simple relations between the parts, and a nice way of printing the values.
  • Nothing very complicated, but have proved to be handy and not error prone.

Sample Calculation

import gear

print"""Set some standards
"""

washer_thick   = .1
gear_clear     = .5
gear_thick     = 5.
plate_thick    = 1.


a_stack    =  gear.PartStack( "two gears" )


l_plate  = gear.Part3D( "l_plate", plate_thick )
a_stack.add_up( l_plate )
a_stack.comp_z_top_mid()

l_washer = gear.Part3D( "l_washer", washer_thick )
a_stack.add_up( l_washer )
a_stack.comp_z_top_mid()


l_spacer = gear.Part3D( "l_spacer", 5.0 )
a_stack.add_up( l_spacer )
a_stack.comp_z_top_mid()


l_gear = gear.Part3D( "l_gear", gear_thick )
a_stack.add_up( l_gear )
l_gear.comp_z_top_mid()


u_gear = gear.Part3D( "u_gear", gear_thick + gear_clear )
a_stack.add_up( u_gear )
u_gear.comp_z_top_mid()


u_spacer = gear.Part3D( "u_spacer", 5. )
a_stack.add_up( u_spacer )
u_spacer.comp_z_top_mid()


u_washer = gear.Part3D( "l_washer", washer_thick )
a_stack.add_up( u_washer )
a_stack.comp_z_top_mid()


u_plate = gear.Part3D( "u_plate", 5. )
a_stack.add_up( u_plate )
u_plate.comp_z_top_mid()


print( "-----------------------" )

a_stack.print_stack()

Output

Set some standards

-----------------------

------------ Stack: two gears ------------
l_plate
     bot  = 0.0
     thick= 1.0
     mid  = 0.5
     top  = 1.0
l_washer
     bot  = 1.0
     thick= 0.1
     mid  = 1.05
     top  = 1.1
l_spacer
     bot  = 1.1
     thick= 5.0
     mid  = 3.6
     top  = 6.1
l_gear
     bot  = 6.1
     thick= 5.0
     mid  = 8.6
     top  = 11.1
u_gear
     bot  = 11.1
     thick= 5.5
     mid  = 13.85
     top  = 16.6
u_spacer
     bot  = 16.6
     thick= 5.0
     mid  = 19.1
     top  = 21.6
l_washer
     bot  = 21.6
     thick= 0.1
     mid  = 21.65
     top  = 21.7
u_plate
     bot  = 21.7
     thick= 5.0
     mid  = 24.2
     top  = 26.7