a37008333ae1207805cfa88ead7d60b11277d41e
[challenge-bot] / 3d-printables / wheel.scad
1 // challenge-bot
2 // GNU AGPLv3 (or later at your option)
3 // project available at these locations:
4 // https://gitorious.org/ozzloy/challenge-bot
5 // https://github.com/waynegramlich/challenge-bot
6
7 // use $fn = 20 while developing, 100 when about to print
8 // 20 will make previews fast
9 // 100 will make printing smooth
10 $fn = 100;
11
12 include <wheel-dimensions.scad>
13 use <qr.scad>
14
15 module mounting_screw_flat() {
16 circle(0.9); }
17
18 module motor_shaft_flat(radius, flat_width) {
19 intersection() {
20 circle(radius);
21 square([flat_width, radius * 2], center = true); } }
22
23 module motor_shaft(radius,
24 flat_width,
25 shaft_length) {
26 linear_extrude(height = shaft_length) {
27 motor_shaft_flat(radius, flat_width); } }
28
29 module rim(radius, wall_width, wheel_width) {
30 linear_extrude(height = wheel_width) {
31 difference() {
32 circle(radius);
33 circle(radius - wall_width); } } }
34
35 module motor_shaft_holder_flat(radius, flat_width, wall_width) {
36 difference() {
37 motor_shaft_flat(radius + wall_width,
38 flat_width + wall_width);
39 motor_shaft_flat(radius, flat_width); } }
40
41 module motor_shaft_holder(radius, flat_width, wall_width, height) {
42 linear_extrude(height = height) {
43 motor_shaft_holder_flat(radius, flat_width, wall_width); } }
44
45 module tread(wheel_radius, tread_radius) {
46 rotate_extrude(convexity = 10) {
47 translate([wheel_radius, 0]) {
48 circle(tread_radius); } } }
49
50 module wheel_black(radius,
51 width,
52 shaft_radius,
53 shaft_flat_width,
54 wall_width,
55 tread_radius) {
56 color("black") {
57 difference() {
58 rim(radius, wall_width, width);
59 translate([0, 0, width / 2]) {
60 tread(radius, tread_radius); } }
61 linear_extrude(height = qr_height) {
62 difference() {
63 qr_black_flat();
64 mounting_screw_flat(); } }
65 translate([0, 0, qr_height]) {
66 motor_shaft_holder(shaft_radius,
67 shaft_flat_width,
68 wall_width,
69 width - qr_height); } } }
70
71 module wheel_white() {
72 color("white") {
73 linear_extrude(height = qr_height) {
74 difference() {
75 qr_white_flat();
76 mounting_screw_flat(); } } } }
77
78 module wheel(radius,
79 width,
80 shaft_radius,
81 shaft_flat_width,
82 wall_width,
83 tread_radius) {
84 wheel_black(radius,
85 width,
86 shaft_radius,
87 shaft_flat_width,
88 wall_width,
89 tread_radius);
90 wheel_white(); }
91
92 module wheel_solid(radius,
93 width,
94 shaft_radius,
95 shaft_flat_width,
96 wall_width,
97 tread_radius) {
98 difference() {
99 rim(radius, wall_width * 2, width);
100 translate([0, 0, width / 2]) {
101 tread(radius, tread_radius); } }
102 linear_extrude(height = qr_height) {
103 difference() {
104 square(qr_size, center = true);
105 mounting_screw_flat(); } }
106 translate([0, 0, qr_height]) {
107 motor_shaft_holder(shaft_radius,
108 shaft_flat_width,
109 wall_width,
110 width - qr_height); } }
111
112 /*
113 wheel(wheel_radius,
114 wheel_width,
115 motor_shaft_radius,
116 motor_shaft_flat_width,
117 wall_width,
118 tread_radius);
119 */
120
121 wheel_solid(wheel_radius,
122 wheel_width,
123 motor_shaft_radius,
124 motor_shaft_flat_width,
125 wall_width,
126 tread_radius);