1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-03 20:32:35 +02:00

Compare commits

...

145 Commits

Author SHA1 Message Date
Chris Palmer
35ffbad74c Drag chain ends now pp3_colour and explode. 2020-11-22 12:47:30 +00:00
Chris Palmer
fb685a0f42 Fixed missing screw default for ribbon_clamp_assembly(). 2020-11-22 12:04:55 +00:00
Chris Palmer
5d42b2e1ab Merge branch 'martinbudden-camera_no_lens' 2020-11-21 20:55:25 +00:00
Chris Palmer
2fe815d1bd Updated readme 2020-11-21 20:54:38 +00:00
Martin Budden
5c577cccd0 Added facility to display camera without lens. 2020-11-21 20:45:39 +00:00
Chris Palmer
1dbfafd366 Merge branch 'martinbudden-conditional_flip' 2020-11-20 12:13:44 +00:00
Chris Palmer
68b3dfb098 Updated readme. 2020-11-20 12:13:26 +00:00
Martin Budden
25dceee20a Made hflip and vflip conditional. 2020-11-20 08:46:17 +00:00
Chris Palmer
d70ddf5359 Type in drag chain blurb, fixes #100 2020-11-19 19:41:59 +00:00
Chris Palmer
70b60522ce Added drag_chain to the cover picture. 2020-11-18 16:25:45 +00:00
Chris Palmer
ecba7eaea4 Merge branch 'martinbudden-square_blower' 2020-11-18 11:31:57 +00:00
Chris Palmer
f751dd9a73 Tweaks to make interface consistent with blowers.
Added blower_exit_offset().
Fixed corner shape and exit dimensions.
Updated images and readme.
2020-11-18 11:31:40 +00:00
Chris Palmer
3f359f6839 Merge branch 'square_blower' of https://github.com/martinbudden/NopSCADlib into martinbudden-square_blower 2020-11-17 16:41:34 +00:00
Chris Palmer
3e5947c161 Added another size of ribbon clamp 2020-11-17 16:23:12 +00:00
Chris
66dc430541 Merge pull request #92 from martinbudden/belt_gap
Allow user to set y size of belt gap.
2020-11-17 16:18:44 +00:00
Chris Palmer
4dc83d62cb Finished end links. 2020-11-17 16:14:25 +00:00
Martin Budden
ebbec3c903 Allow user to set y size of belt gap. 2020-11-16 07:36:34 +00:00
Chris Palmer
9944aab73e Merge branch 'master' into drag 2020-11-15 17:49:30 +00:00
Chris Palmer
eb9bcf0ada Fixed recent bug in plateup when no platters / panels. 2020-11-15 16:29:50 +00:00
Chris Palmer
ff5e8c0372 Added ends 2020-11-15 16:28:24 +00:00
Martin Budden
17ebf36e27 Initial commit of square blower. 2020-11-15 08:16:22 +00:00
Chris Palmer
e38d9abfa0 Merge branch 'master' into drag 2020-11-14 17:46:29 +00:00
Chris Palmer
fc7fd5482e Corrected core XY comment. 2020-11-14 17:40:20 +00:00
Chris Palmer
cee1202fd9 Merge branch 'martinbudden-belt_test_corexy' 2020-11-14 17:20:18 +00:00
Chris Palmer
6e342441c6 Added images and readme. 2020-11-14 17:19:18 +00:00
Chris Palmer
072c38f955 Enabled the two belt version. 2020-11-14 17:18:08 +00:00
Chris Palmer
b342549d74 Merge branch 'belt_test_corexy' of https://github.com/martinbudden/NopSCADlib into martinbudden-belt_test_corexy 2020-11-14 17:00:11 +00:00
Chris Palmer
2b83a15e5d Merge branch 'martinbudden-BTT_TFT35v3' 2020-11-14 14:44:01 +00:00
Chris Palmer
ab81c6538c Updated images and readme. 2020-11-14 14:41:27 +00:00
Chris Palmer
27b0a442e4 Changed the order to avoid a clash with fans. 2020-11-14 14:32:23 +00:00
Chris Palmer
38acef9e27 Needs end pieces 2020-11-14 14:27:22 +00:00
Martin Budden
5415beb80d Added BigTreeTech TFT35 v 3.0 display. 2020-11-14 14:13:53 +00:00
Martin Budden
040985c0db Converted belts test to coreXY. 2020-11-14 09:40:37 +00:00
Chris Palmer
0216093a68 Added printed camera housings. 2020-11-13 22:43:55 +00:00
Chris
30302431c0 Merge pull request #94 from martinbudden/carbon_tube_fix
Fix to centering of carbon fiber tubing.
2020-11-13 19:35:14 +00:00
Chris Palmer
1fb429e9a5 Merge branch 'martinbudden-shaft_couplings' 2020-11-13 19:32:03 +00:00
Chris Palmer
9571e68629 Updated lib.scad, images and readme. 2020-11-13 19:31:49 +00:00
Chris Palmer
b01e6a673c type[0] should be the name of the constant. 2020-11-13 19:30:46 +00:00
Martin Budden
9239c6da3c Fix to centering of carbon fiber tubing. 2020-11-13 19:27:02 +00:00
Chris Palmer
ba5e5fa390 Used tube.scad to shorten code. 2020-11-13 18:55:26 +00:00
Chris Palmer
c7dfdd0fb9 Merge branch 'shaft_couplings' of https://github.com/martinbudden/NopSCADlib into martinbudden-shaft_couplings 2020-11-13 18:11:29 +00:00
Chris Palmer
814ce4f15d Merge branch 'martinbudden-bowden_connector' 2020-11-13 17:59:17 +00:00
Chris Palmer
f661cf6934 Updated images and readme 2020-11-13 17:57:13 +00:00
Chris Palmer
305d2146f2 Colours passed to thread need to be numeric, not strings. 2020-11-13 17:51:30 +00:00
Chris Palmer
e39ee1797d Merge branch 'bowden_connector' of https://github.com/martinbudden/NopSCADlib into martinbudden-bowden_connector 2020-11-13 17:45:47 +00:00
Chris Palmer
520569cb30 Made small idler pulley 6.5mm by default and added a 7mm one. 2020-11-13 13:55:15 +00:00
Chris Palmer
f73a7b46a2 Merge branch 'martinbudden-carbon_fiber_tube' 2020-11-13 10:51:24 +00:00
Chris Palmer
fb9eca85c6 Updated images and readme. 2020-11-13 10:50:29 +00:00
Martin Budden
166ed05d4a Add optional bowden connector to E3D hotends. 2020-11-13 10:21:38 +00:00
Chris Palmer
ce6aec428d Merge branch 'carbon_fiber_tube' of https://github.com/martinbudden/NopSCADlib into martinbudden-carbon_fiber_tube 2020-11-13 10:03:15 +00:00
Chris Palmer
4e9d169c31 Updated cover pic 2020-11-13 09:57:17 +00:00
Martin Budden
1810160103 Added carbon fiber tubing with woven pattern. 2020-11-13 09:35:56 +00:00
Chris Palmer
0c9ae8d60c PCBs now drawn before components so that transparent LEDs draw correctly. 2020-11-13 09:24:15 +00:00
Chris Palmer
9a0bad4e61 Made stepper motor encap paramatric.
Made connector position based on encap height and added PCB.
2020-11-12 23:36:35 +00:00
Chris Palmer
90047815b0 Added JST PH connectors.
Made jst_xh_header() more parametric and corrected pin positions.
2020-11-12 23:34:59 +00:00
Martin Budden
b583202fb7 Added hole for grub screw to shaft coupling. 2020-11-10 14:49:11 +00:00
Chris Palmer
eac0086199 tests.py now allows parts of projects to be tested without finding an implementation. 2020-11-10 12:01:57 +00:00
Martin Budden
03beaec470 Initial submission of shaft couplings vitamin. 2020-11-10 09:11:30 +00:00
Chris Palmer
51c649cc53 Merge branch 'martinbudden-tests_script' 2020-11-09 16:19:45 +00:00
Chris Palmer
5fa33d7c4d Tests.py now works in projects and makes tests.md and tests.html.
NopSCADlib blurb now scraped from libtest.scad.
libtest.scad no longer required and lack of it is used to detect a project.
2020-11-09 16:17:02 +00:00
Chris Palmer
78ce51d045 Merge branch 'tests_script' of https://github.com/martinbudden/NopSCADlib into martinbudden-tests_script 2020-11-08 21:36:56 +00:00
Chris Palmer
23cbadf6df Merge branch 'martinbudden-stepper_motor_jst_connector' 2020-11-08 21:29:03 +00:00
Chris Palmer
c9c2ffafba Fixed connector position, fixed missing wires, updated images.
Reverted the jst header pin position change.
2020-11-08 21:28:08 +00:00
Martin Budden
2e0e833d40 Made jst_connector a parameter to NEMA. 2020-11-08 15:14:19 +00:00
Martin Budden
6c51f8726c Updated tests.py to better support generic testing. 2020-11-08 14:56:52 +00:00
Martin Budden
0b035dbd15 Added optional jst connector to stepper motors. 2020-11-08 12:20:15 +00:00
Chris Palmer
34b58e3b64 Added convexity parameter to sweep. 2020-11-04 22:27:31 +00:00
Chris Palmer
df43fe7dc6 Added list and string slicing. 2020-11-04 21:44:07 +00:00
Chris Palmer
b5fe03fcb2 Test image pixel differences due to switch to winter computer 2020-11-04 20:48:22 +00:00
Chris Palmer
1658f6f0b4 Sweep can now cope with the start having colinear points. 2020-11-04 19:56:51 +00:00
Chris Palmer
7b126f9792 More spelling 2020-11-04 19:50:35 +00:00
Chris Palmer
479207fd4f Spelling 2020-11-04 10:52:57 +00:00
Chris Palmer
3ee55981f9 Comment spelling. 2020-10-05 12:02:54 +01:00
Chris Palmer
8c2b4a20fe Added tesrdrop_minus() and horicylinder(). 2020-10-05 10:59:50 +01:00
Chris Palmer
1529759406 Fixes for lazy union. 2020-10-05 10:42:13 +01:00
Chris Palmer
c4a986aa21 Test for circle_intersect() 2020-10-05 10:41:27 +01:00
Chris Palmer
ebee729d08 Added MP1584EN PCB. Melzi no longer displayed. 2020-10-05 10:40:43 +01:00
Chris Palmer
90e7f1a315 Added circle_intersect() calculation to maths.scad. 2020-10-04 22:01:08 +01:00
Chris Palmer
e39af154bb Fixed use of intersection with conditional argument to suit new OpenSCAD behaviour. 2020-10-03 15:53:41 +01:00
Chris Palmer
933fea687c Removed debug code 2020-09-20 09:07:01 +01:00
Chris Palmer
a7803b1efb Improved numerical accuarcy of catenary calculations. 2020-09-19 23:52:57 +01:00
Chris Palmer
1255e71271 Added catenary curves. 2020-09-19 12:11:54 +01:00
Chris Palmer
b11c5914b3 Added hyperbolic maths functions 2020-09-15 20:58:39 +01:00
Chris Palmer
ac60057801 Fixes for additional warnings in OpenSCAD 2020.09.12.ci5914 2020-09-14 22:54:55 +01:00
Chris Palmer
332933a4fd Made ribbon_clamps parametric on screw size. 2020-09-11 19:53:14 +01:00
Chris Palmer
6b0132c32e Added chamfer option to poly_cylinder(). 2020-09-11 12:36:37 +01:00
Chris Palmer
afac5f9737 Added PCB components to OpenGrab and functions to access PCB. 2020-09-11 12:35:22 +01:00
Chris Palmer
8d8df3cb8a Added 4.5mm button to PCBs. 2020-09-11 12:30:00 +01:00
Chris Palmer
81eb183db9 Fixed PCB cutout for right angle pin headers. 2020-09-11 12:24:07 +01:00
Chris Palmer
c99ed98a64 Can now have right angle pin headers on PCBs.
Fixed bugs right angle pin headers with rows not equal to two.
Added more tests for pin headers.
2020-09-11 00:20:28 +01:00
Chris Palmer
7f65e5d539 Added M2 dome head screws. 2020-09-10 18:38:24 +01:00
Chris Palmer
ffb7f87cc5 Fixed typo in insert name. 2020-09-10 18:27:56 +01:00
Chris Palmer
d0513c7299 Bodge to jhead to allow the ziptie and sleaving to be removed by setting naked to undef. 2020-09-06 12:33:44 +01:00
Chris Palmer
d1429a3b7d Verboard can now have components on the underside, same as PCBs. 2020-09-06 12:32:42 +01:00
Chris Palmer
70513993bd Can now put wire links on PCBs 2020-09-06 12:31:41 +01:00
Chris Palmer
9eb35accfd Updated fan_guard picture. 2020-09-06 11:59:32 +01:00
Chris Palmer
7276f18566 Spacing 2020-09-06 11:56:55 +01:00
Chris Palmer
d944198dc4 25mm fans are actually 25.4, i.e. 1". 2020-09-06 11:55:58 +01:00
Chris Palmer
04f2499a9e Moved no_point(str) from belt.scad to global.scad 2020-09-06 11:51:33 +01:00
Chris Palmer
1eb8b378e9 Added magnets 2020-08-23 16:46:29 +01:00
Chris Palmer
362dbdb4fc Opengrab hole position children now passed diameter. 2020-08-22 14:32:23 +01:00
Chris Palmer
57d223d84b Added insert_nose_length() 2020-08-22 14:31:06 +01:00
Chris Palmer
699385342f quadrant can now have different height and width if passed a vector. 2020-08-22 14:27:01 +01:00
Chris Palmer
547a418cea Hanging hole now works when the hole has only four sides. 2020-08-22 13:52:25 +01:00
Chris Palmer
b6d25048bc Fixed belt gap positioning and added ability to rotae it. 2020-08-22 11:16:56 +01:00
Chris Palmer
4cdab218d9 Fix belt positioning bug.
Belt gap position is now relative to the pitch line.
Added belt_pitch_to_back().
2020-08-22 09:45:13 +01:00
Chris Palmer
b6147e5684 Code formatting 2020-08-13 17:02:14 +01:00
Chris Palmer
966ba536ed Fixed J-Head nozzle offset.
Reduced J-Head inset.
Removed J-Head MK4.
2020-08-13 12:44:17 +01:00
Chris Palmer
2419d50641 Added more PTFE tube sizes and amde them whiter. 2020-08-13 12:30:39 +01:00
Chris Palmer
02211c2034 Added tubing_or() and center option. 2020-08-13 11:56:53 +01:00
Chris Palmer
77d73b075d Added opengrab_side_hole_positions() 2020-08-13 11:55:31 +01:00
Chris Palmer
cb54a3131b Added USB-C connector, micro hdmi and RPI4. 2020-08-01 19:38:22 +01:00
Chris Palmer
3cf275579c Fixed ball bearing chamfers. 2020-07-31 01:33:33 +01:00
Chris Palmer
fb41f218fe Added involute_gear_od() function. 2020-07-28 21:24:01 +01:00
Chris Palmer
e6a26bc7b1 Changed some teardrop holes to teardrop plus. 2020-07-20 20:39:01 +01:00
Chris Palmer
cb4fa40643 Reimplemented teardrop_plus() again. 2020-07-20 16:55:55 +01:00
Chris Palmer
6a26903514 Added blog links for horiholes. 2020-07-18 23:53:15 +01:00
Chris Palmer
d08d949887 Corrected teardrop_plus() shape to be an accurate compensation for slicer
staircasing and added a plus option to tearslot(), etc.

Added horiholes.scad to depict staircase holes.
2020-07-18 19:28:26 +01:00
Chris Palmer
574a73e527 More spelling 2020-07-14 23:39:36 +01:00
Chris Palmer
87a35126de Spelling. 2020-07-14 09:48:30 +01:00
Chris Palmer
1ca485b66b Added involute_worm_profile() and involute_rack_tooth_profile() functions. 2020-07-14 09:47:45 +01:00
Chris Palmer
bc919529d3 Tweaks to thread.
Better thread crest detection.
No longer shrtens thread by eps (to avoid z fight) if all one colour.
Comment about left hand threads.
2020-07-14 09:42:32 +01:00
Chris Palmer
9f4ed2b915 Fixed capitalisation of Swiss_clips.scad. 2020-07-12 00:27:26 +01:00
Chris Palmer
7ce055373a Add rack to mesh with involute spur gears. 2020-07-07 22:36:34 +01:00
Chris Palmer
71ac571346 Added a utility for making involute spur gears 2020-07-06 23:22:11 +01:00
Chris Palmer
e4d93366fa Added degrees, radians and rot2_z() to maths.scad. 2020-07-06 12:43:24 +01:00
Chris Palmer
f047ac27f7 Added SMR95 ball bearing 2020-07-04 17:30:26 +01:00
Chris Palmer
a9e479d971 Documented camera lens module. 2020-07-04 14:57:01 +01:00
Chris Palmer
47b01af1ea Added RPI camera V2
Add cameras to lib.scad
2020-07-04 14:54:19 +01:00
Chris Palmer
fe19eba237 Tweaked flat_flex connectors. 2020-07-04 14:14:25 +01:00
Chris Palmer
235f7b86e3 Camera connector position and size separated.
Camera_lens() module added.
2020-07-04 09:55:38 +01:00
Chris Palmer
92d7e18b16 Added pcb_size() function. 2020-07-04 09:53:09 +01:00
Chris Palmer
6a7226120f Fixed RPI camera component positions. 2020-06-30 18:57:14 +01:00
Chris Palmer
8aa00cd041 Added MGN12H rail and included MGN12 in the test. 2020-06-30 09:28:32 +01:00
Chris Palmer
f6b512da1f Added a couple of Raspberry Pi cameras. 2020-06-29 23:03:54 +01:00
Chris Palmer
c7ea0939b9 Made flat_flex parametric and changed default orientation. 2020-06-29 23:01:34 +01:00
Chris Palmer
265b5ab555 Fixed layout to work with an empty list. 2020-06-27 20:00:47 +01:00
Chris Palmer
186dbbfd08 Added SMT resistors and 0603 LED. 2020-06-27 19:59:49 +01:00
Chris Palmer
60659a43f8 Added light_strip_clip_wall(). 2020-06-24 16:42:17 +01:00
Chris Palmer
f412cb1736 Tweaked lightstrip dimensions. 2020-06-21 20:35:13 +01:00
Chris Palmer
2b878556fc Bug fix to platters.scad for last change. 2020-06-21 16:00:26 +01:00
Chris Palmer
1f1a360b7c Mods to allow panels and platters to be target specific or not. 2020-06-21 12:53:14 +01:00
Chris Palmer
a547c98995 Added shelf bracket to printed/box.scad. 2020-06-20 15:12:09 +01:00
Chris Palmer
d9fa8c8668 Added position children used for drilling holes on sheets. 2020-06-20 15:04:03 +01:00
Chris Palmer
bf5b6d7c30 Added matrix inversion 2020-06-20 15:01:01 +01:00
139 changed files with 3746 additions and 759 deletions

View File

@@ -18,7 +18,7 @@
//
//
// Include this file to use the miniumum library plus screws, nuts and washers
// Include this file to use the minimum library plus screws, nuts and washers
//
include <utils/core/core.scad>
//

View File

@@ -33,7 +33,7 @@ $exploded = is_undef($explode) ? 0 : $explode; // 1 f
layer_height = is_undef($layer_height) ? 0.25 : $layer_height; // layer heigth when printing
extrusion_width = is_undef($extrusion_width) ? 0.5 : $extrusion_width; // filament width when printing
nozzle = is_undef($nozzle) ? 0.45 : $nozzle; // 3D printer nozzle
cnc_bit_r = is_undef($cnc_bit_r) ? 1.2 : $cnc_bit_r; // miniumum tool radius when milling 2D objects
cnc_bit_r = is_undef($cnc_bit_r) ? 1.2 : $cnc_bit_r; // minimum tool radius when milling 2D objects
pp1_colour = is_undef($pp1_colour) ? [0, 146/255, 0] : $pp1_colour; // printed part colour 1, RepRap logo colour
pp2_colour = is_undef($pp2_colour) ? "red" : $pp2_colour; // printed part colour 2
pp3_colour = is_undef($pp3_colour) ? "blue" : $pp3_colour; // printed part colour 3

View File

@@ -29,6 +29,7 @@ include <vitamins/batteries.scad>
include <vitamins/blowers.scad>
include <vitamins/bulldogs.scad>
include <vitamins/buttons.scad>
include <vitamins/cameras.scad>
include <vitamins/components.scad>
include <vitamins/displays.scad>
include <vitamins/extrusions.scad>
@@ -42,6 +43,7 @@ include <vitamins/ldrs.scad>
include <vitamins/leadnuts.scad>
include <vitamins/led_meter.scad>
include <vitamins/light_strips.scad>
include <vitamins/magnets.scad>
include <vitamins/mains_sockets.scad>
include <vitamins/modules.scad>
include <vitamins/panel_meters.scad>
@@ -52,6 +54,7 @@ include <vitamins/ring_terminals.scad>
include <vitamins/rails.scad>
include <vitamins/rod.scad>
include <vitamins/scs_bearing_blocks.scad>
include <vitamins/shaft_couplings.scad>
include <vitamins/sheets.scad>
include <vitamins/sk_brackets.scad>
include <vitamins/spools.scad>
@@ -83,6 +86,7 @@ use <utils/rounded_cylinder.scad>
use <utils/dogbones.scad>
use <utils/tube.scad>
use <utils/quadrant.scad>
use <utils/gears.scad>
use <utils/hanging_hole.scad>
use <utils/fillet.scad>
use <utils/rounded_polygon.scad>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 KiB

After

Width:  |  Height:  |  Size: 848 KiB

View File

@@ -17,6 +17,23 @@
// If not, see <https://www.gnu.org/licenses/>.
//
//!# NopSCADlib
//! An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
//!
//! It contains lots of vitamins (the RepRap term for non-printed parts), some general purpose printed parts and some utilities.
//! There are also Python scripts to generate Bills of Materials (BOMs),
//! STL files for all the printed parts, DXF files for CNC routed parts in a project and a manual containing assembly
//! instructions and exploded views by scraping markdown embedded in OpenSCAD comments, [see scripts](scripts/readme.md).
//!
//! A simple example project can be found [here](examples/MainsBreakOutBox/readme.md).
//!
//! For more examples of what it can make see the [gallery](gallery/readme.md).
//!
//! The license is GNU General Public License v3.0, see [COPYING](COPYING).
//!
//! See [usage](docs/usage.md) for requirements, installation instructions and a usage guide.
//!
//! <img src="libtest.png" width="100%"/>
//
// This file shows all the parts in the library.
//
@@ -29,10 +46,13 @@ use <tests/blowers.scad>
use <tests/bulldogs.scad>
use <tests/buttons.scad>
use <tests/cable_strips.scad>
use <tests/cameras.scad>
use <tests/camera_housing.scad>
use <tests/circlips.scad>
use <tests/components.scad>
use <tests/d_connectors.scad>
use <tests/displays.scad>
use <tests/drag_chain.scad>
use <tests/extrusions.scad>
use <tests/extrusion_brackets.scad>
use <tests/fans.scad>
@@ -49,6 +69,7 @@ use <tests/LEDs.scad>
use <tests/light_strips.scad>
use <tests/linear_bearings.scad>
use <tests/LED_meters.scad>
use <tests/magnets.scad>
use <tests/microswitches.scad>
use <tests/modules.scad>
use <tests/nuts.scad>
@@ -66,13 +87,14 @@ use <tests/rod.scad>
use <tests/screws.scad>
use <tests/SCS_bearing_blocks.scad>
use <tests/sealing_strip.scad>
use <tests/shaft_couplings.scad>
use <tests/sheets.scad>
use <tests/SK_brackets.scad>
use <tests/spades.scad>
use <tests/springs.scad>
use <tests/SSRs.scad>
use <tests/stepper_motors.scad>
use <tests/swiss_clips.scad>
use <tests/Swiss_clips.scad>
use <tests/toggles.scad>
use <tests/transformers.scad>
use <tests/tubings.scad>
@@ -115,17 +137,17 @@ cable_grommets_y = 0;
translate([x5, cable_grommets_y])
cable_grommets();
translate([x5, cable_grommets_y + 50])
feet();
translate([x5 + 80, cable_grommets_y])
ribbon_clamps();
translate([x5, cable_grommets_y + 75])
translate([x5, cable_grommets_y + 60])
fixing_blocks();
translate([x5, cable_grommets_y + 100])
translate([x5, cable_grommets_y + 90])
corner_blocks();
translate([x5, cable_grommets_y + 150])
ribbon_clamps();
feet();
translate([x5 + 70, cable_grommets_y + 150])
screw_knobs();
@@ -270,8 +292,9 @@ translate([x1, leadnuts_y])
leds_y = 0;
carriers_y = leds_y + 40;
spades_y = carriers_y + 40;
buttons_y = spades_y + 40;
magnets_y = carriers_y + 40;
spades_y = magnets_y + 20;
buttons_y = spades_y + 20;
jacks_y = buttons_y + 40;
microswitches_y = jacks_y + 40;
rockers_y = microswitches_y + 40;
@@ -287,6 +310,9 @@ translate([x2 + 35, leds_y])
translate([x2 + 8, carriers_y])
carriers();
translate([x2, magnets_y])
magnets();
translate([x2 + 20, carriers_y])
led_meters();
@@ -334,9 +360,15 @@ translate([x3 + 70, veroboard_y + 30])
translate([x3 + 140, veroboard_y + 20])
pcb_mounts();
translate([x3 + 170, veroboard_y + 16])
cameras();
translate([x3, d_connectors_y])
d_connectors();
translate([x3 + 170, d_connectors_y - 10])
camera_housings();
translate([x3, iecs_y])
iecs();
@@ -381,13 +413,17 @@ sk_brackets_y = extrusion_brackets_y + 80;
kp_pillow_blocks_y = sk_brackets_y + 50;
scs_bearing_blocks_y = kp_pillow_blocks_y + 60;
translate([x4 + 150, belts_y + 58]) {
translate([x4 + 200, belts_y + 58]) {
belt_test();
translate([0, 60])
opengrab_test();
}
translate([x4 + 175, belts_y, -20])
drag_chains();
translate([x4, rails_y + 130])
rails();
@@ -403,6 +439,9 @@ translate([x4, sk_brackets_y])
translate([x4, extrusion_brackets_y])
extrusion_brackets();
translate([x4 + 120, extrusion_brackets_y])
shaft_couplings();
translate([x4, scs_bearing_blocks_y])
scs_bearing_blocks();

View File

@@ -31,29 +31,29 @@
//!
//! Normally the side sheets are the same type but they can be overridden individually as long as the substitute has the same thickness.
//
include <../utils/core/core.scad>
include <../core.scad>
use <../vitamins/sheet.scad>
use <../vitamins/screw.scad>
use <../vitamins/washer.scad>
use <../vitamins/insert.scad>
use <../utils/quadrant.scad>
use <../utils/round.scad>
bezel_clearance = 0.2;
sheet_end_clearance = 1;
sheet_slot_clearance = 0.2;
function box_screw(type) = type[0]; //! Screw type to be used at the corners
function box_wall(type) = type[1]; //! Wall thickness of 3D parts
function box_sheets(type) = type[2]; //! Sheet type used for the sides
function box_top_sheet(type) = type[3]; //! Sheet type for the top
function box_base_sheet(type)= type[4]; //! Sheet type for the bottom
function box_feet(type) = type[5]; //! True to enable feet on the bottom bezel
function box_width(type) = type[6]; //! Internal width
function box_depth(type) = type[7]; //! Internal depth
function box_height(type) = type[8]; //! Internal height
function box_screw(type) = type[0]; //! Screw type to be used at the corners
function box_shelf_screw(type) = type[1]; //! Screw type to hold a shelf
function box_wall(type) = type[2]; //! Wall thickness of 3D parts
function box_sheets(type) = type[3]; //! Sheet type used for the sides
function box_top_sheet(type) = type[4]; //! Sheet type for the top
function box_base_sheet(type) = type[5]; //! Sheet type for the bottom
function box_feet(type) = type[6]; //! True to enable feet on the bottom bezel
function box_width(type) = type[7]; //! Internal width
function box_depth(type) = type[8]; //! Internal depth
function box_height(type) = type[9]; //! Internal height
function box(screw, wall, sheets, top_sheet, base_sheet, size, feet = false) = //! Construct a property list for a box.
concat([screw, wall, sheets, top_sheet, base_sheet, feet], size);
function box(screw, wall, sheets, top_sheet, base_sheet, size, feet = false, shelf_screw = M3_dome_screw) = //! Construct a property list for a box.
concat([screw, shelf_screw, wall, sheets, top_sheet, base_sheet, feet], size);
function box_bezel_clearance(type) = bezel_clearance;
@@ -62,6 +62,7 @@ function box_profile_overlap(type) = 3 + sheet_end_clearance / 2;
function box_washer(type) = screw_washer(box_screw(type));
function box_insert(type) = screw_insert(box_screw(type));
function box_shelf_insert(type) = screw_insert(box_shelf_screw(type));
function box_hole_inset(type) = washer_radius(box_washer(type)) + 1;
function box_insert_r(type) = insert_hole_radius(box_insert(type));
@@ -90,23 +91,32 @@ function box_bezel_height(type, bottom) = //! Bezel height for top or bottom
grill_hole = 5;
grill_gap = 1.9;
module grill(width, height, r = 1000, poly = false, h = 0) { //! A staggered array of 5mm holes to make grills in sheets. Can be constrained to be circular. Set ```poly``` ```true``` for printing, ```false``` for milling.
function box_grill_hole_r() = grill_hole / 2;
module grill_hole_positions(width, height, r = 1000) {
nx = floor(width / (grill_hole + grill_gap));
xpitch = width / nx;
ny = floor(height / ((grill_hole + grill_gap) * cos(30)));
ypitch = height / ny;
for(y = [0 : ny - 1], x = [0 : nx - 1 - (y % 2)]) {
$x = -width / 2 + (x + 0.5 + (y % 2) / 2) * xpitch;
$y = -height / 2 + (y + 0.5) * ypitch;
if(sqrt(sqr($x) + sqr($y)) + grill_hole / 2 <= r)
translate([$x, $y])
children();
}
}
module grill(width, height, r = 1000, poly = false, h = 0) { //! A staggered array of 5mm holes to make grills in sheets. Can be constrained to be circular. Set ```poly``` ```true``` for printing, ```false``` for milling.
extrude_if(h)
for(y = [0 : ny - 1], x = [0 : nx - 1 - (y % 2)]) {
x = -width / 2 + (x + 0.5 + (y % 2) / 2) * xpitch;
y = -height / 2 + (y + 0.5) * ypitch;
if(sqrt(sqr(x) + sqr(y)) + grill_hole / 2 <= r)
translate([x, y])
if(poly)
poly_circle(r = grill_hole / 2);
else
circle(d = grill_hole);
}
if(poly)
grill_hole_positions(width, height, r)
poly_circle(r = grill_hole / 2);
else
grill_hole_positions(width, height, r)
circle(d = grill_hole);
}
module box_corner_profile_2D(type) { //! The 2D shape of the corner profile.
@@ -178,6 +188,15 @@ module box_corner_profile_section(type, section, sections) { //! Generates inter
}
}
module box_corner_profile_sections(type, section, sections) { //! Generate four copies of a corner profile section
stl("box_corner_profile");
offset = box_boss_r(type) + 1;
for(i = [0 : 3])
rotate(i * 90)
translate([offset, offset])
box_corner_profile_section(type, section, sections);
}
module box_corner_quadrants(type, width, depth)
for(corner = [0:3]) {
x = [-1,1,1,-1][corner];
@@ -261,10 +280,11 @@ dowel_length = 20;
dowel_wall = extrusion_width * 3;
dowel_h_wall = layer_height * 6;
module box_bezel_section(type, bottom, rows, cols, x, y) { //! Generates interlocking sections of the bezel to allow it to be bigger than the printer
w = (box_width(type) + 2 * box_outset(type)) / cols;
h = (box_depth(type) + 2 * box_outset(type)) / rows;
tw = box_width(type) + 2 * box_outset(type);
w = tw / cols;
th = box_depth(type) + 2 * box_outset(type);
h = th / rows;
bw = box_outset(type) - bezel_clearance / 2;
bw2 = box_outset(type) + box_inset(type);
@@ -339,7 +359,7 @@ module box_bezel_section(type, bottom, rows, cols, x, y) { //! Generates interlo
render() difference() {
union() {
clip(xmin = 0, xmax = w, ymin = 0, ymax = h)
translate([box_width(type) / 2 + box_outset(type) - x * w, box_depth(type) / 2 + box_outset(type) - y * h, box_profile_overlap(type)])
translate([tw / 2 - x * w, th / 2 - y * h, box_profile_overlap(type)])
box_bezel(type, bottom);
if(x < cols - 1 && y == 0)
@@ -399,7 +419,6 @@ module box_bezel_section(type, bottom, rows, cols, x, y) { //! Generates interlo
}
}
module box_screw_hole_positions(type)
for(x = [-1, 1], y = [-1, 1])
translate([x * (box_width(type) / 2 - box_hole_inset(type)), y * (box_depth(type) / 2 - box_hole_inset(type))])
@@ -442,6 +461,96 @@ module box_shelf_blank(type, sheet = false) { //! Generates a 2D template for a
}
}
module box_shelf_screw_positions(type, screw_positions, thickness = 0, wall = undef) { //! Place children at the shelf screw positions
w = is_undef(wall) ? box_wall(type) : wall;
insert = box_shelf_insert(type);
translate_z(-insert_boss_radius(insert, w))
for(p = screw_positions)
multmatrix(p)
translate_z(thickness)
children();
}
module box_shelf_bracket(type, screw_positions, wall = undef) { //! Generates a shelf bracket, the first optional child is a 2D cutout and the second 3D cutouts
stl("shelf_bracket");
w = is_undef(wall) ? box_wall(type) : wall;
insert = box_shelf_insert(type);
lip = 2 * insert_boss_radius(insert, w);
width = insert_length(insert) + w;
module shape()
difference() {
square([box_width(type), box_depth(type)], center = true);
offset(bezel_clearance / 2)
box_corner_quadrants(type, box_width(type), box_depth(type));
if($children)
hflip()
children();
}
module boss()
translate_z(-width + eps)
linear_extrude(width - 2 * eps)
hull() {
circle4n(r = lip / 2 - eps);
translate([-lip / 2, -lip / 2 + eps])
square([lip, eps]);
}
difference() {
union() {
linear_extrude(w)
difference() {
shape()
if($children)
children(0);
round(2) offset(-width)
shape()
if($children)
children(0);
}
linear_extrude(lip)
difference() {
shape()
if($children)
children(0);
offset(-w)
shape()
if($children)
children(0);
}
hflip()
box_shelf_screw_positions(type, screw_positions, 0, w)
boss();
}
if($children > 1)
hflip()
children(1);
hflip()
box_shelf_screw_positions(type, screw_positions, 0, w)
insert_hole(insert, counterbore = 1, horizontal = true);
}
}
module box_shelf_bracket_section(type, rows, cols, x, y) { //! Generates sections of the shelf bracket to allow it to be bigger than the printer
tw = box_width(type);
w = tw / cols;
th = box_depth(type);
h = th / rows;
clip(xmin = 0, xmax = w, ymin = 0, ymax = h)
translate([tw / 2 - x * w, th / 2 - y * h])
children();
}
module box_left_blank(type, sheet = false) { //! Generates a 2D template for the left sheet, ```sheet``` can be set to override the type
dxf("box_left");

View File

@@ -110,12 +110,9 @@ function fixing_block_positions(type) = let(
function side_holes(type) = [for(p = fixing_block_positions(type), q = fixing_block_holes(bbox_screw(type))) p * q];
module drill_holes(type, t)
for(list = [corner_holes(type), side_holes(type)], p = list)
let(q = t * p)
if(abs(transform([0, 0, 0], q).z) < eps)
multmatrix(q)
drill(screw_clearance_radius(bbox_screw(type)), 0);
module bbox_drill_holes(type, t)
position_children(concat(corner_holes(type), side_holes(type)), t)
drill(screw_clearance_radius(bbox_screw(type)), 0);
module bbox_base_blank(type) { //! 2D template for the base
dxf(str(bbox_name(type), "_base"));
@@ -123,7 +120,7 @@ module bbox_base_blank(type) { //! 2D template for the base
difference() {
sheet_2D(bbox_base_sheet(type), bbox_width(type), bbox_depth(type), 1);
drill_holes(type, translate(bbox_height(type) / 2));
bbox_drill_holes(type, translate(bbox_height(type) / 2));
}
}
@@ -136,7 +133,7 @@ module bbox_top_blank(type) { //! 2D template for the top
translate([0, t / 2])
sheet_2D(bbox_top_sheet(type), bbox_width(type) + 2 * t, bbox_depth(type) + t);
drill_holes(type, translate(-bbox_height(type) / 2));
bbox_drill_holes(type, translate(-bbox_height(type) / 2));
}
}
@@ -154,7 +151,7 @@ module bbox_left_blank(type, sheet = false) { //! 2D template for the left side
translate([-t / 2, -bb / 2])
sheet_2D(subst_sheet(type, sheet), bbox_depth(type) + t, bbox_height(type) + bb);
drill_holes(type, rotate([0, 90, 90]) * translate([bbox_width(type) / 2, 0]));
bbox_drill_holes(type, rotate([0, 90, 90]) * translate([bbox_width(type) / 2, 0]));
}
}
@@ -168,7 +165,7 @@ module bbox_right_blank(type, sheet = false) { //! 2D template for the right sid
translate([t / 2, -bb / 2])
sheet_2D(subst_sheet(type, sheet), bbox_depth(type) + t, bbox_height(type) + bb);
drill_holes(type, rotate([0, 90, 90]) * translate([-bbox_width(type) / 2, 0]));
bbox_drill_holes(type, rotate([0, 90, 90]) * translate([-bbox_width(type) / 2, 0]));
}
}
@@ -183,7 +180,7 @@ module bbox_front_blank(type, sheet = false, width = 0) { //! 2D template for th
translate([0, (bt - bb) / 2])
sheet_2D(subst_sheet(type, sheet), max(bbox_width(type) + 2 * t, width), bbox_height(type) + bb + bt);
drill_holes(type, rotate([-90, 0, 0]) * translate([0, bbox_depth(type) / 2]));
bbox_drill_holes(type, rotate([-90, 0, 0]) * translate([0, bbox_depth(type) / 2]));
}
}
@@ -197,7 +194,7 @@ module bbox_back_blank(type, sheet = false) { //! 2D template for the back
translate([0, -bb / 2])
sheet_2D(subst_sheet(type, sheet), bbox_width(type), bbox_height(type) + bb);
drill_holes(type, rotate([-90, 0, 0]) * translate([0, -bbox_depth(type) / 2]));
bbox_drill_holes(type, rotate([-90, 0, 0]) * translate([0, -bbox_depth(type) / 2]));
}
}

392
printed/camera_housing.scad Normal file
View File

@@ -0,0 +1,392 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Housings for PCB cameras.
//
include <../core.scad>
include <../vitamins/cameras.scad>
use <../vitamins/pcb.scad>
use <../vitamins/insert.scad>
wall = 1.75;
min_wall = 2 * extrusion_width;
clearance = 0.2;
connector_size = [23, 6, 2.65]; // Worst case size of flat flex connector
cam_back_clearance = round_to_layer(1.5); // Clearance for components on the back of the pcb
cam_back_overlap = 1; // How much the back overlaps the edge of the pcb
cam_back_wall = min_wall;
function cam_front_clearance(cam) = round_to_layer(camera_connector_size(cam).z + clearance);
function cam_back_size(cam) = let(
pcb = camera_pcb(cam),
pcb_size = pcb_size(pcb),
nut = screw_nut(pcb_screw(pcb)),
holes = [for(h = pcb_holes(pcb)) pcb_coord(pcb, h).x],
pitch = max(holes) - min(holes),
length = pitch + 2 * (nut_radius(nut) + min_wall),
width = pcb_size.y + (length - pcb_size.x) * cos(30)
) [length, width, wall + max(connector_size.z, cam_back_clearance + nut_trap_depth(nut))];
function cam_front_size(cam) = cam_back_size(cam) + [ //! Outside dimensions of the case
2 * (wall + clearance),
2 * (wall + clearance),
pcb_thickness(camera_pcb(cam)) + cam_front_clearance(cam) + wall
];
hinge_screw = M2_cap_screw;
hinge_nut = screw_nut(hinge_screw);
hinge_screw_length = 12;
hinge_r = nut_trap_radius(hinge_nut) + 3 * extrusion_width;
hinge_h = wall + nut_trap_depth(hinge_nut);
hinge_offset = hinge_r + 1;
bracket_screw = M3_dome_screw;
function cam_screw_length(cam) = let(
front = cam_front_size(cam),
screw = pcb_screw(camera_pcb(cam)),
nut = screw_nut(screw)
) screw_longer_than(front.z + washer_thickness(screw_washer(screw)) - nut_trap_depth(nut) + nut_thickness(nut, true));
function hinge_z(cam) = cam_screw_length(cam) - hinge_r;
module cam_holes(cam) {
pcb = camera_pcb(cam);
lens_y = camera_lens_offset(cam).y;
two_holes = !!len([for (h = pcb_holes(pcb)) if(abs(pcb_coord(pcb, h).y - lens_y) < 1) true]);
pcb_screw_positions(pcb) // screw holes
if($i > 1 || !two_holes)
children();
}
module rpi_camera_focus_ring_stl() { //! Focus ring the glue onto RPI lens
stl("rpi_camera_focus_ring");
rad = 15 / 2;
hole_r1 = 2.5 / 2;
hole_r2 = 5 / 2;
thickness = 3;
flutes = 8;
angle = 180 / flutes;
x = rad / (sin(angle / 2) + cos(angle / 2));
r = x * sin(angle / 2);
difference() {
linear_extrude(height = thickness, convexity = 5)
difference() {
union() {
circle(x);
for(i = [0 : flutes - 1])
rotate([0, 0, 2 * angle * i])
translate([x, 0])
circle(r);
}
for(i = [0 : flutes - 1])
rotate([0, 0, 2 * angle * i + angle])
translate([x, 0])
circle(r);
}
hull() {
poly_cylinder(r = hole_r1, h = 0.1, center = true);
translate([0, 0, thickness])
poly_cylinder(r = hole_r2, h = 0.1, center = true);
}
}
}
module camera_back(cam) { //! Make the STL for a camera case back
stl(str("camera_back_", cam[0]));
pcb = camera_pcb(cam);
back = cam_back_size(cam);
screw = pcb_screw(pcb);
nut = screw_nut(screw);
translate_z(back.z)
hflip()
difference() {
translate_z(back.z / 2)
cube(back, center = true);
translate([0, -cam_back_overlap])
cube([pcb_length(pcb) - 2 * cam_back_overlap, pcb_width(pcb), 2 * cam_back_clearance], center = true);
translate([0, -pcb_width(pcb) / 2])
cube([connector_size.x + 2 * clearance, 2 * connector_size.y + 1, 2 * round_to_layer(connector_size.z + clearance)], center = true);
translate_z(back.z)
cam_holes(cam)
hflip()
nut_trap(screw, nut, supported = true);
}
}
module camera_front(cam, hinge = 0) { //! Make the STL for a camera case front
stl(str("camera_front_", cam[0]));
front = cam_front_size(cam);
back = cam_back_size(cam);
pcb = camera_pcb(cam);
pcb_size = pcb_size(pcb);
lens_offset = camera_lens_offset(cam);
screw = pcb_screw(pcb);
shelf = front.z - back.z;
connector_slot = connector_size + 2 * [clearance, 0, layer_height];
rad = wall;
led_hole_r = 1;
led_clearance = [5, 2, 1 * 2];
res_clearance = [3.5, 2, 1 * 2];
conn_pos = camera_connector_pos(cam);
conn = camera_connector_size(cam);
sensor_length = conn_pos.y + conn.y / 2 - lens_offset.y + clearance;
module hinge_pos()
if(!is_undef(hinge))
rotate(hinge * 90)
translate([0, (hinge ? front.x * hinge : front.y) / 2 + hinge_offset, hinge_r])
children();
difference() {
union() {
hull()
for(x = [-1, 1], y = [-1, 1])
translate([x * (front.x / 2 - rad), y * (front.y / 2 - rad)])
hull() { // 3D truncated teardrop gives radiused edges without exceeding 45 degree overhang
translate_z(front.z - 1)
cylinder(r = rad, h = 1);
translate_z(rad)
sphere(rad);
cylinder(r = rad * (sqrt(2) - 1), h = eps);
}
hinge_pos()
hull() {
rotate([-90, 0, -90])
teardrop(r = hinge_r, h = hinge_h, center = false);
translate([0, -10, -hinge_r])
cube([hinge_h, eps, 2 * hinge_r]);
}
}
hinge_pos()
rotate([90, 0, 90])
teardrop_plus(r = screw_clearance_radius(hinge_screw), h = 100, center = true);
translate_z(front.z / 2 + shelf - layer_height) // recess for the back
cube([back.x + 2 * clearance, back.y + 2 * clearance, front.z], center = true);
translate_z(front.z / 2 + shelf - pcb_size.z) // recess for PCB
cube([pcb_size.x + 2 * clearance, pcb_size.y + 2 * clearance, front.z], center = true);
translate_z(shelf)
hflip() {
pcb_component_position(pcb, "smd_led") // clearance for LED
cube(led_clearance, center = true);
pcb_component_position(pcb, "smd_res") // clearance for resistor
cube(res_clearance, center = true);
}
translate([conn_pos.x, lens_offset.y + sensor_length / 2, shelf - pcb_size.z]) // clearance for sensor connector
cube([conn.x + 2 * clearance, sensor_length, 2 * cam_front_clearance(cam)], center = true);
translate([0, -front.y / 2, shelf + front.z / 2]) // slot for connector
cube([connector_slot.x, connector_slot.y, front.z], center = true);
translate_z(cam_back_clearance + layer_height)
cam_holes(cam)
rotate(90)
poly_cylinder(r = screw_clearance_radius(screw), h = 100, center = true);
translate_z(shelf - pcb_size.z)
hflip()
camera_lens(cam, clearance);
hflip()
pcb_component_position(pcb, "smd_led")
rotate(45)
poly_cylinder(r = led_hole_r, h = 100, center = true); // hole for led
}
}
function bracket_thickness(cam) = max(wall, min(3.5, hinge_z(cam) - hinge_r - 1));
module camera_bracket_screw_positions(cam) { //! Position children at the bracket screw positions
r = washer_radius(screw_washer(bracket_screw)) + 0.5;
wide = bracket_thickness(cam) == wall;
pitch = wide ? cam_front_size(cam).x / 2 - r : hinge_h + 1 + r;
for(side = [-1, 1])
translate([side * pitch, 0])
children();
}
module camera_bracket_position(cam) //! Position children at the bracket position
translate([0, cam_front_size(cam).y / 2 + hinge_offset])
children();
module camera_bracket(cam) { //! Make the STL for the camera bracket
stl(str("camera_bracket_", cam[0]));
t = bracket_thickness(cam);
z = hinge_z(cam);
translate([hinge_h / 2, 0])
difference() {
hull() {
translate_z(eps / 2)
cube([hinge_h, 2 * hinge_r, eps], center = true);
translate_z(z)
rotate([0, 90, 0])
cylinder(r = hinge_r, h = hinge_h, center = true);
}
translate([hinge_h / 2, 0, z])
rotate([90, 0, 90])
nut_trap(hinge_screw, screw_nut(hinge_screw), horizontal = true);
}
linear_extrude(t)
difference() {
hull()
camera_bracket_screw_positions(cam)
circle(washer_radius(screw_washer(bracket_screw)) + 0.5);
camera_bracket_screw_positions(cam)
poly_circle(screw_clearance_radius(bracket_screw));
}
}
module camera_assembly(cam, angle = 0) //! Camera case assembly
assembly(str("camera_", cam[0])) {
front = cam_front_size(cam);
screw = pcb_screw(camera_pcb(cam));
nut = screw_nut(screw);
screw_length = cam_screw_length(cam);
hinge_z = hinge_z(cam);
hinge_pos = [0, front.y / 2 + hinge_offset, -hinge_r];
camera_bracket_position(cam) {
nut = screw_nut(hinge_screw);
stl_colour(pp1_colour) render()
camera_bracket(cam);
translate([-hinge_h, 0, hinge_z(cam)])
rotate([-90, 0, 90]) {
vflip()
translate_z(2 * hinge_h - nut_trap_depth(nut))
nut(nut, true);
screw_and_washer(hinge_screw, screw_longer_than(2 * hinge_h));
}
}
translate_z(hinge_z(cam) + hinge_r)
translate(hinge_pos)
rotate([-angle, 0, 0])
translate(-hinge_pos) {
translate_z(cam_back_size(cam).z - front.z)
camera(cam);
stl_colour(pp1_colour) render()
translate_z(-front.z)
camera_back(cam);
cam_holes(cam) {
screw_and_washer(screw, screw_length);
translate_z(-front.z + nut_trap_depth(nut))
vflip()
nut(nut, true);
}
*translate(camera_lens_offset(cam))
translate_z(1.5)
stl_colour(pp1_colour) render()
rpi_camera_focus_ring_stl();
stl_colour(pp2_colour) render()
hflip()
camera_front(cam, 0);
}
}
module camera_fastened_assembly(cam, thickness, angle = 0) {
camera_assembly(cam, angle);
camera_bracket_position(cam)
camera_bracket_screw_positions(cam) {
nut = screw_nut(bracket_screw);
washer = screw_washer(bracket_screw);
t = bracket_thickness(cam);
screw_length = screw_longer_than(thickness + t + nut_thickness(nut, true) + 2 * washer_thickness(washer));
vflip()
translate_z(thickness)
screw_and_washer(bracket_screw, screw_length);
translate_z(t)
nut_and_washer(nut, true);
}
}
module camera_back_rpi_camera_stl() camera_back(rpi_camera);
module camera_back_rpi_camera_v1_stl() camera_back(rpi_camera_v1);
module camera_back_rpi_camera_v2_stl() camera_back(rpi_camera_v2);
module camera_front_rpi_camera_stl() camera_front(rpi_camera);
module camera_front_rpi_camera_v1_stl() camera_front(rpi_camera_v1);
module camera_front_rpi_camera_v2_stl() camera_front(rpi_camera_v2);
module camera_bracket_rpi_camera_stl() camera_bracket(rpi_camera);
module camera_bracket_rpi_camera_v1_stl() camera_bracket(rpi_camera_v1);
module camera_bracket_rpi_camera_v2_stl() camera_bracket(rpi_camera_v2);
module camera_rpi_camera_assembly() camera_assembly(rpi_camera);
module camera_rpi_camera_v1_assembly() camera_assembly(rpi_camera_v1);
module camera_rpi_camera_v2_assembly() camera_assembly(rpi_camera_v2);
module camera_housing(cam) {
front = cam_front_size(cam);
camera_front(cam, 0);
translate([front.x, 0])
camera_back(cam);
translate([-front.x / 2 - 2 - hinge_r, 0])
rotate(90)
camera_bracket(cam);
}
cam = rpi_camera_v2;
if($preview)
camera_fastened_assembly(cam, 3);
else
camera_housing(cam);

View File

@@ -74,7 +74,7 @@ module door_hinge(door_thickness) { //! Generates STL fo
square([1, thickness + door_thickness]);
}
translate([dia / 2, thickness + door_thickness / 2])
teardrop(r = screw_clearance_radius(pin_screw), h = 0);
teardrop_plus(r = screw_clearance_radius(pin_screw), h = 0);
}
linear_extrude(thickness)
difference() {
@@ -127,7 +127,7 @@ module door_hinge_stat_stl() { //! Generates the STL for the stationary part
square([dia, 1], center = true);
}
translate([0, dia / 2 + stat_clearance])
teardrop(r = screw_clearance_radius(pin_screw), h = 0);
teardrop_plus(r = screw_clearance_radius(pin_screw), h = 0);
}
}
}

286
printed/drag_chain.scad Normal file
View File

@@ -0,0 +1,286 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Parametric cable drag chain to limit the bend radius of a cable run.
//!
//! Each link has a maximum bend angle of 45&deg;, so the mininium radius is proportional to the link length.
//!
//! The travel property is how far it can move in each direction, i.e. half the maximum travel if the chain is mounted in the middle of the travel.
//
include <../core.scad>
use <../utils/horiholes.scad>
use <../utils/maths.scad>
function drag_chain_name(type) = type[0]; //! The name to allow more than one in a project
function drag_chain_size(type) = type[1]; //! The internal size and link length
function drag_chain_travel(type) = type[2]; //! X travel
function drag_chain_wall(type) = type[3]; //! Side wall thickness
function drag_chain_bwall(type) = type[4]; //! Bottom wall
function drag_chain_twall(type) = type[5]; //! Top wall
function drag_chain_screw(type) = type[6]; //! Mounting screw for the ends
function drag_chain_screw_lists(type) = type[7]; //! Two lists of four bools to say which screws positions are used
function drag_chain_radius(type) = //! The bend radius at the pivot centres
let(s = drag_chain_size(type))
s.x / 2 / sin(360 / 16);
function drag_chain_z(type) = //! Outside dimension of a 180 bend
let(os = drag_chain_outer_size(type), s = drag_chain_size(type))
2 * drag_chain_radius(type) + os.z;
function drag_chain(name, size, travel, wall = 1.6, bwall = 1.5, twall = 1.5, screw = M2_cap_screw, screw_lists = [[1,0,0,1],[1,0,0,1]]) = //! Constructor
[name, size, travel, wall, bwall, twall, screw, screw_lists];
clearance = 0.1;
function drag_chain_outer_size(type) = //! Link outer dimensions
let(s = drag_chain_size(type), z = s.z + drag_chain_bwall(type) + drag_chain_twall(type))
[s.x + z, s.y + 4 * drag_chain_wall(type) + 2 * clearance, z];
function screw_lug_radius(screw) = //! Radius if a screw lug
corrected_radius(screw_clearance_radius(screw)) + 3.1 * extrusion_width;
module screw_lug(screw, h = 0) //! Create a D shaped lug for a screw
extrude_if(h, center = false)
difference() {
r = screw_lug_radius(screw);
hull() {
circle4n(r);
translate([-r, -r])
square([2 * r, eps]);
}
poly_circle(screw_clearance_radius(screw));
}
function bool2int(b) = b ? 1 : 0;
module drag_chain_screw_positions(type, end) {//! Place children at the screw positions, end = 0 for the start, 1 for the end
r = screw_lug_radius(drag_chain_screw(type));
s = drag_chain_size(type);
os = drag_chain_outer_size(type);
R = os.z / 2;
x0 = end ? R + norm([drag_chain_cam_x(type), R - drag_chain_twall(type)]) + clearance + r : r;
x1 = end ? os.x - r : os.x - 2 * R - clearance - r;
for(i = [0 : 3]) {
x = i % 2;
y = bool2int(i > 1);
if(drag_chain_screw_lists(type)[bool2int(end)][i])
translate([(x0 + x1) / 2, 0])
mirror([x, 0])
mirror([0, y])
translate([(x1 - x0) / 2, s.y / 2 + r])
children();
}
}
function drag_chain_cam_x(type) = // how far the cam sticks out
let(s = drag_chain_size(type),
r = drag_chain_outer_size(type).z / 2,
wall = drag_chain_wall(type),
cam_r = s.x - 2 * clearance - wall - r, // inner_x_normal - clearance - r
twall = drag_chain_twall(type)
) min(sqrt(max(sqr(cam_r) - sqr(r - twall), 0)), r);
module drag_chain_link(type, start = false, end = false) { //! One link of the chain, special case for start and end
stl(str(drag_chain_name(type), "_drag_chain_link", start ? "_start" : end ? "_end" : ""));
s = drag_chain_size(type);
wall = drag_chain_wall(type);
bwall = drag_chain_bwall(type);
twall = drag_chain_twall(type);
os = drag_chain_outer_size(type);
r = os.z / 2;
pin_r = r / 2;
socket_x = r;
pin_x = socket_x + s.x;
outer_normal_x = pin_x - r - clearance; // s.x - clearance
outer_end_x = end ? os.x : outer_normal_x;
inner_x = start ? 0 : outer_normal_x - wall; // s.x - clearance - wall
roof_x_normal = 2 * r - twall;
roof_x = start ? 0 : roof_x_normal;
floor_x = start ? 0 : 2 * r;
cam_x = drag_chain_cam_x(type);
assert(r + norm([drag_chain_cam_x(type), r - drag_chain_twall(type)]) + clearance <= inner_x || start, "Link must be longer");
difference() {
union() {
for(side = [-1, 1])
rotate([90, 0, 0]) {
// Outer cheeks
translate_z(side * (os.y / 2 - wall / 2))
linear_extrude(wall, center = true)
difference() {
hull() {
if(start)
square([eps, os.z]);
else
translate([socket_x, r])
rotate(180)
teardrop(r = r, h = 0);
translate([outer_end_x - eps, 0])
square([eps, os.z]);
}
if(!start)
translate([socket_x, r])
horihole(pin_r, r);
}
// Inner cheeks
translate_z(side * (s.y / 2 + wall / 2))
linear_extrude(wall, center = true)
difference() {
union() {
hull() {
if(!end) {
translate([pin_x, r])
rotate(180)
teardrop(r = r, h = 0);
translate([pin_x, twall])
square([cam_x, eps]);
}
else
translate([os.x - eps, 0])
square([eps, os.z]);
translate([inner_x, 0])
square([eps, os.z]);
}
}
// Cutout for top wall
if(!end)
intersection() {
translate([pin_x - r, 0])
square([3 * r, twall]); // When straight
translate([pin_x, r])
rotate(-45)
translate([-r + roof_x_normal, -r - twall]) // When bent fully
square(os.z);
}
}
// Pin
if(!end)
translate([pin_x, r, side * (s.y / 2 + wall + clearance)])
horicylinder(r = pin_r, z = r, h = 2 * wall);
// Cheek joint
translate([inner_x, 0, side * (s.y / 2 + wall) - 0.5])
cube([outer_end_x - inner_x, os.z, 1]);
}
// Roof, actually the floor when printed
roof_end = end ? s.x + 2 * r : s.x + r - twall - clearance;
translate([roof_x, -s.y / 2 - 0.5])
cube([roof_end - roof_x , s.y + 1, twall]);
translate([roof_x, -os.y / 2 + 0.5])
cube([s.x - clearance - roof_x, os.y - 1, twall]);
// Floor, actually the roof when printed
floor_end = end ? s.x + 2 * r : s.x + r;
translate([floor_x, -s.y / 2 - wall, os.z - bwall])
cube([floor_end - floor_x, s.y + 2 * wall, bwall]);
translate([floor_x, -os.y / 2 + 0.5, os.z - bwall])
cube([s.x - floor_x - clearance, os.y -1, bwall]);
if(start || end)
drag_chain_screw_positions(type, end)
screw_lug(drag_chain_screw(type), os.z);
}
if(start || end)
translate_z(-eps)
drag_chain_screw_positions(type, end)
poly_cylinder(r = screw_clearance_radius(drag_chain_screw(type)), h = os.z + 2 * eps, center = false);
}
if(show_supports() && !end) {
for(side = [-1, 1]) {
w = 2.1 * extrusion_width;
translate([s.x + r + cam_x - w / 2, side * (s.y / 2 + wall / 2), twall / 2])
cube([w, wall, twall], center = true);
h = round_to_layer(r - pin_r / sqrt(2));
y = s.y / 2 + max(wall + w / 2 + clearance, 2 * wall + clearance - w / 2);
translate([s.x + r, side * y, h / 2])
cube([pin_r * sqrt(2), w, h], center = true);
gap = cam_x - pin_r / sqrt(2) + extrusion_width;
translate([s.x + r + cam_x - gap / 2, side * (s.y / 2 + wall + clearance / 2), layer_height / 2])
cube([gap, 2 * wall + clearance, layer_height], center = true);
}
}
}
//! 1. Remove the support material from the links with side cutters.
//! 1. Clip the links together with the special ones at the ends.
module drag_chain_assembly(type, pos = 0) { //! Drag chain assembly
s = drag_chain_size(type);
x = (1 + exploded()) * s.x;
r = drag_chain_radius(type) * x / s.x;
travel = drag_chain_travel(type);
links = ceil(travel / s.x);
actual_travel = links * s.x;
z = drag_chain_outer_size(type).z;
zb = z / 2; // z of bottom track
c = [actual_travel / 2 + pos / 2, 0, r + zb]; // centre of bend
points = [ // Calculate list of hinge points
for(i = 0, p = [0, 0, z / 2 + 2 * r]; i < links + 5;
i = i + 1,
dx = p.z > c.z ? x : -x,
p = max(p.x + dx, p.x) <= c.x ? p + [dx, 0, 0] // Straight sections
: let(q = circle_intersect(p, x, c, r))
q.x <= c.x ? [p.x - sqrt(sqr(x) - sqr(p.z - zb)), 0, zb] // Transition back to straight
: q) // Circular section
p
];
npoints = len(points);
module link(n) // Position and colour link with origin at the hinge hole
translate([-z / 2, 0, -z / 2])
stl_colour(n < 0 || n == npoints - 1 ? pp3_colour : n % 2 ? pp1_colour : pp2_colour)
drag_chain_link(type, start = n == -1, end = n == npoints - 1);
assembly(str(drag_chain_name(type), "_drag_chain")) {
for(i = [0 : npoints - 2]) let(v = points[i+1] - points[i])
translate(points[i])
rotate([0, -atan2(v.z, v.x), 0])
link(i);
translate(points[0] - [x, 0, 0])
link(-1);
translate(points[npoints - 1])
hflip()
link(npoints - 1);
}
}

View File

@@ -24,69 +24,72 @@ include <../core.scad>
use <../vitamins/insert.scad>
use <../vitamins/cable_strip.scad>
wall = 2;
wall = 1.6;
min_wall = 2 * extrusion_width;
screw = M3_cap_screw;
insert = screw_insert(screw);
screw_depth = insert_length(insert) + 1;
function ribbon_clamp_hole_pitch(ways) = ribbon_clamp_slot(ways) + 2 * min_wall + 2 * corrected_radius(insert_hole_radius(insert)); //! Hole pitch
function ribbon_clamp_width() = 2 * (insert_hole_radius(insert) + wall); //! Width
function ribbon_clamp_length(ways) = ribbon_clamp_hole_pitch(ways) + ribbon_clamp_width(); //! Length given ways
function ribbon_clamp_height() = screw_depth + 1; //! Height
function ribbon_clamp_screw_depth(screw = screw) = insert_length(screw_insert(screw)) + 1;
function ribbon_clamp_hole_pitch(ways, screw = screw) =
ribbon_clamp_slot(ways) + 2 * min_wall + 2 * corrected_radius(insert_hole_radius(screw_insert(screw))); //! Hole pitch
module ribbon_clamp_hole_positions(ways, side = undef) //! Place children at hole positions
function ribbon_clamp_width(screw = screw) = 2 * (insert_hole_radius(screw_insert(screw)) + wall); //! Width
function ribbon_clamp_length(ways, screw = screw) = ribbon_clamp_hole_pitch(ways, screw) + ribbon_clamp_width(screw); //! Length given ways
function ribbon_clamp_height(screw = screw) = ribbon_clamp_screw_depth(screw) + 1; //! Height
module ribbon_clamp_hole_positions(ways, screw = screw, side = undef) //! Place children at hole positions
for(x = is_undef(side) ? [-1, 1] : side)
translate([x * ribbon_clamp_hole_pitch(ways) / 2, 0])
translate([x * ribbon_clamp_hole_pitch(ways, screw) / 2, 0])
children();
module ribbon_clamp_holes(ways, h = 20) //! Drill screw holes
ribbon_clamp_hole_positions(ways)
module ribbon_clamp_holes(ways, h = 20, screw = screw) //! Drill screw holes
ribbon_clamp_hole_positions(ways, screw)
drill(screw_clearance_radius(screw), h);
module ribbon_clamp(ways) { //! Generate STL for given number of ways
stl(str("ribbon_clamp_", ways));
module ribbon_clamp(ways, screw = screw) { //! Generate STL for given number of ways
screw_d = screw_radius(screw) * 2;
stl(str("ribbon_clamp_", ways, screw_d != 3 ? str("_", screw_d) : ""));
pitch = ribbon_clamp_hole_pitch(ways);
d = ribbon_clamp_width();
h = ribbon_clamp_height();
t = h - ribbon_clamp_slot_depth() - wall;
pitch = ribbon_clamp_hole_pitch(ways, screw);
d = ribbon_clamp_width(screw);
h = ribbon_clamp_height(screw);
t = round_to_layer(ribbon_clamp_slot_depth() + wall);
insert = screw_insert(screw);
difference() {
union() {
hull() {
translate_z(h - t / 2)
cube([ribbon_clamp_hole_pitch(ways), d, t], center = true);
cube([ribbon_clamp_hole_pitch(ways, screw), d, t], center = true);
translate_z(1)
cube([pitch, max(wall, d - 2 * (h - t)), 2], center = true);
}
ribbon_clamp_hole_positions(ways, -1)
ribbon_clamp_hole_positions(ways, screw, -1)
cylinder(d = d, h = h);
ribbon_clamp_hole_positions(ways, 1)
ribbon_clamp_hole_positions(ways, screw, 1)
cylinder(d = d, h = h);
}
translate_z(h)
cube([ribbon_clamp_slot(ways), d + 1, ribbon_clamp_slot_depth() * 2], center = true);
ribbon_clamp_hole_positions(ways)
ribbon_clamp_hole_positions(ways, screw)
translate_z(h)
rotate(22.5)
insert_hole(insert, screw_depth - insert_length(insert));
insert_hole(insert, ribbon_clamp_screw_depth(screw) - insert_length(insert));
}
}
module ribbon_clamp_assembly(ways) pose([55, 180, 25]) //! Printed part with inserts in place
assembly(str("ribbon_clamp_", ways)) {
h = ribbon_clamp_height();
module ribbon_clamp_assembly(ways, screw = screw) pose([55, 180, 25]) //! Printed part with inserts in place
assembly(let(screw_d = screw_radius(screw) * 2)str("ribbon_clamp_", ways, screw_d != 3 ? str("_", screw_d) : "")) {
h = ribbon_clamp_height(screw);
insert = screw_insert(screw);
stl_colour(pp1_colour) render()
translate_z(h) vflip() ribbon_clamp(ways);
translate_z(h) vflip() ribbon_clamp(ways, screw);
ribbon_clamp_hole_positions(ways)
ribbon_clamp_hole_positions(ways, screw)
vflip()
insert(insert);
}
@@ -99,20 +102,28 @@ module ribbon_clamp_fastened_assembly(ways, thickness, screw = screw) { //! Clam
vitamin(str(": Tape self amalgamating silicone ",tape_l," x 25mm"));
washer = screw_washer(screw);
screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + screw_depth);
screw_length = screw_shorter_than(2 * washer_thickness(washer) + thickness + ribbon_clamp_screw_depth(screw));
ribbon_clamp_assembly(ways);
ribbon_clamp_assembly(ways, screw);
color("red") translate_z(tape_thickness / 2)
cube([tape_l, tape_width, tape_thickness], center = true);
ribbon_clamp_hole_positions(ways)
ribbon_clamp_hole_positions(ways, screw)
vflip()
translate_z(thickness)
screw_and_washer(screw, screw_length, true);
}
module ribbon_clamp_20_stl() ribbon_clamp(20);
module ribbon_clamp_8_2_stl() ribbon_clamp(8, M2_dome_screw);
module ribbon_clamp_7_2_stl() ribbon_clamp(8, M2_dome_screw);
//! * Place inserts into the holes and press home with a soldering iron with a conical bit heated to 200&deg;C.
module ribbon_clamp_20_assembly() ribbon_clamp_assembly(20);
//! * Place inserts into the holes and press home with a soldering iron with a conical bit heated to 200&deg;C.
module ribbon_clamp_8_2_assembly() ribbon_clamp_assembly(8, M2_dome_screw);
//! * Place inserts into the holes and press home with a soldering iron with a conical bit heated to 200&deg;C.
module ribbon_clamp_7_2_assembly() ribbon_clamp_assembly(8, M2_dome_screw);

648
readme.md

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,7 @@ import c14n_stl
from set_config import *
from deps import *
from shutil import copyfile
import re
source_dirs = { "stl" : "platters", "dxf" : "panels" }
target_dirs = { "stl" : "printed", "dxf" : "routed" }
@@ -38,61 +39,73 @@ def plateup(target, part_type, usage = None):
top_dir = set_config(target, usage)
parts_dir = top_dir + part_type + 's'
target_dir = parts_dir + '/' + target_dirs[part_type]
source_dir = top_dir + source_dirs[part_type]
deps_dir = source_dir + "/deps"
if not os.path.isdir(source_dir):
return
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
if not os.path.isdir(deps_dir):
os.makedirs(deps_dir)
source_dir1 = source_dirs[part_type]
source_dir2 = top_dir + source_dirs[part_type]
#
# Decide which files to make
#
sources = [file for file in os.listdir(source_dir) if file.endswith('.scad')]
#
# Run OpenSCAD on the source files to make the targets
# Loop through source directories
#
used = []
for src in sources:
src_file = source_dir + '/' + src
part_file = target_dir + '/' + src[:-4] + part_type
dname = deps_name(deps_dir, src)
changed = check_deps(part_file, dname)
if changed:
print(changed)
openscad.run("-D$bom=1", "-d", dname, "-o", part_file, src_file)
if part_type == 'stl':
c14n_stl.canonicalise(part_file)
log_name = 'openscad.log'
else:
log_name = 'openscad.echo'
openscad.run_silent("-D$bom=1", "-o", log_name, src_file)
all_sources = []
for dir in [source_dir1, source_dir2]:
if not os.path.isdir(dir):
continue
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
#
# Add the files on the BOM to the used list
# Make the deps dir
#
with open(log_name) as file:
for line in file.readlines():
if line.startswith('ECHO: "~') and line.endswith('.' + part_type + '"\n'):
used.append(line[8:-2])
#
# Copy file that are not included
#
deps_dir = dir + "/deps"
if not os.path.isdir(deps_dir):
os.makedirs(deps_dir)
#
# Decide which files to make
#
sources = [file for file in os.listdir(dir) if file.endswith('.scad')]
all_sources += sources
#
# Run OpenSCAD on the source files to make the targets
#
for src in sources:
src_file = dir + '/' + src
part_file = target_dir + '/' + src[:-4] + part_type
dname = deps_name(deps_dir, src)
changed = check_deps(part_file, dname)
if changed:
print(changed)
openscad.run("-D$bom=1", "-d", dname, "-o", part_file, src_file)
if part_type == 'stl':
c14n_stl.canonicalise(part_file)
log_name = 'openscad.log'
else:
log_name = 'openscad.echo'
openscad.run_silent("-D$bom=1", "-o", log_name, src_file)
#
# Add the files on the BOM to the used list
#
with open(log_name) as file:
for line in file.readlines():
match = re.match(r'^ECHO: "~(.*?\.' + part_type + r').*"$', line)
if match:
used.append(match.group(1))
copied = []
for file in os.listdir(parts_dir):
if file.endswith('.' + part_type) and not file in used:
src = parts_dir + '/' + file
dst = target_dir + '/' + file
if mtime(src) > mtime(dst):
print("Copying %s to %s" % (src, dst))
copyfile(src, dst)
copied.append(file)
#
# Remove any cruft
#
targets = [file[:-4] + part_type for file in sources]
for file in os.listdir(target_dir):
if file.endswith('.' + part_type):
if not file in targets and not file in copied:
print("Removing %s" % file)
os.remove(target_dir + '/' + file)
if all_sources:
#
# Copy files that are not included
#
for file in os.listdir(parts_dir):
if file.endswith('.' + part_type) and not file in used:
src = parts_dir + '/' + file
dst = target_dir + '/' + file
if mtime(src) > mtime(dst):
print("Copying %s to %s" % (src, dst))
copyfile(src, dst)
copied.append(file)
#
# Remove any cruft
#
targets = [file[:-4] + part_type for file in all_sources]
for file in os.listdir(target_dir):
if file.endswith('.' + part_type):
if not file in targets and not file in copied:
print("Removing %s" % file)
os.remove(target_dir + '/' + file)

View File

@@ -97,7 +97,6 @@ def tests(tests):
for dir in [deps_dir, png_dir, bom_dir]:
if not os.path.isdir(dir):
os.makedirs(dir)
doc_name = "readme.md"
index = {}
bodies = {}
done = []
@@ -108,19 +107,33 @@ def tests(tests):
#
png_name = "libtest.png"
scad_name = "libtest.scad"
if not os.path.isfile(png_name):
openscad.run(colour_scheme, "--projection=p", "--imgsize=%d,%d" % (w, h), "--camera=0,0,0,50,0,340,500", "--autocenter", "--viewall", "-o", png_name, scad_name);
do_cmd(["magick", png_name, "-trim", "-resize", "1280", "-bordercolor", background, "-border", "10", png_name])
if os.path.isfile(scad_name):
libtest = True
lib_blurb = scrape_blurb(scad_name)
if not os.path.isfile(png_name):
openscad.run(colour_scheme, "--projection=p", "--imgsize=%d,%d" % (w, h), "--camera=0,0,0,50,0,340,500", "--autocenter", "--viewall", "-o", png_name, scad_name);
do_cmd(["magick", png_name, "-trim", "-resize", "1280", "-bordercolor", background, "-border", "10", png_name])
else:
#
# Project tests so just a title
#
libtest = False
project = ' '.join(word[0].upper() + word[1:] for word in os.path.basename(os.getcwd()).split('_'))
lib_blurb = '#' + project + ' Tests\n'
doc_base_name = "readme" if libtest else "tests"
doc_name = doc_base_name + ".md"
#
# List of individual part files
#
scads = [i for i in sorted(os.listdir(scad_dir), key = lambda s: s.lower()) if i[-5:] == ".scad"]
scads = [i for i in sorted(os.listdir(scad_dir), key = lambda s: s.lower()) if i[-5:] == ".scad"]
types = []
for scad in scads:
base_name = scad[:-5]
if not tests or base_name in tests:
done.append(base_name)
print(base_name)
print('\n'+base_name)
cap_name = base_name[0].capitalize() + base_name[1:]
base_name = base_name.lower()
scad_name = scad_dir + '/' + scad
@@ -132,29 +145,42 @@ def tests(tests):
if is_plural(base_name) and os.path.isfile(vits_name):
objects_name = vits_name
locations = [
('vitamins/' + depluralise(base_name) + '.scad', 'Vitamins'),
('printed/' + base_name + '.scad', 'Printed'),
('utils/' + base_name + '.scad', 'Utilities'),
('utils/core/' + base_name + '.scad', 'Core Utilities'),
]
locations = []
if os.path.isdir('vitamins'):
locations.append(('vitamins/' + depluralise(base_name) + '.scad', 'Vitamins'))
if os.path.isdir('printed'):
locations.append(('printed/' + base_name + '.scad', 'Printed'))
if os.path.isdir('utils'):
locations.append(('utils/' + base_name + '.scad', 'Utilities'))
if libtest and os.path.isdir('utils/core'):
locations.append(('utils/core/' + base_name + '.scad', 'Core Utilities'))
for name, type in locations:
if os.path.isfile(name):
impl_name = name
break
else:
print("Can't find implementation!")
continue
if libtest:
print("Can't find implementation!")
continue
else:
type = 'Tests' # OK when testing part of a project
impl_name = None
vsplit = "AJR" + chr(ord('Z') + 1)
vtype = locations[0][1]
types = [vtype + ' ' + vsplit[i] + '-' + chr(ord(vsplit[i + 1]) - 1) for i in range(len(vsplit) - 1)] + [loc[1] for loc in locations[1 :]]
if type == vtype:
for i in range(1, len(vsplit)):
if cap_name[0] < vsplit[i]:
type = types[i - 1]
break
if libtest:
vsplit = "AJR" + chr(ord('Z') + 1)
vtype = locations[0][1]
types = [vtype + ' ' + vsplit[i] + '-' + chr(ord(vsplit[i + 1]) - 1) for i in range(len(vsplit) - 1)] + [loc[1] for loc in locations[1 :]]
if type == vtype:
for i in range(1, len(vsplit)):
if cap_name[0] < vsplit[i]:
type = types[i - 1]
break
else:
if not types:
types = [loc[1] for loc in locations] # No need to split up the vitamin list
if not type in types: # Will happen when implementation is not found and type is set to Tests
types.append(type)
for t in types:
if not t in bodies:
@@ -250,24 +276,7 @@ def tests(tests):
usage()
with open(doc_name, "wt") as doc_file:
print('# NopSCADlib', file = doc_file)
print('''\
An ever expanding library of parts modelled in OpenSCAD useful for 3D printers and enclosures for electronics, etc.
It contains lots of vitamins (the RepRap term for non-printed parts), some general purpose printed parts and
some utilities. There are also Python scripts to generate Bills of Materials (BOMs),
STL files for all the printed parts, DXF files for CNC routed parts in a project and a manual containing assembly
instructions and exploded views by scraping markdown embedded in OpenSCAD comments, [see scripts](scripts/readme.md). A simple example project can be found [here](examples/MainsBreakOutBox/readme.md).
For more examples of what it can make see the [gallery](gallery/readme.md).
The license is GNU General Public License v3.0, see [COPYING](COPYING).
See [usage](docs/usage.md) for requirements, installation instructions and a usage guide.
<img src="libtest.png" width="100%"/>\n
''', file = doc_file)
print(lib_blurb, file = doc_file)
print('## Table of Contents<a name="top"/>', file = doc_file)
print('<table><tr>', file = doc_file)
n = 0
@@ -288,10 +297,10 @@ See [usage](docs/usage.md) for requirements, installation instructions and a usa
for type in types:
for line in bodies[type]:
print(line, file = doc_file)
with open("readme.html", "wt") as html_file:
do_cmd("python -m markdown -x tables readme.md".split(), html_file)
with open(doc_base_name + ".html", "wt") as html_file:
do_cmd(("python -m markdown -x tables " + doc_name).split(), html_file)
times.print_times()
do_cmd('codespell -L od readme.md'.split())
do_cmd(('codespell -L od ' + doc_name).split())
if __name__ == '__main__':
for arg in sys.argv[1:]:

View File

@@ -58,8 +58,12 @@ test_pcb = ["TestPCB", "Test PCB",
// components
[
[ 20, -5, 180, "trimpot10"],
[ 20, -15, 0, "trimpot10", true],
[ 10, 2, 0, "smd_led", LED0805, "red"],
[ 20, -15, 90, "trimpot10", true],
[ 10, 2, 90, "smd_led", LED0805, "red"],
[ 13, 2, 90, "smd_led", LED0603, "orange"],
[ 16, 2, 90, "smd_res", RES1206, "1K"],
[ 19, 2, 90, "smd_res", RES0805, "1K"],
[ 22, 2, 90, "smd_res", RES0603, "1K"],
[ 10, 10, 0, "2p54header", 4, 1],
[ 25, 10, 0, "2p54header", 5, 1, false, "blue" ],
[ 10, 20, 0, "2p54boxhdr", 4, 2],
@@ -82,16 +86,20 @@ test_pcb = ["TestPCB", "Test PCB",
[ 5, 218, 180, "hdmi"],
[ 3, 235, 180, "mini_hdmi"],
[ 6, 175, 180, "uSD", [12, 11.5, 1.4]],
[ 65, 9, 0, "link", inch(0.4)],
[ 65, 12, 0, "ax_res", res1_8, 1000],
[ 65, 17, 0, "ax_res", res1_4, 10000],
[ 65, 22, 0, "ax_res", res1_2, 100000],
[ 80, 9, 0, "link", inch(0.2), inch(0.4)],
[ 80, 12, 0, "ax_res", res1_8, 1000000, 1, inch(0.1)],
[ 80, 17, 0, "ax_res", res1_4, 100, 2, inch(0.1)],
[ 80, 22, 0, "ax_res", res1_2, 10, 10, inch(0.2)],
[ 60, 3, 0, "flex"],
[ 50, 15, 0, "flat_flex"],
[ 50, 15, -90, "flat_flex"],
[ 40, 15, -90, "flat_flex", true],
[ 60, 35, 0, "D_plug", DCONN9],
[ 50, 50, 0, "molex_hdr", 2],
@@ -113,7 +121,8 @@ test_pcb = ["TestPCB", "Test PCB",
[ 70, 130, 180, "term35", 3, "lime"],
[ 50, 150, 0, "transition", 5],
[ 50, 160, 0, "block", 10, 5, 8, "orange"],
[ 50, 170, 0, "button_6mm"],
[ 45, 170, 0, "button_6mm"],
[ 55, 170, 0, "button_4p5mm"],
[ 50, 185, 0, "microswitch", small_microswitch],
[ 52, 200, 0, "pcb", 11, TMC2130 ],
[ 80, 200, 0, "pdip", 24, "27C32", true, inch(0.6) ],

View File

@@ -21,9 +21,14 @@ use <../utils/layout.scad>
include <../vitamins/smds.scad>
module smds()
layout([for(l = smd_leds) smd_led_size(l).x], 1)
smd_led(smd_leds[$i], ["green", "blue", "red"][$i % 3]);
module smds() {
layout([for(r = smd_resistors) smd_res_size(r).x], 1)
smd_resistor(smd_resistors[$i], ["1R0", "10M", "100K"][$i % 3]);
translate([0, 3])
layout([for(l = smd_leds) smd_led_size(l).x], 1)
smd_led(smd_leds[$i], ["green", "blue", "red"][$i % 3]);
}
if($preview)
smds();

View File

@@ -23,46 +23,52 @@ use <../vitamins/insert.scad>
use <../utils/layout.scad>
module belt_test() {
p1 = [75, -50];
p2 = [-75, -50];
p3 = [-75, 100];
p4 = [75, 100];
p5 = [75 - pulley_pr(GT2x20ob_pulley) - pulley_pr(GT2x16_plain_idler), -pulley_pr(GT2x16_plain_idler)];
p6 = [-75 + pulley_pr(GT2x20ob_pulley) + pulley_pr(GT2x16_plain_idler), -pulley_pr(GT2x16_plain_idler)];
p5 = [75 + pulley_pr(GT2x20ob_pulley) - pulley_pr(GT2x16_plain_idler), +pulley_pr(GT2x16_plain_idler)];
p6 = [-75 + pulley_pr(GT2x20ob_pulley) + pulley_pr(GT2x16_plain_idler), -pulley_pr(GT2x16_plain_idler)];
translate(p1) pulley_assembly(GT2x20ob_pulley);
translate(p2) pulley_assembly(GT2x20ob_pulley);
translate(p3) pulley_assembly(GT2x20_toothed_idler);
translate(p4) pulley_assembly(GT2x20_toothed_idler);
module pulleys(flip = false) {
translate(p2) rotate([0, flip ? 180 : 0, 0]) pulley_assembly(GT2x20ob_pulley);
translate(p3) pulley_assembly(GT2x20_toothed_idler);
translate(p4) pulley_assembly(GT2x20_toothed_idler);
translate(p5) {
pulley = GT2x16_toothed_idler;
screw = find_screw(hs_cs_cap, pulley_bore(pulley));
insert = screw_insert(screw);
translate(p5) {
pulley = GT2x16_plain_idler;
screw = find_screw(hs_cs_cap, pulley_bore(pulley));
insert = screw_insert(screw);
pulley_assembly(pulley);
translate_z(pulley_height(pulley) + pulley_offset(pulley) + screw_head_depth(screw, pulley_bore(pulley)))
screw(screw, 20);
translate_z(pulley_offset(pulley) - insert_length(insert))
vflip()
insert(insert);
hflip(flip) {
pulley_assembly(pulley);
translate_z(pulley_height(pulley) + pulley_offset(pulley) + screw_head_depth(screw, pulley_bore(pulley)))
screw(screw, 20);
translate_z(pulley_offset(pulley) - insert_length(insert))
vflip()
insert(insert);
}
}
translate(p6) pulley_assembly(GT2x16_plain_idler);
}
translate(p6) pulley_assembly(GT2x16_plain_idler);
path = [ [p1.x, p1.y, pulley_pr(GT2x20ob_pulley)],
[p5.x, p5.y, -pulley_pr(GT2x16_plain_idler)],
path = [ [p5.x, p5.y, pulley_pr(GT2x16_plain_idler)],
[p6.x, p6.y, -pulley_pr(GT2x16_plain_idler)],
[p2.x, p2.y, pulley_pr(GT2x20ob_pulley)],
[p3.x, p3.y, pulley_pr(GT2x20ob_pulley)],
[p4.x, p4.y, pulley_pr(GT2x20ob_pulley)]
];
belt = GT2x6;
belt(belt, path, 80, [0, belt_pitch_height(belt) - belt_thickness(belt) / 2]);
translate([-25, 0])
belt = GT2x6;
belt(belt, path, 80, [0, 0]);
pulleys();
translate_z(20)
hflip() {
belt(belt, path, 80, [0, 0], belt_colour = grey(90), tooth_colour = grey(50));
pulleys(flip=true);
}
translate([-25, 0, 10])
layout([for(b = belts) belt_width(b)], 10)
rotate([0, 90, 0])
belt(belts[$i], [[0, 0, 20], [0, 1, 20]], belt_colour = $i%2==0 ? grey(90) : grey(20), tooth_colour = $i%2==0 ? grey(70) : grey(50));

33
tests/camera_housing.scad Normal file
View File

@@ -0,0 +1,33 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../core.scad>
use <../utils/layout.scad>
use <../printed/camera_housing.scad>
include <../vitamins/cameras.scad>
use <../vitamins/pcb.scad>
module camera_housings()
layout([for(c = cameras) pcb_length(camera_pcb(c))], 15, false) let(c = cameras[$i])
camera_fastened_assembly(c, 3);
if($preview)
camera_housings();

31
tests/cameras.scad Normal file
View File

@@ -0,0 +1,31 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../core.scad>
use <../utils/layout.scad>
include <../vitamins/cameras.scad>
use <../vitamins/pcb.scad>
module cameras()
layout([for(c = cameras) pcb_length(camera_pcb(c))], 15, false) let(c = cameras[$i])
camera(c);
if($preview)
cameras();

56
tests/catenary.scad Normal file
View File

@@ -0,0 +1,56 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
l = 250; // [1: 1000]
x = 200; // [1: 1000]
y = 50; //[-500 : 500]
include <../utils/core/core.scad>
use <../utils/catenary.scad>
use <../utils/sweep.scad>
use <../utils/annotation.scad>
module catenaries() {
//
// catenary curve path from control points
//
curve = [for(p = catenary_points(l, x, y)) [p.x, p.y, 0]];
//
// Draw the curve
//
r = 0.5;
sweep(curve, circle_points(r, $fn = 64));
//
// Minimum Z
//
min_z = catenary_points(l, x, y, 0);
color("blue") {
translate([min_z.x, min_z.y + r])
rotate([-90, 0, 0])
arrow();
translate([min_z.x, min_z.y - r])
rotate([90, 0, 0])
arrow();
}
}
if($preview)
rotate(is_undef($bom) ? 0 : [70, 0, 315])
catenaries();

59
tests/drag_chain.scad Normal file
View File

@@ -0,0 +1,59 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
// Link length between hinges
x = 10; //[8 : 30]
// Link inner width
y = 10; //[5 : 30]
// Link inner height
z = 5; //[4 : 11]
// Side wall thickness
wall = 1.6; //[0.9: 0.1: 3]
// Bottom wall thickness
bwall = 1.5; //[1: 0.25: 3]
// Top wall thickness
twall = 1.5; //[1: 0.25: 3]
// Max travel in each direction
travel = 100;
// Current position
pos = 50; // [-100 : 1 : 100]
include <../core.scad>
use <../printed/drag_chain.scad>
include <../vitamins/leadnuts.scad>
drag_chain = drag_chain("x", [x, y, z], travel, wall = wall, bwall = bwall, twall = twall);
module drag_chains()
drag_chain_assembly(drag_chain, pos);
if($preview)
drag_chains();
else {
drag_chain_link(drag_chain);
translate([-x * 2, 0])
drag_chain_link(drag_chain, start = true);
translate([x * 2, 0])
drag_chain_link(drag_chain, end = true);
}

View File

@@ -21,14 +21,14 @@ use <../printed/foot.scad>
module feet()
if($preview) {
translate([50, 0])
translate([40, 0])
foot_assembly(3);
translate([foot_diameter(insert_foot()) / 2, 0])
fastened_insert_foot_assembly(3);
}
else {
translate([50, 0])
translate([40, 0])
foot();
insert_foot();

66
tests/gears.scad Normal file
View File

@@ -0,0 +1,66 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../utils/core/core.scad>
use <../utils/gears.scad>
// left gear teeth
z1 = 39; // [7 : 1 : 99]
// Right gear teeth
z2 = 7; // [7 : 1 : 99]
// Modulus
m = 2.0; // [0.1 : 0.1 : 5.0]
// Pressure angle
pa = 20; // [14.5, 20, 22.5, 25]
$show_numbers = false;
module gears() {
color(pp1_colour)
rotate(-$t * 360)
linear_extrude(eps, center = true, convexity = z1)
difference() {
involute_gear_profile(m, z1, pa);
circle(r = m * z1 / 10);
}
color(pp2_colour)
translate([centre_distance(m, z1, z2, pa), 0])
rotate(180 + 180 / z2 + $t * 360 * z1 / z2)
linear_extrude(eps, center = true, convexity = z2)
difference() {
involute_gear_profile(m, z2, pa);
circle(r = m * z2 / 10);
}
z3 = floor((z1 + z2) / PI);
angle = -$t * 360 + 90 - floor(z1 / 4) * 360 / z1; // Line up the rack 1/4 turn around the gear
pitch = m * PI;
color(pp3_colour)
translate([(angle % ((z3 / z1) * 360)) / 360 * z1 * pitch, -centre_distance(m, z1, 0, pa)])
linear_extrude(eps, center = true)
involute_rack_profile(m, z3, 3 * m, pa);
}
rotate(is_undef($bom) ? 0 : [70, 0, 315])
gears();

View File

@@ -29,6 +29,23 @@ module globals() {
translate([50, 0])
right_triangle(10, 20, 0);
}
assert(slice("ABCD") == "ABCD");
assert(slice("ABCD", 1) == "BCD");
assert(slice("ABCD", 2) == "CD");
assert(slice("ABCD", 3) == "D");
assert(slice("ABCD", 4) == "");
assert(slice("ABCD", 1, -1) == "BC");
assert(slice("ABCD", 2, -1) == "C");
assert(slice("ABCD", 3, -1) == "");
assert(slice("ABCD", 4, -1) == "");
assert(slice("ABCD", 0, -1) == "ABC");
assert(slice("ABCD", 0, -2) == "AB");
assert(slice("ABCD", 0, -3) == "A");
assert(slice("ABCD", 0, -4) == "");
assert(slice("ABCD", 0, 0) == "");
assert(slice("ABCD", 0, 1) == "A");
assert(slice("ABCD", 0, 2) == "AB");
assert(slice("ABCD", 0, 3) == "ABC");
}
rotate([70, 0, 315]) globals();

94
tests/horiholes.scad Normal file
View File

@@ -0,0 +1,94 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
$layer_height = 0.25;
include <../utils/core/core.scad>
use <../utils/horiholes.scad>
show_disc = true;
use_horihole = true;
thickness = 6;
length = 60;
height = 20;
overlap_x = 15;
overlap_y = 10;
module hole_positions() {
x0 = (length - 40) / 2;
for($i = [0 : 4], $z = 5 + $i * layer_height / 5, $r = 3)
translate([x0 + $i * 10, $z])
children();
for($i = [0 : 4], $z = 15 + $i * layer_height / 5, $r = 0.5 + $i / 2)
translate([x0 + $i * 10, $z])
children();
}
module horiholes_stl(t = thickness) {
rotate([90, 0, 0])
difference() {
linear_extrude(t, center = true) {
difference() {
square([length, height]);
hole_positions()
if(use_horihole)
horihole($r, $z);
else
teardrop_plus(h = 0, r = $r);
}
}
}
if(t == thickness)
translate([length / 2, 0])
rounded_rectangle([length + 2 * overlap_x, thickness + 2 * overlap_y, 2], 5);
}
module horiholes() {
stl_colour(pp1_colour)
rotate([-90, 0, 0])
horiholes_stl(eps);
if(show_disc)
hole_positions()
color(silver)
cylinder(r = $r, h = eps, center = true, $fn = 360);
hole_positions()
color("blue")
horicylinder(r = $r, z = $z, h = 2 * eps, center = true, $fn = 360);
hole_positions()
color("red")
linear_extrude(3 * eps, center = true)
intersection() {
difference() {
square(8, center = true);
horihole($r, $z);
}
circle($r, $fn = 360);
}
}
if($preview)
rotate(is_undef($bom) ? 0 : [70, 0, 315])
horiholes();
else
horiholes_stl();

View File

@@ -25,7 +25,7 @@ module hot_ends()
layout([for(h = hot_ends) 40])
translate([-20, 0])
rotate(90)
hot_end(hot_ends[$i], 3);
hot_end(hot_ends[$i], 3, bowden = $i == 3);
if($preview)
hot_ends();

29
tests/magnets.scad Normal file
View File

@@ -0,0 +1,29 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../core.scad>
use <../utils/layout.scad>
include <../vitamins/magnets.scad>
module magnets()
layout([for(m = magnets) magnet_od(m)], 5)
magnet(magnets[$i]);
if($preview)
magnets();

View File

@@ -69,6 +69,33 @@ module maths() {
// Test Euler
//
assert(euler(rotate(r)) == r, "euler() failed");
//
// Circle intersect
//
r1 = 10;
c1 = [50, 0, 10];
r2 = 20;
c2 = [67, 0, 0];
p1 = circle_intersect(c1, r1, c2, r2);
p2 = circle_intersect(c2, r2, c1, r1);
rotate(90) {
color(grey(90))
translate(c1) rotate([90, 0, 0]) cylinder(r = r1, h = 4 * eps, center = true);
color(grey(80))
translate(c2) rotate([90, 0, 0]) cylinder(r = r2, h = eps, center = true);
color("red")
translate(p1) rotate([90, 0, 0]) cylinder(r = 0.1, h = 6 * eps, center = true);
color("blue")
translate(p2) rotate([90, 0, 0]) cylinder(r = 0.1, h = 6 * eps, center = true);
translate(p1) arrow();
translate(p2) vflip() arrow();
}
}
rotate(45)

View File

@@ -21,11 +21,11 @@ include <../utils/core/core.scad>
use <../vitamins/opengrab.scad>
module opengrab_test() {
opengrab_target();
rotate(45)
translate_z(opengrab_target_thickness())
opengrab();
opengrab_target();
translate_z(opengrab_target_thickness())
opengrab();
}
if($preview)

View File

@@ -23,26 +23,56 @@ include <../vitamins/pin_headers.scad>
pins = 10;
module pin_headers()
module pin_headers() {
layout([for(p = pin_headers) hdr_pitch(p) * pins], 15) {
idc_transition(pin_headers[$i], 10);
translate([0, 20])
pin_header(pin_headers[$i], 10, 2, right_angle = true);
pin_header(pin_headers[$i], 3, 2, right_angle = true);
translate([-10, 20])
pin_header(pin_headers[$i], 3, 1, right_angle = true);
translate([10, 20])
pin_header(pin_headers[$i], 3, 3, right_angle = true);
translate([0, 30])
pin_header(pin_headers[$i], 8, 1);
translate([0, 40])
pin_header(pin_headers[$i], 10, 2);
translate([0, 50])
box_header(pin_headers[$i], 8, 1);
translate([0, 60])
box_header(pin_headers[$i], 10, 2);
translate([0, 70])
pin_socket(pin_headers[$i], 8, 1);
translate([0, 80])
pin_socket(pin_headers[$i], 10, 2);
translate([0, 110])
pin_socket(pin_headers[$i], 10, 2, right_angle = true);
translate([-10, 105])
pin_socket(pin_headers[$i], 3, 1, right_angle = true);
translate([0, 105])
pin_socket(pin_headers[$i], 3, 2, right_angle = true);
translate([10, 105])
pin_socket(pin_headers[$i], 3, 3, right_angle = true);
}
for(i = [0, 1], p = [5, 2][i], j = [0 , 1]) {
h = [jst_ph_header, jst_xh_header][j];
translate([-20 * (i + 1), 0 + j * 40])
jst_xh_header(h, p);
translate([-20 * (i + 1), 20 + j * 40])
jst_xh_header(h, p, true);
}
}
if($preview)
pin_headers();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
tests/png/cameras.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
tests/png/catenary.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

BIN
tests/png/drag_chain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 102 KiB

BIN
tests/png/gears.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
tests/png/horiholes.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 115 KiB

BIN
tests/png/magnets.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 KiB

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 72 KiB

View File

@@ -67,7 +67,7 @@ module box1_external_additions() {
module box1_holes() {
box1_feet_positions()
teardrop(r = screw_pilot_hole(foot_screw(foot)), h = 10, center = true);
teardrop_plus(r = screw_pilot_hole(foot_screw(foot)), h = 10, center = true);
}

View File

@@ -25,10 +25,10 @@ use <../vitamins/nut.scad>
sheet = 3;
module rails()
layout([for(l = rails) carriage_width(rail_carriage(l))], 25)
layout([for(l = rails) carriage_width(rail_carriage(l))], 20)
rotate(-90) {
rail = rails[$i];
length = rail == MGN15 ? 260 : 200;
length = 200;
screw = rail_screw(rail);
nut = screw_nut(screw);
washer = screw_washer(screw);

View File

@@ -16,20 +16,22 @@
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../utils/core/core.scad>
include <../core.scad>
use <../printed/ribbon_clamp.scad>
use <../vitamins/wire.scad>
ways = 20;
ways = [8, 20];
screws = [M2_dome_screw, M3_cap_screw];
module ribbon_clamps()
translate([ribbon_clamp_length(ways) / 2, 0])
if($preview) {
ribbon_clamp_fastened_assembly(ways, 3);
for(i = [0 : len(screws) - 1])
translate([ribbon_clamp_length(ways[i]) / 2, i * 30])
if($preview) {
ribbon_clamp_fastened_assembly(ways[i], 3, screws[i]);
ribbon_cable(ways, 100);
}
else
ribbon_clamp(ways);
ribbon_cable(ways[i], 100);
}
else
ribbon_clamp(ways[i], screws[i]);
ribbon_clamps();

View File

@@ -0,0 +1,30 @@
//
// NopSCADlib Copyright Chris Palmer 2018
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
include <../core.scad>
include <../vitamins/shaft_couplings.scad>
use <../utils/layout.scad>
module shaft_couplings()
layout([for(s = shaft_couplings) sc_diameter(s)],5)
shaft_coupling(shaft_couplings[$i]);
if($preview)
shaft_couplings();

View File

@@ -22,12 +22,12 @@ include <../vitamins/stepper_motors.scad>
use <../utils/layout.scad>
module stepper_motors()
layout([for(s = stepper_motors) NEMA_width(s)], 5) {
layout([for(s = stepper_motors) NEMA_width(s)], 5) let(m = stepper_motors[$i]) {
rotate(180)
NEMA(stepper_motors[$i]);
NEMA(m, 0, m == NEMA17M || m == NEMA17M8);
translate_z(4)
NEMA_screws(stepper_motors[$i], M3_pan_screw, n = $i, earth = $i > 4 ? undef : $i - 1);
NEMA_screws(m, M3_pan_screw, n = $i, earth = $i > 4 ? undef : $i - 1);
}
if($preview)

View File

@@ -41,7 +41,10 @@ module teardrops() {
translate([20, 10])
semi_teardrop(h = 0, r = 3);
}
translate([20, 20])
teardrop(h = 0, r = 3, truncate = false, plus = true);
}
}
translate([40, 0, 1.5]) {
h = 3 + eps;
@@ -61,6 +64,9 @@ module teardrops() {
translate([20, 10])
semi_teardrop(h = h, r = 3, chamfer = chamfer);
translate([20, 20])
teardrop(h = h, r = 3, truncate = false, plus = false, chamfer = chamfer);
}
}
}

View File

@@ -26,27 +26,27 @@ profile = thread_profile(pitch / 2, pitch * 0.366, 30);
module threads()
for(female = [false, true]) translate([0, female ? -20 : 0]) {
length = female ? 8 : 40;
dia = female ? 8 : 8 - pitch;
colour = female ? brass : silver;
length = female ? 8 : 40;
dia = female ? 8 : 8 - pitch;
colour = female ? brass : silver;
thread(dia, starts * pitch, length, profile, starts = starts, top = 45, bot = 45, female = female, colour = colour);
thread(dia, starts * pitch, length, profile, starts = starts, top = 45, bot = 45, female = female, colour = colour);
color(colour)
translate([20, 0])
thread(dia, starts * pitch, length, profile, starts = starts, top = 0, bot = 0, female = female);
color(colour)
translate([20, 0])
thread(dia, starts * pitch, length, profile, starts = starts, top = 0, bot = 0, female = female);
translate([40, 0])
thread(dia, starts * pitch, length, profile, starts = starts, top = -1, bot = -1, female = female, colour = colour);
translate([40, 0])
thread(dia, starts * pitch, length, profile, starts = starts, top = -1, bot = -1, female = female, colour = colour);
color(colour)
translate([60, 0])
thread(dia, 2 * pitch, length, profile, starts = 2, top = -1, bot = -1, female = female);
color(colour)
translate([60, 0])
thread(dia, 2 * pitch, length, profile, starts = 2, top = -1, bot = -1, female = female);
color(colour)
translate([80, 0])
thread(dia, pitch, length, profile, starts = 1, top = -1, bot = -1, female = female);
}
color(colour)
translate([80, 0])
thread(dia, pitch, length, profile, starts = 1, top = -1, bot = -1, female = female);
}
let($show_threads = true)
threads();

View File

@@ -22,7 +22,7 @@ use <../utils/layout.scad>
include <../vitamins/tubings.scad>
module tubings()
layout([for(t = tubings) tubing_od(t)], 10)
layout([for(t = tubings) tubing_od(t)], 8)
tubing(tubings[$i]);
if($preview)

52
utils/catenary.scad Normal file
View File

@@ -0,0 +1,52 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Catenary curve to model hanging wires, etc.
//!
//! Although the equation of the curve is simply ```y = a cosh(x / a)``` there is no explicit formula to calculate the constant ```a``` or the range of ```x``` given the
//! length of the cable and the end point coordinates. See <https://en.wikipedia.org/wiki/Catenary#Determining_parameters>. The Newton-Raphson method is used to find
//! ```a``` numerically, see <https://en.wikipedia.org/wiki/Newton%27s_method>.
//!
//! The coordinates of the lowest point on the curve can be retrieved by calling ```catenary_points()``` with ```steps``` equal to zero.
//
include <core/core.scad>
use <maths.scad>
function catenary(t, a) = let(u = argsinh(t)) a * [u, cosh(u)]; //! Parametric catenary function linear along the length of the curve.
function catenary_s(d, a) = 2 * a * sinh(d / a); //! Length of a symmetric catenary with width ```2d```.
function catenary_ds_by_da(d, a) = 2 * sinh(d / a) - 2 * d / a * cosh(d / a); //! First derivative of the length with respect to ```a```.
function catenary_find_a(d, l, a = 1, best_e = inf, best_a = 1) = //! Find the catenary constant ```a```, given half the horizontal span and the length.
assert(l > 2 * d, "Not long enough to span the gap") assert(d) let(error = abs(catenary_s(d, a) - l))
error >= best_e && error < 0.0001 ? best_a
: catenary_find_a(d, l, max(a - (catenary_s(d, a) - l) / catenary_ds_by_da(d, a), d / argsinh(1e99)), error, a);
function catenary_points(l, x, y, steps = 100) = //! Returns a list of 2D points on the curve that goes from the origin to ```(x,y)``` and has length ```l```.
let(
d = x / 2,
a = catenary_find_a(d, sqrt(sqr(l) - sqr(y))), // Find a to get the correct length
offset = argsinh(y / catenary_s(d, a)),
t0 = sinh(-d / a + offset),
t1 = sinh( d / a + offset),
h = a * cosh(-d / a + offset) - a,
lowest = offset > d / a ? [0, 0] : offset < -d / a ? [x, y] : [d - offset * a, -h],
p0 = catenary(t0, a)
)
steps ? [for(t = [t0 : (t1 - t0) / steps : t1]) catenary(t, a) - p0] : lowest;

View File

@@ -18,7 +18,7 @@
//
//
// Include this file to use the miniumum library
// Include this file to use the minimum library
//
include <../../global_defs.scad>
//
@@ -28,12 +28,12 @@ use <global.scad>
module use_stl(name) { //! Import an STL to make a build platter
stl(name);
import(str("../stls/", name, ".stl"));
path = is_undef($target) ? "../stls/" : str("../", $target, "/stls/");
import(str(path, name, ".stl"));
}
module use_dxf(name) { //! Import a DXF to make a build panel
dxf(name);
import(str("../dxfs/", name, ".dxf"));
path = is_undef($target) ? "../dxfs/" : str("../", $target, "/dxfs/");
import(str(path, name, ".dxf"));
}

View File

@@ -31,16 +31,27 @@ function m(x) = x * 1000.0;
function sqr(x) = x * x; //! Returns the square of ```x```
function echoit(x) = echo(x) x; //! Echo expression and return it, useful for debugging
function no_point(str) = chr([for(c = str(str)) if(c == ".") ord("p") else ord(c)]);//! Replace decimal point in string with 'p'
function in(list, x) = !!len([for(v = list) if(v == x) true]); //! Returns true if ```x``` is an element in the ```list```
function Len(x) = is_list(x) ? len(x) : 0; //! Returns the length of a list or 0 if ```x``` is not a list
function r2sides(r) = $fn ? $fn : ceil(max(min(360/ $fa, r * 2 * PI / $fs), 5)); //! Replicates the OpenSCAD logic to calculate the number of sides from the radius
function r2sides4n(r) = floor((r2sides(r) + 3) / 4) * 4; //! Round up the number of sides to a multiple of 4 to ensure points land on all axes
function limit(x, min, max) = max(min(x, max), min); //! Force x in range min <= x <= max
module translate_z(z) translate([0, 0, z]) children(); //! Shortcut for Z only translations
module vflip() rotate([180, 0, 0]) children(); //! Invert children by doing a 180&deg; flip around the X axis
module hflip() rotate([0, 180, 0]) children(); //! Invert children by doing a 180&deg; flip around the Y axis
module vflip(flip=true) rotate([flip ? 180 : 0, 0, 0]) children(); //! Invert children by doing a 180&deg; flip around the X axis
module hflip(flip=true) rotate([0, flip ? 180: 0, 0]) children(); //! Invert children by doing a 180&deg; flip around the Y axis
module ellipse(xr, yr) scale([1, yr / xr]) circle4n(xr); //! Draw an ellipse
function slice_str(str, start, end, s ="") = start >= end ? s : slice_str(str, start + 1, end, str(s, str[start])); // Helper for slice()
function slice(list, start = 0, end = undef) = let( //! Slice a list or string with Python type semantics
len = len(list),
start = limit(start < 0 ? len + start : start, 0, len),
end = is_undef(end) ? len : limit(end < 0 ? len + end : end, 0, len)
) is_string(list) ? slice_str(list, start, end) : [for(i = [start : 1 : end - 1]) list[i]];
module extrude_if(h, center = true) //! Extrudes 2D object to 3D when ```h``` is nonzero, otherwise leaves it 2D
if(h)
linear_extrude(h, center = center, convexity = 2) // 3D

View File

@@ -32,10 +32,14 @@ module poly_circle(r, sides = 0) { //! Make a circle adjusted to print the corre
circle(r = corrected_radius(r,n), $fn = n);
}
module poly_cylinder(r, h, center = false, sides = 0) //! Make a cylinder adjusted to print the correct size
module poly_cylinder(r, h, center = false, sides = 0, chamfer = false) {//! Make a cylinder adjusted to print the correct size
extrude_if(h, center)
poly_circle(r, sides);
if(h && chamfer)
poly_cylinder(r + layer_height, center ? layer_height * 2 : layer_height, center, sides = sides ? sides : sides(r));
}
module poly_ring(or, ir, sides = 0) { //! Make a 2D ring adjusted to have the correct internal radius
cir = corrected_radius(ir, sides);
filaments = (or - cir) / extrusion_width;

View File

@@ -20,17 +20,32 @@
//
//! For making horizontal holes that don't need support material.
//! Small holes can get away without it, but they print better with truncated teardrops.
//!
//! Using teardrop_plus() or setting the plus option on other modules will elongate the teardrop vertically by the layer height, so when sliced the staircase tips
//! do not intrude into the circle. See <https://hydraraptor.blogspot.com/2020/07/horiholes-2.html>
//
module teardrop(h, r, center = true, truncate = true, chamfer = 0) { //! For making horizontal holes that don't need support material, set ```truncate = false``` to make traditional RepRap teardrops that don't even need bridging
module teardrop(h, r, center = true, truncate = true, chamfer = 0, plus = false) { //! For making horizontal holes that don't need support material, set ```truncate = false``` to make traditional RepRap teardrops that don't even need bridging
module teardrop_2d(r, truncate) {
hull() {
circle4n(r);
if(truncate)
translate([0, r / 2])
square([2 * r * (sqrt(2) - 1), r], center = true);
else
polygon([[0, 0], [eps, 0], [0, r * sqrt(2)]]);
}
er = layer_height / 2 - eps; // Extrustion edge radius
R = plus ? r + er : r; // Corrected radius
offset = plus ? -er : 0; // Offset inwards
hull()
for(side = [0 : 1])
mirror([side, 0, 0])
intersection() {
hull()
translate([offset, 0]) {
circle4n(R);
if(truncate)
translate([0, R / 2])
square([2 * R * (sqrt(2) - 1), R], center = true);
else
polygon([[0, 0], [eps, 0], [0, R * sqrt(2)]]);
}
translate([0, -2 * R])
square([R, 4 * R]);
}
}
render(convexity = 5)
@@ -40,23 +55,23 @@ module teardrop(h, r, center = true, truncate = true, chamfer = 0) { //! For mak
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
teardrop_2d(r + chamfer / 2, truncate);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
teardrop_2d(r, truncate);
}
}
module semi_teardrop(h, r, d = undef, center = true, chamfer = 0) { //! A semi teardrop in the positive Y domain
module semi_teardrop_2d(r, d) {
module semi_teardrop(h, r, d = undef, center = true, chamfer = 0, plus = false) { //! A semi teardrop in the positive Y domain
module semi_teardrop_2d(r, d)
intersection() {
R = is_undef(d) ? r : d / 2;
teardrop(r = R, h = 0);
teardrop(r = R, h = 0, plus = plus);
sq = R + 1;
translate([-sq, 0])
square([2 * sq, sq]);
}
}
render(convexity = 5)
extrude_if(h, center)
@@ -65,22 +80,21 @@ module semi_teardrop(h, r, d = undef, center = true, chamfer = 0) { //! A semi t
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
semi_teardrop_2d(r + chamfer / 2, d);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
semi_teardrop_2d(r, d);
}
}
module teardrop_plus(h, r, center = true, truncate = true, chamfer = 0) //! Slightly bigger teardrop to allow for the 3D printing staircase effect
teardrop(h, r + layer_height / 4, center, truncate, chamfer);
module teardrop_plus(h, r, center = true, truncate = true, chamfer = 0) //! Slightly elongated teardrop to allow for the 3D printing staircase effect
teardrop(h, r, center, truncate, chamfer, plus = true);
module tearslot(h, r, w, center = true, chamfer = 0) { //! A horizontal slot that doesn't need support material
module tearslot_2d(r, w) {
hull() {
translate([-w / 2, 0]) teardrop(r = r, h = 0);
translate([w / 2, 0]) teardrop(r = r, h = 0);
}
}
module tearslot(h, r, w, center = true, chamfer = 0, plus = false) { //! A horizontal slot that doesn't need support material
module tearslot_2d(r, w)
hull()
for(x = [-1, 1])
translate([x * w / 2, 0]) teardrop(r = r, h = 0, plus = plus);
extrude_if(h, center)
tearslot_2d(r, w);
@@ -88,19 +102,19 @@ module tearslot(h, r, w, center = true, chamfer = 0) { //! A horizontal slot tha
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
tearslot_2d(r + chamfer / 2, w);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
tearslot_2d(r, w);
}
}
module vertical_tearslot(h, r, l, center = true, chamfer = 0) { //! A vertical slot that doesn't need support material
module vertical_tearslot_2d(r, l) {
hull() {
translate([0, l / 2]) teardrop(0, r, true);
translate([0, -l / 2]) circle4n(r);
}
}
module vertical_tearslot(h, r, l, center = true, chamfer = 0, plus = false) { //! A vertical slot that doesn't need support material
module vertical_tearslot_2d(r, l)
hull()
for(y = [-1, 1])
translate([0, y * l / 2])
teardrop(0, r, true, plus = plus);
extrude_if(h, center)
vertical_tearslot_2d(r, l);
@@ -108,6 +122,7 @@ module vertical_tearslot(h, r, l, center = true, chamfer = 0) { //! A vertical s
teardrop_chamfer(h, center, chamfer) {
linear_extrude(eps, center = true)
vertical_tearslot_2d(r + chamfer / 2, l);
translate_z(-chamfer / 2)
linear_extrude(eps, center = true)
vertical_tearslot_2d(r, l);
@@ -123,4 +138,3 @@ module teardrop_chamfer(h, center, chamfer) { //! Helper module for adding chamf
hull()
children();
}

138
utils/gears.scad Normal file
View File

@@ -0,0 +1,138 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Utilities for making involute gears.
//!
//! Formulas from <https://khkgears.net/new/gear_knowledge/gear_technical_reference/involute_gear_profile.html>
//! <https://khkgears.net/new/gear_knowledge/gear_technical_reference/calculation_gear_dimensions.html>
//! and <https://www.tec-science.com/mechanical-power-transmission/involute-gear/calculation-of-involute-gears/>
//!
//! ```involute_gear_profile()``` returns a polygon that can have the bore and spokes, etc, subtracted from it before linear extruding it to 3D.
//! Helical gears can be made using ```twist``` and bevel gears using ```scale``` parameters of ```linear_extrude()```.
//!
//! Gears with less than 19 teeth (when pressure angle is 20) are profile shifted to avoid undercutting the tooth root. 7 teeth is considered
//! the practical minimum.
//!
//! The clearance between tip and root defaults to module / 6, but can be overridden by setting the ```clearance``` parameter.
//!
//! The origin of the rack is the left end of the pitch line and its width is below the pitch line. I.e. it does not include the addendum.
//!
//! ```involute_worm_profile()``` returns a tooth profile that can be passed to ```thread()``` to make worms.
//
include <core/core.scad>
use <maths.scad>
function involute(r, u) = let(a = degrees(u), c = cos(a), s = sin(a)) r * [c + u * s, s - u * c]; //! Involute of circle radius r at angle u in radians
function profile_shift(z, pa) = z ? max(1 - z * sqr(sin(pa)) / 2, 0) : 0; //! Calculate profile shift for small gears
function centre_distance(m, z1, z2, pa = 20) = //! Calculate distance between centres taking profile shift into account
let(x1 = profile_shift(z1, pa), x2 = profile_shift(z2, pa)) m * (z1/2 + z2/2 + x1 + x2);
function involute_gear_od(m, z, pa = 20) = //! involute gear outside diameter given modulus, tooth count and pressure angle
m * (z + 2 * profile_shift(z, pa) + 2);
module involute_gear_profile(m, z, pa = 20, clearance = undef, steps = 20) { //! Calculate gear profile given module, number of teeth and pressure angle
assert(z >= 7, "Gears must have at least 7 teeth.");
d = m * z; // Reference pitch circle diameter
x = profile_shift(z, pa); // Profile shift
c = is_undef(clearance) ? m / 6 : clearance; // Clearance from tip to root
base_d = d * cos(pa); // Base diameter
root_r = d / 2 + m * (x - 1) - c; // Root radius (dedendum circle radius)
tip_d = d + 2 * m * (1 + x); // Tip diameter (addendum circle diameter)
tpa = acos(base_d / tip_d); // Tip pressure angle
inva = tan(pa) - radians(pa); // Involute alpha
invaa = tan(tpa) - radians(tpa); // Involute alphaa
ta = PI / (2 * z) + 2 * x * tan(pa) / z + inva - invaa; // Tooth tip thickness angle, radians
crest_w = ta * tip_d; // Crest width
umax = sqrt(sqr(tip_d / base_d) - 1); // Max value of the involute parameter
base_r = base_d / 2;
p1 = involute(base_r, 0);
p2 = involute(base_r, umax);
dist = norm(p2 - p1); // distance between beginning and end of the involute curve
base_angle = 2 * acos((sqr(base_r) + sqr(tip_d / 2) - sqr(dist)) / base_r / tip_d) + degrees(2 * ta);
root_angle = 360 / z - base_angle;
root_circle_r = base_r * sin(root_angle / 2);
if(!is_undef($show_numbers) && $show_numbers) {
echo(d=d);
echo(base_d=base_d);
echo(tip_d=tip_d);
echo(tpa = tpa);
echo(inva=inva);
echo(invaa=invaa);
echo(x=x);
echo(ta=ta);
echo(crest_w=crest_w);
echo(umax = umax);
echo(base_angle=base_angle);
echo(root_angle=root_angle);
}
involute = [for(i = [0 : steps], u = umax * i / steps) involute(base_r, u)]; // involute for the bottom side of the tooth
truncated = [for(p = involute) if((rot2_z(-base_angle / 2) * p).y <= 0) p]; // removed any above the centreline to prevent overlap
reflection = reverse([for(p = truncated) rot2_z(base_angle) * [p.x, -p.y] ]); // reflect and rotate to make the top edge
root = reverse([for(a = [90 : 180 / steps : 270]) rot2_z(base_angle + root_angle / 2) * ([base_r, 0] + root_circle_r * [cos(a), sin(a)]) ]);
tooth = concat(truncated, reflection, root);
gear = concat([for(i = [0 : z - 1], p = tooth) rot2_z(i * 360 / z) * p]);
rotate(-base_angle / 2)
union() {
polygon(gear);
circle(root_r);
}
}
function involute_rack_tooth_profile(m, pa = 20, clearance = undef) = //! Calculate rack tooth profile given module and pressure angle
let(p = PI * m, // Pitch
ha = m, // Addendum
c = is_undef(clearance) ? m / 4 : clearance, // Tip root clearance
hf = m + c, // Dedendum
hw = 2 * m, // Working depth
h = ha + hf, // Tooth depth
crest_w = p / 2 - 2 * ha * tan(pa), // Crest width
base_w = crest_w + 2 * hw * tan(pa), // Base width
root_w = p - base_w, // Root width
clearance_w = root_w - 2 * c * tan(pa), // Width of clearance without fillet
kx = tan(pa / 2 + 45), // Fillet ratio of radius and xoffset
pf = min(0.38 * m, kx * clearance_w / 2), // Dedendum fillet radius
x = pf / kx, // Fillet centre x offset from corner
sides = ceil(r2sides(pf) * (90 - pa) / 360), // Fillet facets taking $fa, $fs and $fn into account
fillet = [ for(i = [0 : sides - 1], a = i * (90 - pa) / sides + 270) [clearance_w / 2 - x, -hf + pf] + pf * [cos(a), sin(a)] ],
reflection = reverse([for(pt = fillet) [p - pt.x, pt.y] ]) // reflect for trailing edge
) concat(fillet, [ [root_w / 2, -hw / 2], [p / 2 - crest_w / 2, ha], [p / 2 + crest_w / 2, ha], [p - root_w / 2, -hw / 2] ], reflection);
module involute_rack_profile(m, z, w, pa = 20, clearance = undef) { //! Calculate rack profile given module, number of teeth and pressure angle
p = PI * m; // Pitch
hf = 1.25 * m; // Dedendum
tooth = involute_rack_tooth_profile(m, pa, clearance);
teeth = [for(i = [0 : z - 1], pt = tooth) [pt.x + i * p, pt.y] ];
polygon(concat([[0, -w], [0, -hf]], teeth, [[z * p, -hf ], [z * p, -w]])); // Add the corners
}
function involute_worm_profile(m, pa = 20, clearance = undef) = //! Calculate worm profile suitable for passing to thread()
let(tooth = involute_rack_tooth_profile(m),
pitch = PI * m,
y_min = min([for(p = tooth) p.y])
) [for(p = tooth) [p.x - pitch / 2, p.y - y_min, 0]]; // Offset to be positive in y, centred in x and add 0 z ordintate

View File

@@ -39,11 +39,13 @@ module hanging_hole(z, ir, h = 100, h2 = 100) { //! Hole radius ```ir``` hanging
infill_angle = z % (2 * layer_height) ? -45 : 45;
below = min(z + eps, h2);
big = 1000;
render(convexity = 3) translate_z(z)
union() {
translate_z(2 * layer_height)
polyhole(ir - eps, h - 2 * layer_height);
if(sides(ir) > 4)
polyhole(ir - eps, h - 2 * layer_height);
else
poly_cylinder(ir, h - 2 * layer_height);
difference() {
translate_z(-below)

83
utils/horiholes.scad Normal file
View File

@@ -0,0 +1,83 @@
//
// NopSCADlib Copyright Chris Palmer 2020
// nop.head@gmail.com
// hydraraptor.blogspot.com
//
// This file is part of NopSCADlib.
//
// NopSCADlib is free software: you can redistribute it and/or modify it under the terms of the
// GNU General Public License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// NopSCADlib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
//
//! Utilities for depicting the staircase slicing of horizontal holes made with [`teardrop_plus()`](#teardrops), see <https://hydraraptor.blogspot.com/2020/07/horiholes-2.html>
//!
//! ```horicylinder()``` makes cylinders that fit inside a round hole. Layers that are less than 2 filaments wide and layers that need more than a 45 degree overhang are omitted.
//
include <../utils/core/core.scad>
function teardrop_plus_x(r, y, h) = //! Calculate the ordinate of a compensated teardrop given y and layer height.
let(fr = h / 2,
hpot = r + fr,
x2 = sqr(hpot) - sqr(y),
x = x2 > 0 ? sqrt(x2) : 0
)
max(0,
y < hpot / sqrt(2) ? x - fr :
y < hpot ? hpot * sqrt(2) - y - fr :
0);
module horihole(r, z, h = 0, center = true) { //! For making horizontal holes that don't need support material and are correct dimensions
bot_layer = floor((z - r) / layer_height);
top_layer = ceil((z + r) / layer_height);
render(convexity = 5)
extrude_if(h, center)
for(i = [bot_layer : top_layer]) {
Z = i * layer_height;
y = Z - z + layer_height / 2;
x = teardrop_plus_x(r, y, layer_height);
if(x > 0)
translate([0, y])
difference() {
square([2 * x + layer_height, layer_height], center = true);
for(end = [-1, 1])
translate([end * (x + layer_height / 2), 0])
circle(d = layer_height, $fn = 32);
}
}
}
function teardrop_minus_x(r, y, h) = //! Calculate the ordinate of a compensated teardrop given y and layer height.
let(fr = h / 2,
hpot = r - fr,
x2 = sqr(hpot) - sqr(y),
x = x2 > 0 ? sqrt(x2) : 0,
X = y >= -hpot / sqrt(2) ? x + fr : 0
)
X >= extrusion_width ? X : 0;
module horicylinder(r, z, h = 0, center = true) { //! For making horizontal cylinders that don't need support material and are correct dimensions
bot_layer = floor((z - r) / layer_height);
top_layer = ceil((z + r) / layer_height);
render(convexity = 5)
extrude_if(h, center)
for(i = [bot_layer : top_layer]) {
Z = i * layer_height;
y = Z - z + layer_height / 2;
x = teardrop_minus_x(r, y, layer_height);
if(x >= extrusion_width)
hull()
for(end = [-1, 1])
translate([end * (x - layer_height / 2), y])
circle(d = layer_height, $fn = 32);
}
}

View File

@@ -28,6 +28,6 @@ function layout_offset(widths, i, gap = 2) = //! Calculate the offset for the ``
module layout(widths, gap = 2, no_offset = false) //! Layout children passing ```$i```
translate([no_offset ? -widths[0] / 2 : 0, 0])
for($i = [0 : len(widths) - 1])
for($i = [0 : 1 : len(widths) - 1])
translate([layout_offset(widths, $i, gap), 0])
children();

View File

@@ -20,7 +20,18 @@
//
//! Maths utilities for manipulating vectors and matrices.
//
function sqr(x) = x * x;
function sqr(x) = x * x; //! Square x
function radians(degrees) = degrees * PI / 180; //! Convert radians to degrees
function degrees(radians) = radians * 180 / PI; //! Convert degrees to radians
function sinh(x) = (exp(x) - exp(-x)) / 2; //! hyperbolic sine
function cosh(x) = (exp(x) + exp(-x)) / 2; //! hyperbolic cosine
function tanh(x) = sinh(x) / cosh(x); //! hyperbolic tangent
function coth(x) = cosh(x) / sinh(x); //! hyperbolic cotangent
function argsinh(x) = ln(x + sqrt(sqr(x) + 1)); //! inverse hyperbolic sine
function argcosh(x) = ln(x + sqrt(sqr(x) - 1)); //! inverse hyperbolic cosine
function argtanh(x) = ln((1 + x) / (1 - x)) / 2;//! inverse hyperbolic tangent
function argcoth(x) = ln((x + 1) / (x - 1)) / 2;//! inverse hyperbolic cotangent
function translate(v) = let(u = is_list(v) ? len(v) == 2 ? [v.x, v.y, 0] //! Generate a 4x4 translation matrix, ```v``` can be ```[x, y]```, ```[x, y, z]``` or ```z```
: v
@@ -63,6 +74,12 @@ function rot3_z(a) = //! Generate a 3x3 matrix to rotate around z
[ s, c, 0],
[ 0, 0, 1] ];
function rot2_z(a) = //! Generate a 2x2 matrix to rotate around z
let(c = cos(a),
s = sin(a))
[ [ c, -s],
[ s, c] ];
function scale(v) = let(s = is_list(v) ? v : [v, v, v]) //! Generate a 4x4 matrix that scales by ```v```, which can be a vector of xyz factors or a scalar to scale all axes equally
[
[s.x, 0, 0, 0],
@@ -90,3 +107,49 @@ function euler(R) = let(ay = asin(-R[2][0]), cy = cos(ay)) //! Convert a rotatio
cy ? [ atan2(R[2][1] / cy, R[2][2] / cy), ay, atan2(R[1][0] / cy, R[0][0] / cy) ]
: R[2][0] < 0 ? [atan2( R[0][1], R[0][2]), 180, 0]
: [atan2(-R[0][1], -R[0][2]), -180, 0];
module position_children(list, t) //! Position children if they are on the Z = 0 plane when transformed by t
for(p = list)
let(q = t * p)
if(abs(transform([0, 0, 0], q).z) < 0.01)
multmatrix(q)
children();
// Matrix inversion: https://www.mathsisfun.com/algebra/matrix-inverse-row-operations-gauss-jordan.html
function augment(m) = let(l = len(m), n = identity(l)) [ //! Augment a matrix by adding an identity matrix to the right
for(i = [0 : l - 1])
concat(m[i], n[i])
];
function rowswap(m, i, j) = [ //! Swap two rows of a matrix
for(k = [0 : len(m) - 1])
k == i ? m[j] : k == j ? m[i] : m[k]
];
function solve_row(m, i) = let(diag = m[i][i]) [ //! Make diagonal one by dividing the row by it and subtract from other rows to make column zero
for(j = [0 : len(m) - 1])
i == j ? m[j] / diag : m[j] - m[i] * m[j][i] / diag
];
function nearly_zero(x) = abs(x) < 1e-5; //! True if x is close to zero
function solve(m, i = 0, j = 0) = //! Solve each row ensuring diagonal is not zero
i < len(m) ?
assert(i + j < len(m), "matrix is singular")
solve(!nearly_zero(m[i + j][i]) ? solve_row(j ? rowswap(m, i, i + j) : m, i) : solve(m, i, j + 1), i + 1)
: m;
function invert(m) = let(n =len(m), m = solve(augment(m))) [ //! Invert a matrix
for(i = [0 : n - 1]) [
for(j = [n : 2 * n - 1])
each m[i][j]
]
];
function circle_intersect(c1, r1, c2, r2) = //! Calculate one point where two circles in the X-Z plane intersect, clockwise around c1
let(
v = c1 - c2, // Line between centres
d = norm(v), // Distance between centres
a = atan2(v.z, v.x) - acos((sqr(d) + sqr(r2) - sqr(r1)) / (2 * d * r2)) // Cosine rule to find angle from c2
) c2 + r2 * [cos(a), 0, sin(a)]; // Point on second circle

View File

@@ -23,18 +23,21 @@
include <../utils/core/core.scad>
module quadrant(w, r, center = false) { //! Draw a square with one rounded corner, can be centered on the arc centre, when ```center``` is ```true```.
offset = center ? r - w : 0;
translate([offset, offset])
h = is_list(w) ? w.y : w;
w = is_list(w) ? w.x : w;
offset_w = center ? r - w : 0;
offset_h = center ? r - h : 0;
translate([offset_w, offset_h])
hull() {
intersection() {
translate([w - r, w - r])
translate([w - r, h - r])
circle4n(r);
square(w);
square([w, h]);
}
square([w, eps]);
square([eps, w]);
square([eps, h]);
}
}

View File

@@ -34,14 +34,22 @@ function transpose3(m) = [ [m[0].x, m[1].x, m[2].x],
[m[0].y, m[1].y, m[2].y],
[m[0].z, m[1].z, m[2].z] ];
//
// Find the first non-colinear point
//
tiny = 0.00001;
function find_curve(tangents, i = 1) =
i >= len(tangents) - 1 || norm(cross(tangents[0], tangents[i] - tangents[0])) > tiny ? i
: find_curve(tangents, i + 1);
//
// Frenet-Serret frame
//
function fs_frame(tangents) =
let(tangent = tangents[0],
normal = tangents[1] - tangents[0],
i = find_curve(tangents),
normal = tangents[i] - tangents[0],
binormal = cross(tangent, normal),
z = unit(tangent),
x = assert(norm(binormal) > 0.00001, "first three points are colinear") unit(binormal),
x = assert(norm(binormal) > tiny, "all points are colinear") unit(binormal),
y = unit(cross(z, x))
) [[x.x, y.x, z.x],
[x.y, y.y, z.y],
@@ -70,7 +78,6 @@ function orientate(p, r) =
[x.y, y.y, z.y],
[x.z, y.z, z.z],
[p.x, p.y, p.z]];
//
// Rotate around z
//
@@ -145,10 +152,10 @@ function sweep(path, profile, loop = false, twist = 0) = //! Generate the point
faces = loop ? skin_faces : concat([cap(facets)], skin_faces, [cap(facets, npoints - 1)])
) [points, faces];
module sweep(path, profile, loop = false, twist = 0) { //! Draw a polyhedron that is the swept volume
module sweep(path, profile, loop = false, twist = 0, convexity = 1) { //! Draw a polyhedron that is the swept volume
mesh = sweep(path, profile, loop, twist);
polyhedron(points = mesh[0], faces = mesh[1]);
polyhedron(points = mesh[0], faces = mesh[1], convexity = convexity);
}
function path_length(path, i = 0, length = 0) = //! Calculated the length along a path

View File

@@ -26,6 +26,8 @@
//! Threads are by default solid, so the male version is wrapped around a cylinder and the female inside a tube. This can be suppressed to just get the helix, for
//! example to make a printed pot with a screw top lid.
//!
//! A left hand thread can be made by using mirror([0,1]).
//!
//! Threads with a typical 60 degree angle appear too bright with OpenSCAD's primitive lighting model as they face towards the lights more than the top and sides of
//! a cylinder. To get around this a colour can be passed to thread that is used to colour the cylinder and then toned down to colour the helix.
//!
@@ -47,7 +49,7 @@ function thread_profile(h, crest, angle, overlap = 0.1) = //! Create thread prof
let(base = crest + 2 * (h + overlap) * tan(angle / 2))
[[-base / 2, -overlap, 0], [-crest / 2, h, 0], [crest / 2, h, 0], [base / 2, -overlap, 0]];
module thread(dia, pitch, length, profile, center = true, top = -1, bot = -1, starts = 1, solid = true, female = false, colour = undef) { //! Create male or femail thread, ends can be tapered, chamfered or square
module thread(dia, pitch, length, profile, center = true, top = -1, bot = -1, starts = 1, solid = true, female = false, colour = undef) { //! Create male or female thread, ends can be tapered, chamfered or square
//
// Apply colour if defined
//
@@ -61,10 +63,12 @@ module thread(dia, pitch, length, profile, center = true, top = -1, bot = -1, st
// Extract some properties from the profile, perhaps they should be stored in it.
//
h = max([for(p = sprofile) p.y]);
maxx = max([for(p = sprofile) p.x]);
minx = min([for(p = sprofile) p.x]);
crest_xmax = max([for(p = sprofile) if(p.x != maxx) p.x]);
crest_xmin = min([for(p = sprofile) if(p.x != minx) p.x]);
xs = [for(p = sprofile) p.x];
maxx = max(xs);
minx = min(xs);
crest_xs = [for(p = sprofile) if(p.y == h) p.x];
crest_xmax = max(crest_xs);
crest_xmin = min(crest_xs);
//
// If the ends don't taper we need an extra half turn past the ends to be cropped horizontally.
//
@@ -129,11 +133,13 @@ module thread(dia, pitch, length, profile, center = true, top = -1, bot = -1, st
render() intersection() {
polyhedron(points, ends_faces);
len = length - 2 * eps;
shorten = !is_undef(colour);
len = shorten ? length - 2 * eps : length;
offset = shorten ? eps : 0;
rotate_extrude()
if(female) {
difference() {
translate([0, eps])
translate([0, offset])
square([r + h + overlap, len]);
if(top_chamfer_h)
@@ -146,7 +152,7 @@ module thread(dia, pitch, length, profile, center = true, top = -1, bot = -1, st
else
difference() {
hull() {
translate([0, eps])
translate([0, offset])
square([r, len]);
translate([0, bot_chamfer_h])

View File

@@ -31,3 +31,41 @@ module ring(or, ir) //! Create a ring with specified external and internal radii
module tube(or, ir, h, center = true) //! Create a tube with specified external and internal radii and height ```h```
linear_extrude(h, center = center, convexity = 5)
ring(or, ir);
module woven_tube(or, ir, h, center= true, colour = grey(30), colour2, warp = 2, weft) {//! Create a woven tube with specified external and internal radii, height ```h```, colours, warp and weft
colour2 = colour2 ? colour2 : colour * 0.8;
weft = weft ? weft : warp;
warp_count = max(floor(PI * or / warp), 0.5);
angle = 360 / (2 * warp_count);
module layer(weft) {
points = [[ir, weft / 2], [or, weft / 2], [or, -weft / 2], [ir, -weft / 2]];
color(colour)
for (i = [0 : warp_count])
rotate(2 * i * angle)
rotate_extrude(angle = angle)
polygon(points);
color(colour2)
for (i = [0 : warp_count])
rotate((2 * i + 1) * angle)
rotate_extrude(angle = angle)
polygon(points);
}
translate_z(center ? -h / 2 : 0) {
weft_count = floor(h / weft);
if (weft_count > 0)
for (i = [0 : weft_count - 1]) {
translate_z(i * weft + weft / 2)
rotate(i * angle)
layer(weft);
}
remainder = h - weft * weft_count;
if (remainder) {
translate_z(weft_count * weft + remainder / 2)
rotate(weft_count * angle)
layer(remainder);
}
}
}

View File

@@ -24,6 +24,7 @@ include <../utils/core/core.scad>
include <../utils/round.scad>
module wire_link(d, l, h = 1, tail = 3) { //! Draw a wire jumper link.
vitamin(str("wire_link(", d, ", ", l, arg(h, 1, "h"), arg(tail, 3, "tail"), "): Wire link ", d, "mm x ", l / inch(1), "\""));
r = d;
$fn = 32;
@@ -57,13 +58,16 @@ module orientate_axial(length, height, pitch, wire_d) { // Orient horizontal or
min_pitch = ceil((length + 1) / inch(0.1)) * inch(0.1);
lead_pitch = pitch ? pitch : min_pitch;
if(lead_pitch >= min_pitch) {
wire_link(wire_d, lead_pitch, height);
not_on_bom()
wire_link(wire_d, lead_pitch, height);
translate_z(height)
rotate([0, 90, 0])
children();
}
else {
wire_link(wire_d, lead_pitch, length + 0.7 + wire_d);
not_on_bom()
wire_link(wire_d, lead_pitch, length + 0.7 + wire_d);
translate([-pitch / 2, 0, length / 2 + 0.2])
children();

View File

@@ -52,21 +52,21 @@ module ball_bearing(type) { //! Draw a ball bearing
rim_chamfer = rim / 6;
rotate_extrude()
hull() {
translate([or - rim / 2, 0])
square([rim, h - 2 * rim_chamfer], center = true);
translate([or - rim, -h / 2 + rim_chamfer])
square([rim, h - 2 * rim_chamfer]);
translate([or - rim / 2 - rim_chamfer, 0])
square([rim - rim_chamfer, h], center = true);
translate([or - rim, -h / 2])
square([rim - rim_chamfer, h]);
}
hub_chamfer = hub / 6;
rotate_extrude()
hull() {
translate([ir + hub / 2, 0])
square([hub, h - 2 * hub_chamfer], center = true);
translate([ir, -h / 2 + hub_chamfer])
square([hub, h - 2 * hub_chamfer]);
translate([ir + hub / 2 + hub_chamfer, 0])
square([hub - hub_chamfer, h], center = true);
translate([ir + hub_chamfer, -h / 2])
square([hub - hub_chamfer, h]);
}
}

View File

@@ -16,11 +16,12 @@
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
BB624 = ["624", 4, 13, 5, "blue", 1.2, 1.2]; // 624 ball bearing for idlers
BB608 = ["608", 8, 22, 7, "OrangeRed", 1.4, 2.0]; // 608 bearings for wades
BB6200 = ["6200", 10, 30, 9, "black", 2.3, 3.6]; // 6200 bearings for KP pillow blocks
BB6201 = ["6201", 12, 32, 10, "black", 2.4, 3.7]; // 6201 bearings for KP pillow blocks
BB6808 = ["6808", 40, 52, 7, "black", 1.5, 1.6];
ball_bearings = [BB624, BB608, BB6200, BB6201, BB6808];
BBSMR95 = ["SMR95", 5, 9, 2.5, "silver", 0.5, 0.7]; // SMR95 ball bearing for FlexDrive extruder
BB624 = ["624", 4, 13, 5, "blue", 1.2, 1.2]; // 624 ball bearing for idlers
BB608 = ["608", 8, 22, 7, "OrangeRed", 1.4, 2.0]; // 608 bearings for wades
BB6200 = ["6200", 10, 30, 9, "black", 2.3, 3.6]; // 6200 bearings for KP pillow blocks
BB6201 = ["6201", 12, 32, 10, "black", 2.4, 3.7]; // 6201 bearings for KP pillow blocks
BB6808 = ["6808", 40, 52, 7, "black", 1.5, 1.6];
ball_bearings = [BBSMR95, BB624, BB608, BB6200, BB6201, BB6808];
use <ball_bearing.scad>

View File

@@ -19,61 +19,67 @@
//
//! Models timing belt running over toothed or smooth pulleys and calculates an accurate length.
//! Only models 2D paths, so not core XY!
//! Only models 2D paths, so not crossed belt core XY!
//!
//! To make the back of the belt run against a smooth pulley on the outside of the loop specify a negative pitch radius.
//!
//! By default the path is a closed loop but a gap length and position can be specified to make open loops.
//! To draw the gap its XY position is specified by ```gap_pos```. ```gap_pos.z``` can be used to specify a rotation if the gap is not at the bottom of the loop.
//!
//! Individual teeth are not drawn, instead they are represented by a lighter colour.
//
include <../utils/core/core.scad>
use <../utils/rounded_polygon.scad>
use <../utils/maths.scad>
function belt_pitch(type) = type[1]; //! Pitch in mm
function belt_width(type) = type[2]; //! Width in mm
function belt_thickness(type) = type[3]; //! Total thickness including teeth
function belt_tooth_height(type) = type[4]; //! Tooth height
function belt_pitch_height(type) = belt_tooth_height(type) + type[4]; //! Offset of the pitch radius from the tips of the teeth
function belt_pitch_height(type) = type[5] + belt_tooth_height(type); //! Offset of the pitch radius from the tips of the teeth
function no_point(str) = chr([for(c = str) if(c == ".") ord("p") else ord(c)]);
function belt_pitch_to_back(type) = belt_thickness(type) - belt_pitch_height(type); //! Offset of the back from the pitch radius
//
// We model the belt path at the pitch radius of the pulleys and the pitch line of the belt to get an accurate length.
// The belt is then drawn by offseting each side from the pitch line.
//
module belt(type, points, gap = 0, gap_pt = undef, belt_colour = grey(20), tooth_colour = grey(50)) { //! Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless a gap is specified
module belt(type, points, gap = 0, gap_pos = undef, belt_colour = grey(20), tooth_colour = grey(50)) { //! Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless a gap is specified
width = belt_width(type);
pitch = belt_pitch(type);
thickness = belt_thickness(type);
part = str(type[0],pitch);
vitamin(str("belt(", no_point(part), "x", width, ", ", points, arg(gap, 0), arg(gap_pt, undef), "): Belt ", part," x ", width, "mm x ", length, "mm"));
vitamin(str("belt(", no_point(part), "x", width, ", ", points, arg(gap, 0), arg(gap_pos, undef), "): Belt ", part," x ", width, "mm x ", length, "mm"));
len = len(points);
tangents = rounded_polygon_tangents(points);
length = ceil((rounded_polygon_length(points, tangents) - gap) / pitch) * pitch;
length = ceil((rounded_polygon_length(points, tangents) - (is_list(gap) ? gap.x + gap.y : gap)) / pitch) * pitch;
module shape() rounded_polygon(points, tangents);
ph = belt_pitch_height(type);
th = belt_tooth_height(type);
module gap()
if(gap)
translate(gap_pt)
square([gap, thickness + eps], center = true);
translate([gap_pos.x, gap_pos.y])
rotate(is_undef(gap_pos.z) ? 0 : gap_pos.z)
translate([0, ph - thickness / 2])
square(is_list(gap) ? [gap.x, gap.y + thickness + eps] : [gap, thickness + eps], center = true);
color(belt_colour)
linear_extrude(width, center = true)
difference() {
offset(thickness - belt_pitch_height(type)) shape();
offset(-belt_pitch_height(type) + belt_tooth_height(type)) shape();
offset(-ph + thickness ) shape();
offset(-ph + th) shape();
gap();
}
color(tooth_colour)
linear_extrude(width, center = true)
difference() {
offset(-belt_pitch_height(type) + belt_tooth_height(type)) shape();
offset(-belt_pitch_height(type)) shape();
offset(-ph + th) shape();
offset(-ph) shape();
gap();
}
}

View File

@@ -22,6 +22,8 @@
//
include <../utils/core/core.scad>
use <../utils/rounded_cylinder.scad>
use <../utils/quadrant.scad>
use <screw.scad>
function blower_length(type) = type[2]; //! Length of enclosing rectangle
function blower_width(type) = type[3]; //! Width of enclosing rectangle
@@ -39,8 +41,87 @@ function blower_top(type) = type[14]; //! Thickness of the top
function blower_wall(type) = type[15]; //! Side wall thickness
function blower_lug(type) = type[16]; //! Height of the lugs
function blower_casing_is_square(type) = len(blower_screw_holes(type)) > 3; //! True for square radial fans, false for spiral shape radial blowers
function blower_exit_offset(type) = blower_casing_is_square(type) ? blower_length(type) / 2 : blower_exit(type) / 2; //! Offset of exit's centre from the edge
fan_colour = grey(20);
module blower_fan(type, casing_is_square) {
module squarish(s, n) {
polygon([
for(i = [0 : n]) [i * s.x / n, s.y + (i % 2) * eps],
for(i = [0 : n]) [s.x - i * s.x / n, (i % 2) * eps],
]);
}
depth = blower_depth(type);
blade_ir = blower_hub(type) / 2 + 0.5; // slight gap between main part of blades and hub
blade_len = casing_is_square
? (blower_bore(type) - 1) / 2 - blade_ir // fan constrained by bore hole
: blower_width(type) - blower_axis(type).x- blower_wall(type) - blade_ir; // fan extends to casing
blade_thickness = 0.75;
blade_count = 25;
base_offset = 1;
translate([blower_axis(type).x, blower_axis(type).y, blower_base(type) + base_offset])
linear_extrude(blower_hub_height(type) - 0.5 - blower_base(type) - base_offset, center = false, convexity = 4, twist = -30, slices = round(depth / 2))
for(i = [0 : blade_count - 1])
rotate((360 * i) / blade_count)
translate([blade_ir, -blade_thickness / 2])
squarish([blade_len, blade_thickness], round(blade_len / 2));
}
module blower_square(type) { //! Draw a square blower
width = blower_width(type);
depth = blower_depth(type);
wall = blower_wall(type);
hole_pitch = (blower_screw_holes(type)[1].x - blower_screw_holes(type)[0].x) / 2;
corner_radius = width / 2 - hole_pitch;
corner_inset = (width - blower_exit(type)) / 2;
module square_inset_corners(remove_center = false)
difference() {
//overall outside
square([width, width], center = false);
if (remove_center) {
// cut out the inside, leaving the corners
translate([corner_inset + wall, -eps])
square([width - 2 * (wall + corner_inset), width - wall + eps], center = false);
translate([wall, corner_inset + wall])
square([width - 2 * wall, width - 2 * (wall + corner_inset)], center = false);
} else {
// cut out the bore for the fan
translate(blower_axis(type))
circle(d = blower_bore(type));
}
// corner inset
translate([width / 2, width / 2])
for(i = [0 : 3])
rotate(i * 90)
translate([-width / 2 - eps, -width/ 2 - eps])
quadrant(corner_inset, corner_inset - corner_radius);
}
base_height = blower_base(type);
linear_extrude(base_height)
difference () {
rounded_square([width, width], corner_radius, center = false);
blower_hole_positions(type)
circle(d = blower_screw_hole(type));
}
translate_z(base_height)
linear_extrude(depth - base_height)
square_inset_corners(remove_center = true);
translate_z(depth - base_height)
linear_extrude(blower_top(type))
square_inset_corners();
}
module blower(type) { //! Draw specified blower
length = blower_length(type);
width = blower_width(type);
@@ -70,55 +151,63 @@ module blower(type) { //! Draw specified blower
vitamin(str("blower(", type[0], "): ", type[1]));
is_square = blower_casing_is_square(type); // Description starts with square!
color(fan_colour) {
// screw lugs
linear_extrude(blower_lug(type), center = false)
for(hole = blower_screw_holes(type))
difference() {
hull() {
if (is_square) {
blower_square(type);
} else {
// screw lugs
linear_extrude(blower_lug(type), center = false)
for(hole = blower_screw_holes(type))
difference() {
hull() {
translate(hole)
circle(d = blower_screw_hole(type) + 2 * blower_wall(type));
translate(blower_axis(type))
circle(d = blower_screw_hole(type) + 2 * blower_wall(type) + 7);
}
translate(hole)
circle(d = blower_screw_hole(type) + 2 * blower_wall(type));
circle(d = blower_screw_hole(type));
translate(blower_axis(type))
circle(d = blower_screw_hole(type) + 2 * blower_wall(type) + 7);
}
translate(hole)
circle(d = blower_screw_hole(type));
shape(true);
}
shape(true);
}
// rotor
translate(concat(blower_axis(type), [blower_base(type) + 1]))
rounded_cylinder(r = blower_hub(type) / 2, h = blower_hub_height(type) - blower_base(type) - 1, r2 = 1);
*%square([length, width]);
*%square([length, width]);
// base
linear_extrude(blower_base(type))
difference() {
shape();
translate(concat(blower_axis(type), [blower_base(type)]))
circle(d = 2);
}
// sides
linear_extrude(depth)
difference() {
shape();
offset(-blower_wall(type))
shape(true);
}
// top
translate_z(depth -blower_top(type))
linear_extrude(blower_top(type))
// base
linear_extrude(blower_base(type))
difference() {
shape();
translate(concat(blower_axis(type), [blower_base(type)]))
circle(d = blower_bore(type));
}
circle(d = 2);
}
// sides
linear_extrude(depth)
difference() {
shape();
offset(-blower_wall(type))
shape(true);
}
// top
translate_z(depth -blower_top(type))
linear_extrude(blower_top(type))
difference() {
shape();
translate(concat(blower_axis(type), [blower_base(type)]))
circle(d = blower_bore(type));
}
}
// rotor
translate(concat(blower_axis(type), [blower_base(type) + 1]))
rounded_cylinder(r = blower_hub(type) / 2, h = blower_hub_height(type) - blower_base(type) - 1, r2 = 1);
blower_fan(type, is_square);
}
}

Some files were not shown because too many files have changed in this diff Show More