Updated 2017/10/03 to work in Customizer.
This OpenSCAD script makes many different types of pulleys for just about any sort of timing belt. This latest version adds support for shafts that have a flat, for multiple nut sizes based on the shaft diameter, adjustable flanges, and for making pulley sets, where the second one is based on a ratio of teeth from the first one. The prior version added support for any number of setscrews and allowed them to be at an angle. The original (By Erik de Bruijn) supported threaded shafts with a recess for a nut to hold the pulley in place, or an even number of set screws printed in a hub with a (capped) teardrop hole. The original works well with the Synchroflex(R) timing belt,1500Lx10Wmm from RS (order code 474-5892), spliced in half (to 5 mm width). Code from DJ Delore adds support for trapezoidal teeth and moves the flange to the bottom if there is only one.
Updated 2017/10/03 to work in Customizer. Just hit the "Open in Customizer' button and customize away. The parameters are as listed below, and if you download the script, these notes may help.
Render with F6, as F5 doesn't always work correctly with this script. If rendering is very slow, change $fs to 1 and $fa to 12; at least while working. Change the parameters for your belt, and for your pulleys. The samples supplied include a small pulley for a stepper motor with a flat on it's shaft, a large pulley with a 4:1 ratio of teeth to the first one and a large hub with 3 setscrews at a slight angle, and another small one with a nut recess for a threaded rod.
toothType // 1 = slightly rounded, 2 = oval sharp, 3 = square, 4 = trapezoidal. For square, set the toothWidth a little low.
$fs=0.2; // defaults 1, 0.2 is high res
$fa=3; //defaults 12, 3 is very nice
//NOTE: If rendering is very slow, change $fs to 1 and $fa to 12; at least while working.
PULLEY SPECIFIC PARAMETERS:
pitch // distance between the teeth
beltWidth // the width/height of the belt. The (vertical) size of the pulley is adapted to this.
beltThickness // thickness of the part excluding the notch depth!
notchDepth // make slightly bigger than actual, to avoid outward curvature in the inner solid part of the pulley
toothWidth // Width of the teeth on the pulley. Usually a bit less than half the pitch
numTeeth // this value together with the pitch determines the pulley diameter
flanges // the rims that keep the belt from going anywhere, 0, 1, or 2
flangeHeight // how much the flanges angle in toward the inner diameter of the pulley.
shaftDiameter // the shaft at the center, will be subtracted from the pulley. Better be too small than too wide.
// If there is no flat, and no setscrew, we assume the shaft is threaded and a recess for a nut is added.
// The nut size is selected automatically based on the shaft size, and reported in the compile log.
shaftFlatDiameter // the diameter of the shaft when measured at a flat milled in the shaft. 0 if the shaft is round.
hubDiameter // if the hub or timing pulley is big enough to fit a nut, this will be embedded.
hubHeight // the hub is connected to the pulley to allow a set screw to go through or as a collar for a nut.
hubSetScrewDiameter// use either a set screw or nut on a shaft. Set to 0 to not use a set screw.
hubSetScrewAngle // change from 90 to angle the setscrews
hubSetScrews // 1 is usually fine, 3 allows centering