by mentlergy 3 years, 2 months ago
22 times 1.14s avg. build time

Codewheel

Codewheel for a quadrature encoder

License: CreativeCommons-ShareAlike Publicly Listed: True Tags: wheel,quadrature,code

Log in to download models or make your own copy!

Auto Apply Changes

  1. #
  2. # Important MetaData
  3. #
  4. UOM = "mm"
  5. VERSION = "2.0"
  6. AUTHOR = "Dave Cowden"
  7. #
  8. # PARAMETERS and PRESETS
  9. # These parameters can be manipulated by end users
  10. #
  11. d_inside = FloatParam(min=0,max=300.0,presets={'default':20.0 },group="Basics", desc="The diameter of the centerhole.")
  12. d_outside = FloatParam(min=10.0,max=1000.0,presets={'default':100.0,'short':10.0},group="Basics", desc="The diameter of the encoder.")
  13. thickness = FloatParam(min=0.01,max=10.0,presets={'default':1.0},group="Basics", desc="Thickness of the encoder.")
  14. margin = FloatParam(min=0,max=30.0,presets={'default':5.0},group="Basics", desc="Margin")
  15. h_slot = FloatParam(min=1,max=30.0,presets={'default':10.0},group="Basics", desc="Heigh of slots.")
  16. slots = IntegerParam(min=4,max=1024,presets={'default':64},group="Basics", desc="Number of slots.")
  17. #
  18. # Other Variables.
  19. # These are used in the script but not exposed to users to change with the GUI
  20. #
  21. # Your build method. It must return a solid object
  22. #
  23. def build():
  24. a = (2*math.pi)/(2*slots.value)
  25. r_f = d_outside.value/2-margin.value;
  26. r_l = d_outside.value/2-margin.value-h_slot.value;
  27. r = Workplane("front").circle(d_outside.value/2).circle(d_inside.value/2)
  28. for i in range(0,2*slots.value-1,2):
  29. r.polyline([(math.cos(a*i)*r_f,math.sin(a*i)*r_f) ,\
  30. (math.cos(a*(i+1))*r_f,math.sin(a*(i+1))*r_f),\
  31. (math.cos(a*(i+1))*r_l,math.sin(a*(i+1))*r_l) ,\
  32. (math.cos(a*i)*r_l,math.sin(a*i)*r_l) ,\
  33. (math.cos(a*i)*r_f,math.sin(a*i)*r_f)])
  34. return r.extrude(thickness.value)