1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-09-03 12:22:46 +02:00

Compare commits

...

23 Commits

Author SHA1 Message Date
Chris Palmer
f3376edaf1 Documented xor() function. 2021-04-02 19:28:49 +01:00
Chris Palmer
c073419c0b Added opengrab_screw_depth() function. 2021-04-02 19:25:42 +01:00
Chris Palmer
52e9c1d7fd Updated changelog 2021-03-22 16:15:09 +00:00
Chris Palmer
ca1b34e9ca Added sink parameter to screw_polysink() to recess the head. 2021-03-22 16:11:51 +00:00
Chris Palmer
cbab9cea02 Fixed M6_cs_cap_screw. 2021-03-22 12:27:11 +00:00
Chris Palmer
69cf998862 Updated changelog 2021-03-21 18:50:14 +00:00
Chris Palmer
08bce9ec03 Updated changelog 2021-03-21 18:45:01 +00:00
Chris Palmer
4aa7dbb416 Added M6_cs_cap_screw. 2021-03-21 18:37:17 +00:00
Chris Palmer
7c7c2e5d3f Pixel changes due to switch to summer computer. 2021-03-21 17:57:46 +00:00
Chris Palmer
f6f6664c0d Updated OpenSCAD version required. 2021-03-15 00:24:14 +00:00
Chris Palmer
2fd2e118a0 Updated changelog 2021-03-14 19:04:00 +00:00
Chris Palmer
22c6fef113 Updated changelog 2021-03-14 18:56:50 +00:00
Chris Palmer
dcf0c949b9 Merge branch 'SmoothieAq-open_belt' 2021-03-14 18:54:28 +00:00
Chris Palmer
9ded315801 Removed the belt gap options and changed the tests to use open loops instead.
Note previous belt lengths were incorrect with negative turns.
Fixed spelling typos.
_belt_length() no longer needs belt type.
Uptated images and readme.
2021-03-14 18:53:37 +00:00
Chris Palmer
42e03679b4 Merge branch 'open_belt' of https://github.com/SmoothieAq/NopSCADlib into SmoothieAq-open_belt 2021-03-14 14:39:05 +00:00
SmoothieAq
d2c795f5f5 fix nan angle (hopefully) 2021-03-14 14:18:05 +01:00
Chris Palmer
83b4ab2374 Merge branch 'open_belt' of https://github.com/SmoothieAq/NopSCADlib into SmoothieAq-open_belt 2021-03-14 12:33:46 +00:00
SmoothieAq
573c50774b changes after review 2021-03-14 12:48:14 +01:00
Chris Palmer
4b93623492 changelog.py now omits "Updated changelog" commits. 2021-03-13 11:19:59 +00:00
Chris Palmer
d496898c80 Updated changelog 2021-03-13 10:46:30 +00:00
Chris Palmer
544e69c71b pulley_pr() now has an optional belt type for non-standard belt over smooth pulleys. 2021-03-13 10:45:54 +00:00
SmoothieAq
240334784d Extension to belt.scad
Can now:
- render open loops
- twist the belt
- use pulleys instead of radius in the points list

Fixes some precision a few places
Breaking change in belt_length(); now requires a type argument
2021-03-11 13:40:17 +01:00
SmoothieAq
516b225275 Merge pull request #1 from nophead/master
update fork
2021-03-10 09:11:48 +01:00
29 changed files with 298 additions and 107 deletions

View File

@@ -3,6 +3,53 @@
This changelog is generated by `changelog.py` using manually added semantic version tags to classify commits as breaking changes, additions or fixes.
### [v15.3.0](https://github.com/nophead/NopSCADlib/releases/tag/v15.3.0 "show release") Additions [...](https://github.com/nophead/NopSCADlib/compare/v15.2.0...v15.3.0 "diff with v15.2.0")
* 2021-04-02 [`c073419`](https://github.com/nophead/NopSCADlib/commit/c073419c0b4eddcda4cda5bd0f8d48268b6e58ec "show commit") [C.P.](# "Chris Palmer") Added `opengrab_screw_depth()` function.
### [v15.2.0](https://github.com/nophead/NopSCADlib/releases/tag/v15.2.0 "show release") Additions [...](https://github.com/nophead/NopSCADlib/compare/v15.1.1...v15.2.0 "diff with v15.1.1")
* 2021-03-22 [`ca1b34e`](https://github.com/nophead/NopSCADlib/commit/ca1b34e9cad5d82bd878fa4ebf439c0fbdad7f77 "show commit") [C.P.](# "Chris Palmer") Added `sink` parameter to `screw_polysink()` to recess the head.
#### [v15.1.1](https://github.com/nophead/NopSCADlib/releases/tag/v15.1.1 "show release") Fixes [...](https://github.com/nophead/NopSCADlib/compare/v15.1.0...v15.1.1 "diff with v15.1.0")
* 2021-03-22 [`cbab9ce`](https://github.com/nophead/NopSCADlib/commit/cbab9cea028a204032a91729597572a39ed893a2 "show commit") [C.P.](# "Chris Palmer") Fixed `M6_cs_cap_screw`.
### [v15.1.0](https://github.com/nophead/NopSCADlib/releases/tag/v15.1.0 "show release") Additions [...](https://github.com/nophead/NopSCADlib/compare/v15.0.1...v15.1.0 "diff with v15.0.1")
* 2021-03-21 [`4aa7dbb`](https://github.com/nophead/NopSCADlib/commit/4aa7dbb416773e42b2b5f77b345f18fcd4d2ae2c "show commit") [C.P.](# "Chris Palmer") Added `M6_cs_cap_screw`.
#### [v15.0.1](https://github.com/nophead/NopSCADlib/releases/tag/v15.0.1 "show release") Fixes [...](https://github.com/nophead/NopSCADlib/compare/v15.0.0...v15.0.1 "diff with v15.0.0")
* 2021-03-21 [`7c7c2e5`](https://github.com/nophead/NopSCADlib/commit/7c7c2e5d3f76e84ae86892f9d90f21619fa61a47 "show commit") [C.P.](# "Chris Palmer") Pixel changes due to switch to summer computer.
* 2021-03-15 [`f6f6664`](https://github.com/nophead/NopSCADlib/commit/f6f6664c0d06a7cc3d49f805a2fd4f4978a3a35a "show commit") [C.P.](# "Chris Palmer") Updated OpenSCAD version required.
## [v15.0.0](https://github.com/nophead/NopSCADlib/releases/tag/v15.0.0 "show release") Breaking Changes [...](https://github.com/nophead/NopSCADlib/compare/v14.1.1...v15.0.0 "diff with v14.1.1")
* 2021-03-14 [`9ded315`](https://github.com/nophead/NopSCADlib/commit/9ded3158010b577088fdaca8a25e478f48a27376 "show commit") [C.P.](# "Chris Palmer") Removed the belt gap options and changed the tests to use open loops instead.
Note previous belt lengths were incorrect with negative turns.
Fixed spelling typos.
`_belt_length()` no longer needs belt type.
Uptated images and readme.
* 2021-03-14 [`d2c795f`](https://github.com/nophead/NopSCADlib/commit/d2c795f5f5c564ec4686a7857bd894738a93a6a0 "show commit") [S.](# "SmoothieAq") fix nan angle (hopefully)
* 2021-03-14 [`573c507`](https://github.com/nophead/NopSCADlib/commit/573c50774bfb2edae25a415ca864abb39c4c1bcf "show commit") [S.](# "SmoothieAq") changes after review
* 2021-03-11 [`2403347`](https://github.com/nophead/NopSCADlib/commit/240334784db8002468fe0f51c1f6404a64fe44a4 "show commit") [S.](# "SmoothieAq") Extension to `belt.scad`
* Can now:
- render open loops
- twist the belt
- use pulleys instead of radius in the points list
* Fixes some precision a few places
Breaking change in `belt_length();` now requires a type argument
#### [v14.1.1](https://github.com/nophead/NopSCADlib/releases/tag/v14.1.1 "show release") Fixes [...](https://github.com/nophead/NopSCADlib/compare/v14.1.0...v14.1.1 "diff with v14.1.0")
* 2021-03-13 [`4b93623`](https://github.com/nophead/NopSCADlib/commit/4b93623492a2b8a073ab9dccc91fb2b21c475f21 "show commit") [C.P.](# "Chris Palmer") `changelog.py` now omits "Updated changelog" commits.
### [v14.1.0](https://github.com/nophead/NopSCADlib/releases/tag/v14.1.0 "show release") Additions [...](https://github.com/nophead/NopSCADlib/compare/v14.0.1...v14.1.0 "diff with v14.0.1")
* 2021-03-13 [`544e69c`](https://github.com/nophead/NopSCADlib/commit/544e69c71b404636df320be278b3fa7442f10429 "show commit") [C.P.](# "Chris Palmer") `pulley_pr()` now has an optional belt type for non-standard belt over smooth pulleys.
#### [v14.0.1](https://github.com/nophead/NopSCADlib/releases/tag/v14.0.1 "show release") Fixes [...](https://github.com/nophead/NopSCADlib/compare/v14.0.0...v14.0.1 "diff with v14.0.0")
* 2021-03-08 [`e46e6b6`](https://github.com/nophead/NopSCADlib/commit/e46e6b6e5b95792b5b2b4d7a7e4360beed22df0b "show commit") [C.P.](# "Chris Palmer") Fixed markdown numbered points in `core_xy`.
## [v14.0.0](https://github.com/nophead/NopSCADlib/releases/tag/v14.0.0 "show release") Breaking Changes [...](https://github.com/nophead/NopSCADlib/compare/v13.5.0...v14.0.0 "diff with v13.5.0")
* 2021-03-06 [`298d1f9`](https://github.com/nophead/NopSCADlib/commit/298d1f92841f30e13b437c6770fc113954b94108 "show commit") [C.P.](# "Chris Palmer") Interface is the same but filenames to be included or used changed.
Changlog upated.
@@ -43,8 +90,6 @@ Changlog upated.
* 2021-03-03 [`a7eae4f`](https://github.com/nophead/NopSCADlib/commit/a7eae4f549b51dbe4624a8b67012919cef6cb24a "show commit") [C.P.](# "Chris Palmer") Neater changlog format.
* 2021-03-03 [`7b770ab`](https://github.com/nophead/NopSCADlib/commit/7b770abe12b71fa4b4f7415aa9f46d0f2c9d54f1 "show commit") [C.P.](# "Chris Palmer") Udpated changelog
* 2021-03-03 [`31ab856`](https://github.com/nophead/NopSCADlib/commit/31ab8562a783464f93812b8c7c45d403587efd0a "show commit") [C.P.](# "Chris Palmer") Updated images
* 2021-02-27 [`73c436e`](https://github.com/nophead/NopSCADlib/commit/73c436ee1568c21afd2919593d3f434eb47b53f2 "show commit") [M.B.](# "Martin Budden") Improved contrast of carbon fiber sheets.

View File

@@ -1,7 +1,7 @@
# NopSCADlib usage
## Requirements
1. OpenSCAD 2019.05 or later, download it from here: https://www.openscad.org/downloads.html
1. OpenSCAD 2021.01 or later, download it from here: https://www.openscad.org/downloads.html
1. Python 2.7+ or 3.6+ from https://www.python.org/downloads/
1. ImageMagick 7 www.imagemagick.org

Binary file not shown.

Before

Width:  |  Height:  |  Size: 884 KiB

After

Width:  |  Height:  |  Size: 891 KiB

View File

@@ -267,13 +267,22 @@ SCSnUU and SCSnLUU bearing blocks
---
<a name="Belts"></a>
## Belts
Models timing belt running over toothed or smooth pulleys and calculates an accurate length.
Only models 2D paths, so not crossed belt core XY!
Models timing belt running in a path over toothed or smooth pulleys and calculates an accurate length.
Only models 2D paths, belt may twist to support crossed belt core XY and other designes where the belt twists!
By default the path is a closed loop. An open loop can be specified by specifying `open=true`, and in that case the start and end points are not connected, leaving the loop open.
To get a 180 degree twist of the loop, you can use the `twist` argument. `Twist` can be a single number, and in that case the belt will twist after
the position with that number. Alternatively `twist` can be a list of boolean values with a boolean for each position; the belt will then twist after
the position that have a `true` value in the `twist` list. If the path is specified with pulley/idler types, then you can use `auto_twist=true`; in
that case the belt will automatically twist so the back of the belt always runs against idlers and the tooth side runs against pullies. If you use
`open=true` then you might also use `start_twist=true` to let the belt start the part with the back side out.
The path must be specified as a list of positions. Each position should be either a vector with `[x, y, pulley]` or `[x, y, r]`. A pully is a type from
`pulleys.scad`, and correct radius and angle will automatically be calculated. Alternatively a radius can be specified directly.
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.
Alternativley you can just specify smooth pulleys in the path, and it will then happen automatically.
Individual teeth are not drawn, instead they are represented by a lighter colour.
@@ -295,13 +304,15 @@ Individual teeth are not drawn, instead they are represented by a lighter colour
### Functions
| Function | Description |
|:--- |:--- |
| `belt_length(points, gap = 0)` | Compute belt length given path and optional gap |
| `_belt_points_info(type, points, open, twist, auto_twist, start_twist)` | Helper function that calculates [twist, istwisted, points, tangents, arcs] |
| `belt_length(type, points, open = false)` | Compute belt length given path |
| `belt_pitch_to_back(type)` | Offset of the back from the pitch radius |
| `belt_pulley_pr(type, pulley, twisted=false)` | Pitch radius. Default it expects the belt tooth to be against a toothed pulley an the backside to be against a smooth pulley (an idler). If `twisted` is true, the the belt is the other way around. |
### Modules
| Module | Description |
|:--- |:--- |
| `belt(type, points, gap = 0, gap_pos = undef, belt_colour = grey(20)` | Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless a gap is specified |
| `belt(type, points, belt_colour = grey(20)` | Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless open is specified |
![belts](tests/png/belts.png)
@@ -309,17 +320,18 @@ Individual teeth are not drawn, instead they are represented by a lighter colour
| Qty | Module call | BOM entry |
| ---:|:--- |:---|
| 1 | `belt(GT2x6, [ ... ])` | Belt GT2 x 6mm x 128mm |
| 2 | `belt(GT2x6, [ ... ], 80, [0, 0])` | Belt GT2 x 6mm x 572mm |
| 1 | `belt(GT2x6, [ ... ])` | Belt GT2 x 6mm x 552mm |
| 2 | `belt(GT2x6, [ ... ])` | Belt GT2 x 6mm x 556mm |
| 1 | `belt(T2p5x6, [ ... ])` | Belt T2.5 x 6mm x 130mm |
| 1 | `belt(T5x10, [ ... ])` | Belt T5 x 10mm x 130mm |
| 1 | `belt(T5x6, [ ... ])` | Belt T5 x 6mm x 130mm |
| 2 | `insert(F1BM3)` | Heatfit insert M3 |
| 2 | `pulley(GT2x16_toothed_idler)` | Pulley GT2 idler 16 teeth |
| 4 | `pulley(GT2x20_toothed_idler)` | Pulley GT2 idler 20 teeth |
| 2 | `pulley(GT2x16_plain_idler)` | Pulley GT2 idler smooth 9.63mm |
| 2 | `pulley(GT2x20ob_pulley)` | Pulley GT2OB 20 teeth |
| 6 | `pulley(GT2x16_plain_idler)` | Pulley GT2 idler smooth 9.63mm |
| 3 | `pulley(GT2x20ob_pulley)` | Pulley GT2OB 20 teeth |
| 2 | `screw(M3_cs_cap_screw, 20)` | Screw M3 cs cap x 20mm |
| 4 | `screw(M3_grub_screw, 6)` | Screw M3 grub x 6mm |
| 6 | `screw(M3_grub_screw, 6)` | Screw M3 grub x 6mm |
<a href="#top">Top</a>
@@ -2018,6 +2030,7 @@ A permanent magnet that can be magnatized and de-magnatized electronically.
| `opengrab_depth()` | Module height |
| `opengrab_pcb()` | The PCB |
| `opengrab_pcb_z()` | PCB offset from the front |
| `opengrab_screw_depth()` | Max screw depth in pillars |
| `opengrab_target_thickness()` | Target sheet thickness |
| `opengrab_width()` | Module width |
@@ -2681,7 +2694,7 @@ Timing belt pulleys, both toothed and plain with internal bearings for idlers.
| `pulley_height(type)` | Total height of pulley |
| `pulley_ir(type)` | Inside radius of the teeth |
| `pulley_offset(type)` | Offset of the belt path centre |
| `pulley_pr(type)` | Pitch radius |
| `pulley_pr(type, belt = undef)` | Pitch radius, `belt` only needed for non-standard belt over smooth pulleys |
### Modules
| Module | Description |
@@ -2993,7 +3006,7 @@ For an explanation of `screw_polysink()` see <https://hydraraptor.blogspot.com/2
| `screw(type, length, hob_point = 0, nylon = false)` | Draw specified screw, optionally hobbed or nylon |
| `screw_and_washer(type, length, star = false, penny = false)` | Screw with a washer which can be standard or penny and an optional star washer on top |
| `screw_countersink(type, drilled = true)` | Countersink shape |
| `screw_polysink(type, h = 100, alt = false)` | A countersink hole made from stacked polyholes for printed parts |
| `screw_polysink(type, h = 100, alt = false, sink = 0)` | A countersink hole made from stacked polyholes for printed parts, default is flush, `sink` can be used to recess the head |
![screws](tests/png/screws.png)
@@ -3025,6 +3038,7 @@ For an explanation of `screw_polysink()` see <https://hydraraptor.blogspot.com/2
| 1 | `screw(M5_hex_screw, 30)` | Screw M5 hex x 30mm |
| 1 | `screw(M5_pan_screw, 30)` | Screw M5 pan x 30mm |
| 1 | `screw(M6_cap_screw, 30)` | Screw M6 cap x 30mm |
| 1 | `screw(M6_cs_cap_screw, 30)` | Screw M6 cs cap x 30mm |
| 1 | `screw(M6_hex_screw, 30)` | Screw M6 hex x 30mm |
| 1 | `screw(M6_pan_screw, 30)` | Screw M6 pan x 30mm |
| 1 | `screw(M8_cap_screw, 35)` | Screw M8 cap x 35mm |
@@ -5628,8 +5642,8 @@ allows flexible positioning of the motors.
### Vitamins
| Qty | Module call | BOM entry |
| ---:|:--- |:---|
| 1 | `belt(GT2x6, [ ... ], [10.0078, 11.69], [0, -24.686])` | Belt GT2 x 6mm x 742mm |
| 1 | `belt(GT2x6, [ ... ], [10.0078, 11.69], [0, -24.686])` | Belt GT2 x 6mm x 852mm |
| 1 | `belt(GT2x6, [ ... ])` | Belt GT2 x 6mm x 728mm |
| 1 | `belt(GT2x6, [ ... ])` | Belt GT2 x 6mm x 824mm |
| 7 | `pulley(GT2x16_toothed_idler)` | Pulley GT2 idler 16 teeth |
| 3 | `pulley(GT2x16_plain_idler)` | Pulley GT2 idler smooth 9.63mm |
| 2 | `pulley(GT2x20ob_pulley)` | Pulley GT2OB 20 teeth |
@@ -5824,8 +5838,11 @@ Maths utilities for manipulating vectors and matrices.
| `euler(R)` | Convert a rotation matrix to a Euler rotation vector. |
| `identity(n, x = 1)` | Construct an arbitrary size identity matrix |
| `invert(m)` | Invert a matrix |
| `map(v, func)` | make a new vector where the func function argument is applied to each element of the vector v |
| `mapi(v, func)` | make a new vector where the func function argument is applied to each element of the vector v. The func will get the index number as first argument, and the element as second argument. |
| `nearly_zero(x)` | True if x is close to zero |
| `radians(degrees)` | Convert radians to degrees |
| `reduce(v, func, unity)` | reduce a vector v to a single entity by applying the func function recursively to the reduced value so far and the next element, starting with unity as the initial reduced value |
| `reverse(v)` | Reverse a vector |
| `rot2_z(a)` | Generate a 2x2 matrix to rotate around z |
| `rot3_z(a)` | Generate a 3x3 matrix to rotate around z |
@@ -5836,14 +5853,17 @@ Maths utilities for manipulating vectors and matrices.
| `solve(m, i = 0, j = 0)` | Solve each row ensuring diagonal is not zero |
| `solve_row(m, i)` | Make diagonal one by dividing the row by it and subtract from other rows to make column zero |
| `sqr(x)` | Square x |
| `sumv(v)` | sum a vector of values that can be added with "+" |
| `tanh(x)` | hyperbolic tangent |
| `transform(v, m)` | Apply 4x4 transform to a 3 vector by extending it and cropping it again |
| `transform_points(path, m)` | Apply transform to a path |
| `translate(v)` | Generate a 4x4 translation matrix, `v` can be `[x, y]`, `[x, y, z]` or `z` |
| `transpose(m)` | Transpose an arbitrary size matrix |
| `unit(v)` | Convert `v` to a unit vector |
| `vec2(v)` | Return a 2 vector with the first two elements of `v` |
| `vec3(v)` | Return a 3 vector with the first three elements of `v` |
| `vec4(v)` | Return a 4 vector with the first three elements of `v` |
| `xor(a,b)` | Logical exclusive OR |
### Modules
| Module | Description |
@@ -5957,8 +5977,9 @@ Because the tangents need to be calculated to find the length these can be calcu
| Function | Description |
|:--- |:--- |
| `circle_tangent(p1, p2)` | Compute the clockwise tangent between two circles represented as [x,y,r] |
| `rounded_polygon_arcs(points, tangents)` | Compute the arcs at the points, for each point [angle, rotate_angle, length] |
| `rounded_polygon_length(points, tangents)` | Calculate the length given the point list and the list of tangents computed by ` rounded_polygon_tangents` |
| `rounded_polygon_tangents(points)` | Compute the straight sections needed to draw and to compute the lengths |
| `rounded_polygon_tangents(points)` | Compute the straight sections between a point and the next point, for each section [start_point, end_point, length] |
### Modules
| Module | Description |

View File

@@ -159,5 +159,6 @@ if __name__ == '__main__':
print('%s [%s](%s "show release") %s %s' % ('#' * (level + 1), ver, url + '/releases/tag/' + ver, type, diff), file = file)
# Print commits excluding merges
if not c.comment.startswith('Merge branch') and not c.comment.startswith('Merge pull'):
if not c.comment.startswith('Merge branch') and not c.comment.startswith('Merge pull') and not re.match(r'U..ated changelog.*', c.comment):
print('* %s [`%s`](%s "show commit") %s %s\n' % (c.date, c.hash[:7], url + '/commit/' + c.hash, initials(c.author), fixup_comment(c.comment, url)), file = file)

View File

@@ -25,9 +25,9 @@ use <../utils/layout.scad>
module belt_test() {
p2 = [-75, -50];
p3 = [-75, 100];
p4 = [75, 100];
p4 = [ 75, 100];
p5 = [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)];
module pulleys(flip = false) {
@@ -52,19 +52,21 @@ module belt_test() {
translate(p6) pulley_assembly(GT2x16_plain_idler);
}
path = [ [p5.x, p5.y, pulley_pr(GT2x16_plain_idler)],
path = [ [-40, 0, 0],
[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)]
[p4.x, p4.y, pulley_pr(GT2x20ob_pulley)],
[p5.x, p5.y, pulley_pr(GT2x16_plain_idler)],
[40, 0, 0],
];
belt = GT2x6;
belt(belt, path, 80, [0, 0]);
belt(belt, path, open = true);
pulleys();
translate_z(20)
hflip() {
belt(belt, path, 80, [0, 0], belt_colour = grey(90), tooth_colour = grey(50));
belt(belt, path, open = true, belt_colour = grey(90), tooth_colour = grey(50));
pulleys(flip=true);
}
@@ -72,6 +74,31 @@ module belt_test() {
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));
// new example with open loop - this is a simplified example of the style used for example for the BLV 3D printer
pulley = GT2x20ob_pulley;
idler = GT2x16_plain_idler;
corners = [[-75,-50],[75,100]];
carriagepos = [0,0];
carriagew = 80;
points = [
[carriagepos.x - carriagew / 2, carriagepos.y, 0],
[corners[0].x + belt_pulley_pr(belt, pulley) + belt_pulley_pr(belt, idler), carriagepos.y - belt_pulley_pr(belt, idler), idler],
[corners[0].x, corners[0].y, pulley],
[corners[0].x, corners[1].y, idler],
[corners[1].x, corners[1].y, idler],
[corners[1].x, carriagepos.y + belt_pulley_pr(belt, idler), idler],
[carriagepos.x + carriagew / 2, carriagepos.y, 0]
];
translate_z(-30) {
belt(belt, points, open=true, auto_twist=true);
for (p = points)
if (is_list(p.z))
translate([p.x, p.y, 0])
pulley_assembly(p.z);
}
}
if($preview)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 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: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 103 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: 174 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 181 KiB

View File

@@ -16,6 +16,10 @@
// You should have received a copy of the GNU General Public License along with NopSCADlib.
// If not, see <https://www.gnu.org/licenses/>.
//
// Extra countersink depth
sink = 0; // [0 : 0.05: 1.0]
include <../core.scad>
module polysink_stl() {
@@ -32,9 +36,9 @@ module polysink_stl() {
let(s = cs_screws[i])
translate([i * 20, 0]) {
translate_z(size.z)
screw_polysink(s, 2 * size.z + 1);
screw_polysink(s, 2 * size.z + 1, sink = sink);
screw_polysink(s, 2 * size.z + 1, alt = true);
screw_polysink(s, 2 * size.z + 1, alt = true, sink = sink);
}
}
}

View File

@@ -51,15 +51,20 @@ function coreXY_lower_tooth_colour(type) = type[8]; //! Colour of the lower b
// relative to the anchor pulley so that the belts align properly
function coreXY_drive_pulley_x_alignment(type) = //! Belt alignment offset of the drive pulley relative to the anchor pulley
(pulley_od(coreXY_drive_pulley(type)) - pulley_od(coreXY_toothed_idler(type))) / 2;
function coreXY_coincident_separation(type) = //! Value of x, y separation to make y-carriage pulleys coincident
[ -coreXY_plain_idler_offset(type).x, -(pulley_od(coreXY_plain_idler(type)) + pulley_od(coreXY_toothed_idler(type)))/2, 0 ];
function coreXY_plain_idler_offset(type) = //! Offset of y-carriage plain idler
[ (pulley_od(coreXY_plain_idler(type)) + pulley_od(coreXY_drive_pulley(type))) / 2 + coreXY_drive_pulley_x_alignment(type), pulley_od(coreXY_plain_idler(type))/2, 0 ];
function coreXY_toothed_idler_offset(type) = //! offset of y-carriage toothed idler
[ 0, -pulley_pr(coreXY_toothed_idler(type)), 0 ];
// helper functions for positioning idlers when the stepper motor drive pulley is offset
function coreXY_drive_toothed_idler_offset(type) = //! Offset of toothed drive idler pulley
[ 0, coreXY_drive_pulley_x_alignment(type), 0 ];
function coreXY_drive_plain_idler_offset(type) = //! Offset of plain drive idler pulley
[ coreXY_plain_idler_offset(type).x, -(pulley_od(coreXY_plain_idler(type)) + pulley_od(coreXY_drive_pulley(type))) / 2, 0 ];
@@ -86,7 +91,7 @@ module coreXY_half(type, size, pos, separation_y = 0, x_gap = 0, plain_idler_off
// toothed idler for offset stepper motor drive pulley
p3t_type = coreXY_toothed_idler(type);
p3t = [ -size.x / 2 + (drive_pulley_offset.x > 0 ? 0 : 2*coreXY_drive_pulley_x_alignment(type)),
p3t = [ -size.x / 2 + (drive_pulley_offset.x > 0 ? 0 : 2 * coreXY_drive_pulley_x_alignment(type)),
size.y / 2 + coreXY_drive_pulley_x_alignment(type) + drive_pulley_offset.y
];
@@ -102,11 +107,11 @@ module coreXY_half(type, size, pos, separation_y = 0, x_gap = 0, plain_idler_off
size.y / 2 - pulley_od(p3p_type) / 2 - pulley_od(p3d_type) / 2 + drive_pulley_offset.y
];
// dummy pulleys for y separation
p5_type = p4_type;
p5 = [ pos.x - size.x / 2, -size.y / 2 + pos.y + separation_y / 2 ];
p6_type = p0_type;
p6 = [ pos.x - size.x / 2, -size.y / 2 + pos.y - separation_y / 2 ];
// Start and end points
start_p = [ pos.x - size.x / 2 + x_gap / 2, -size.y / 2 + pos.y - separation_y / 2, 0 ];
end_p = [ pos.x - size.x / 2 - x_gap / 2, -size.y / 2 + pos.y + separation_y / 2, 0 ];
//p6_type = p0_type;
module show_pulleys(show_pulleys) {// Allows the pulley colour to be set for debugging
if (is_list(show_pulleys))
@@ -119,16 +124,21 @@ module coreXY_half(type, size, pos, separation_y = 0, x_gap = 0, plain_idler_off
show_pulleys(show_pulleys) {
translate(p0)
pulley_assembly(p0_type); // y-carriage toothed pulley
translate(p1)
pulley_assembly(p1_type); // bottom right toothed idler pulley
translate(p2)
pulley_assembly(p2_type); // bottom left anchor toothed idler pulley
translate(p3d)
hflip(hflip)
pulley_assembly(p3d_type); // top left stepper motor drive pulley
if (drive_pulley_offset.x) { // idler pulleys for offset stepper motor drive pulley
translate(p3t)
pulley_assembly(p3t_type); // toothed idler
translate(p3p)
pulley_assembly(p3p_type); // plain idler
}
@@ -157,20 +167,15 @@ module coreXY_half(type, size, pos, separation_y = 0, x_gap = 0, plain_idler_off
[ p3t.x, p3t.y, pulley_od(p3t_type) / 2 ],
[ p4.x, p4.y, -pulley_od(p4_type) / 2 ]
];
path1 = [ // use eps for corner radius to get sharp corners so this part of the belt is deleted by the gap
[ p5.x, p5.y, eps ],
[ p6.x, p6.y, eps ]
];
belt = coreXY_belt(type);
path0 = drive_pulley_offset.x == 0 ? concat(path0a, path0b) : drive_pulley_offset.x > 0 ? concat(path0a, path0c) : concat(path0a, path0d);
path = separation_y == 0 ? path0 : concat(path0, path1);
path = concat([start_p], path0, [end_p]);
belt(type = belt,
points = path,
gap = [ x_gap + eps, abs(separation_y) + 2 ],
gap_pos = [ pos.x - size.x / 2, pos.y - size.y / 2 + belt_pitch_height(belt) - belt_thickness(belt) / 2 ],
open = true,
belt_colour = lower_belt ? coreXY_lower_belt_colour(type) : coreXY_upper_belt_colour(type),
tooth_colour = lower_belt ? coreXY_lower_tooth_colour(type) : coreXY_upper_tooth_colour(type));
}
@@ -181,6 +186,7 @@ module coreXY(type, size, pos, separation, x_gap, plain_idler_offset = 0, upper_
hflip()
explode(25)
coreXY_half(type, size, [size.x - pos.x - separation.x, pos.y], separation.y, x_gap, plain_idler_offset, [-lower_drive_pulley_offset.x, lower_drive_pulley_offset.y], show_pulleys, lower_belt = true, hflip = true);
// upper belt
translate([separation.x, 0, separation.z])
explode(25)

View File

@@ -88,6 +88,7 @@ function scale(v) = let(s = is_list(v) ? v : [v, v, v]) //! Generate a 4x4 matr
[0, 0, 0, 1]
];
function vec2(v) = [v.x, v.y]; //! Return a 2 vector with the first two elements of `v`
function vec3(v) = [v.x, v.y, v.z]; //! Return a 3 vector with the first three elements of `v`
function vec4(v) = [v.x, v.y, v.z, 1]; //! Return a 4 vector with the first three elements of `v`
function transform(v, m) = vec3(m * [v.x, v.y, v.z, 1]); //! Apply 4x4 transform to a 3 vector by extending it and cropping it again
@@ -153,3 +154,11 @@ function circle_intersect(c1, r1, c2, r2) = //! Calculate one point where tw
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
function map(v, func) = [ for (e = v) func(e) ]; //! make a new vector where the func function argument is applied to each element of the vector v
function mapi(v, func) = [ for (i = [0:len(v)-1]) func(i,v[i]) ]; //! make a new vector where the func function argument is applied to each element of the vector v. The func will get the index number as first argument, and the element as second argument.
function reduce(v, func, unity) = let ( r = function(i,val) i == len(v) ? val : r(i + 1, func(val, v[i])) ) r(0, unity); //! reduce a vector v to a single entity by applying the func function recursively to the reduced value so far and the next element, starting with unity as the initial reduced value
function sumv(v) = reduce(v, function(a, b) a + b, 0); //! sum a vector of values that can be added with "+"
function xor(a,b) = (a && !b) || (!a && b); //! Logical exclusive OR
function cuberoot(x)= sign(x)*abs(x)^(1/3);

View File

@@ -24,6 +24,7 @@
//! Because the tangents need to be calculated to find the length these can be calculated separately and re-used when drawing to save calculating them twice.
//
include <../utils/core/core.scad>
use <../utils/maths.scad>
function circle_tangent(p1, p2) = //! Compute the clockwise tangent between two circles represented as [x,y,r]
let(
@@ -36,36 +37,45 @@ function circle_tangent(p1, p2) = //! Compute the clockwise tangent between two
v = [cos(theta), sin(theta)]
)[ p1 + r1 * v, p2 + r2 * v ];
function rounded_polygon_tangents(points) = //! Compute the straight sections needed to draw and to compute the lengths
let(len = len(points))
[for(i = [0 : len - 1])
let(ends = circle_tangent(points[i], points[(i + 1) % len]))
for(end = [0, 1])
ends[end]];
function rounded_polygon_arcs(points, tangents) = //! Compute the arcs at the points, for each point [angle, rotate_angle, length]
let(
len = len(points)
) [ for (i = [0: len-1])
let(
p1 = vec2(tangents[(i - 1 + len) % len][1]),
p2 = vec2(tangents[i][0]),
p = vec2(points[i]),
v1 = p1 - p,
v2 = p2 - p,
sr = points[i][2],
r = abs(sr),
a = r < 0.001 ? 0 : let( aa = acos((v1 * v2) / sqr(r)) ) cross(v1, v2) * sign(sr) <= 0 ? aa : 360 - aa,
l = PI * a * r / 180,
v0 = [r, 0],
v = let (
vv = norm(v0 - v2) < 0.001 ? 0 : abs(v2.y) < 0.001 ? 180 :
let( aa = acos((v0 * v2) / sqr(r)) ) cross(v0, v2) * sign(sr) <= 0 ? aa : 360 - aa
) sr > 0 ? 360 - vv : vv - a
) [a, v, l]
];
function sumv(v, i = 0, sum = 0) = i == len(v) ? sum : sumv(v, i + 1, sum + v[i]);
function rounded_polygon_tangents(points) = //! Compute the straight sections between a point and the next point, for each section [start_point, end_point, length]
let(len = len(points))
[ for(i = [0 : len - 1])
let(ends = circle_tangent(points[i], points[(i + 1) % len]))
[ends[0], ends[1], norm(ends[0] - ends[1])]
];
// the cross product of 2D vectors is the area of the parallelogram between them. We use the sign of this to decide if the angle is bigger than 180.
function rounded_polygon_length(points, tangents) = //! Calculate the length given the point list and the list of tangents computed by ` rounded_polygon_tangents`
let(
len = len(points),
indices = [0 : len - 1],
straights = [for(i = indices) norm(tangents[2 * i] - tangents[2 * i + 1])],
arcs = [for(i = indices) let(p1 = tangents[2 * i + 1],
p2 = tangents[(2 * i + 2) % (2 * len)],
corner = points[(i + 1) % len],
c = [corner.x, corner.y],
v1 = p1 - c,
v2 = p2 - c,
r = abs(corner.z),
a = acos((v1 * v2) / sqr(r))) r ? PI * (cross(v1, v2) <= 0 ? a : 360 - a) * r / 180 : 0]
)
sumv(concat(straights, arcs));
arcs = rounded_polygon_arcs(points, tangents)
) sumv( map( concat(tangents, arcs), function(e) e[2] ) );
module rounded_polygon(points, _tangents = undef) { //! Draw the rounded polygon from the point list, can pass the tangent list to save it being calculated
len = len(points);
indices = [0 : len - 1];
tangents = _tangents ? _tangents : rounded_polygon_tangents(points);
tangents = [ for (t = _tangents ? _tangents : rounded_polygon_tangents(points)) each [t.x, t.y] ];
difference(convexity = points) {
union() {
@@ -74,6 +84,7 @@ module rounded_polygon(points, _tangents = undef) { //! Draw the rounded polygon
hull() {
translate([points[i].x, points[i].y])
circle(points[i][2]);
polygon([tangents[(2 * i - 1 + 2 * len) % (2 * len)], tangents[2 * i], [points[i].x, points[i].y]]);
}
@@ -85,7 +96,7 @@ module rounded_polygon(points, _tangents = undef) { //! Draw the rounded polygon
translate([points[i].x, points[i].y])
circle(-points[i][2]);
polygon([tangents[(2 * i - 1 + 2 * len) % (2 *len)], tangents[2 * i], [points[i].x, points[i].y]]);
polygon([tangents[(2 * i - 1 + 2 * len) % (2 * len)], tangents[2 * i], [points[i].x, points[i].y]]);
}
}
}

View File

@@ -18,19 +18,29 @@
//
//
//! Models timing belt running over toothed or smooth pulleys and calculates an accurate length.
//! Only models 2D paths, so not crossed belt core XY!
//! Models timing belt running in a path over toothed or smooth pulleys and calculates an accurate length.
//! Only models 2D paths, belt may twist to support crossed belt core XY and other designes where the belt twists!
//!
//! By default the path is a closed loop. An open loop can be specified by specifying `open=true`, and in that case the start and end points are not connected, leaving the loop open.
//!
//! To get a 180 degree twist of the loop, you can use the `twist` argument. `Twist` can be a single number, and in that case the belt will twist after
//! the position with that number. Alternatively `twist` can be a list of boolean values with a boolean for each position; the belt will then twist after
//! the position that have a `true` value in the `twist` list. If the path is specified with pulley/idler types, then you can use `auto_twist=true`; in
//! that case the belt will automatically twist so the back of the belt always runs against idlers and the tooth side runs against pullies. If you use
//! `open=true` then you might also use `start_twist=true` to let the belt start the part with the back side out.
//!
//! The path must be specified as a list of positions. Each position should be either a vector with `[x, y, pulley]` or `[x, y, r]`. A pully is a type from
//! `pulleys.scad`, and correct radius and angle will automatically be calculated. Alternatively a radius can be specified directly.
//!
//! 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.
//! Alternativley you can just specify smooth pulleys in the path, and it will then happen automatically.
//!
//! 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>
use <pulley.scad>
function belt_pitch(type) = type[1]; //! Pitch in mm
function belt_width(type) = type[2]; //! Width in mm
@@ -41,47 +51,102 @@ function belt_pitch_height(type) = type[5] + belt_tooth_height(type); //! Offset
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_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
module belt(type, points, belt_colour = grey(20), tooth_colour = grey(50), open = false, twist = undef, auto_twist = false, start_twist = false) { //! Draw a belt path given a set of points and pitch radii where the pulleys are. Closed loop unless open is specified
width = belt_width(type);
pitch = belt_pitch(type);
thickness = belt_thickness(type);
info = _belt_points_info(type, points, open, twist, auto_twist, start_twist);
dotwist = info[0]; // array of booleans, true if a twist happen after the position
twisted = info[1]; // array of booleans, true if the belt is twisted at the position
pointsx = info[2]; // array of [x,y,r], r is negative if left-angle (points may have pulleys as third element, but pointsx have radi)
tangents = info[3];
arcs = info[4];
length = ceil(_belt_length(info, open) / pitch) * pitch;
part = str(type[0],pitch);
vitamin(str("belt(", no_point(part), "x", width, ", ", points, arg(gap, 0), arg(gap_pos, undef), "): Belt ", part," x ", width, "mm x ", length, "mm"));
vitamin(str("belt(", no_point(part), "x", width, ", ", pointsx, "): Belt ", part," x ", width, "mm x ", length, "mm"));
len = len(points);
tangents = rounded_polygon_tangents(points);
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_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);
ph = belt_pitch_height(type);
module beltp() translate([ph - th, -width / 2]) square([th, width]);
module beltb() translate([ph - thickness, -width / 2]) square([thickness - th, width]);
color(belt_colour)
linear_extrude(width, center = true)
difference() {
offset(-ph + thickness ) shape();
offset(-ph + th) shape();
gap();
}
for (i = [0 : len - (open ? 2 : 1)]) {
p1 = tangents[i].x;
p2 = tangents[i].y;
v = p2-p1;
a = atan(v.y / v.x) - (v.x < 0 ? 180 : 0); //a2(p2-p1);
l = norm(v);
translate(p1) rotate([-90, 0, a - 90]) {
twist = dotwist[i] ? 180 : 0;
mirrored = twisted[i] ? 1 : 0;
color(tooth_colour) linear_extrude(l, twist = twist) mirror([mirrored, 0, 0]) beltp();
color(belt_colour) linear_extrude(l, twist = twist) mirror([mirrored, 0, 0]) beltb();
}
}
color(tooth_colour)
linear_extrude(width, center = true)
difference() {
offset(-ph + th) shape();
offset(-ph) shape();
gap();
}
for (i = [(open ? 1 : 0) : len - (open ? 2 : 1)]) {
p = pointsx[i];
arc = arcs[i];
translate([p.x, p.y]) rotate([0, 0, arc[1]]) {
mirrored = xor(twisted[i], p[2] < 0) ? 0 : 1;
color(tooth_colour) rotate_extrude(angle = arc[0]) translate([abs(p[2]), 0, 0]) mirror([mirrored, 0, 0]) beltp();
color(belt_colour) rotate_extrude(angle = arc[0]) translate([abs(p[2]), 0, 0]) mirror([mirrored, 0, 0]) beltb();
}
}
}
function belt_length(points, gap = 0) = rounded_polygon_length(points, rounded_polygon_tangents(points)) - gap; //! Compute belt length given path and optional gap
function _belt_points_info(type, points, open, twist, auto_twist, start_twist) = //! Helper function that calculates [twist, istwisted, points, tangents, arcs]
let(
len = len(points),
isleft = function(i) let(
p = vec2(points[i]),
p0 = vec2(points[(i - 1 + len) % len]),
p1 = vec2(points[(i + 1) % len])
) cross(p-p0,p1-p) > 0,
dotwist = function(i, istwisted) let( in = (i + 1) % len )
is_list(twist) ? twist[i] :
!is_undef(twist) ? i == twist :
open && is_list(points[in][2]) && auto_twist ? !pulley_teeth(points[in][2]) && !xor(isleft(in), istwisted) :
false,
twisted = [
for (
i = 0,
istwisted = start_twist,
twist = dotwist(i, istwisted),
nexttwisted = xor(twist, istwisted);
i < len;
i = i + 1,
istwisted = nexttwisted,
twist = dotwist(i, istwisted),
nexttwisted = xor(twist, istwisted)
) [twist, istwisted] ],
pointsx = mapi(points, function(i, p) !is_list(p[2]) ? p : [p.x, p.y, let( // if p[2] is not a list it is just r, otherwise it is taken to be a pulley and we calculate r
isleft = isleft(i),
r = belt_pulley_pr(type, p[2], twisted = !xor(pulley_teeth(p[2]), xor(isleft, twisted[i][1])))
) isleft ? -r : r ] ),
tangents = rounded_polygon_tangents(pointsx),
arcs = rounded_polygon_arcs(pointsx, tangents)
) [ [ for (t = twisted) t[0] ], [ for (t = twisted) t[1] ], pointsx, tangents, arcs];
function belt_pulley_pr(type, pulley, twisted=false) = //! Pitch radius. Default it expects the belt tooth to be against a toothed pulley an the backside to be against a smooth pulley (an idler). If `twisted` is true, the the belt is the other way around.
let(
thickness = belt_thickness(type),
ph = belt_pitch_height(type)
) pulley_teeth(pulley)
? pulley_pr(pulley) + (twisted ? thickness - ph : 0 )
: pulley_ir(pulley) + (twisted ? ph : thickness - ph );
function belt_length(type, points, open = false) = _belt_length(_belt_points_info(type, points, open), open); //! Compute belt length given path
function _belt_length(info, open) = let(
len = len(info[0]),
d = open ? 1 : 0,
tangents = slice(info[3], 0, len - d) ,
arcs = slice(info[4], d, len - d)
) sumv( map( concat(tangents, arcs), function(e) e[2] ));

View File

@@ -62,6 +62,7 @@ function opengrab_depth() = depth; //! Module heig
function opengrab_target_thickness() = target; //! Target sheet thickness
function opengrab_pcb() = pcb; //! The PCB
function opengrab_pcb_z() = depth - pillar - pcb_thickness(pcb); //! PCB offset from the front
function opengrab_screw_depth() = 4; //! Max screw depth in pillars
module opengrab() { //! Draw OpenGrab module
vitamin("opengrab(): OpenGrab V3 electro permanent magnet");

View File

@@ -42,7 +42,7 @@ function pulley_screw(type) = type[13]; //! Grub screw type
function pulley_screws(type) = type[14]; //! Number of grub screws
function pulley_ir(type) = pulley_od(type) / 2 - (pulley_teeth(type) ? belt_tooth_height(pulley_belt(type)) : 0); //! Inside radius of the teeth
function pulley_pr(type) = let(belt = pulley_belt(type)) //! Pitch radius
function pulley_pr(type, belt = undef) = let(belt = is_undef(belt) ? pulley_belt(type) : belt) //! Pitch radius, `belt` only needed for non-standard belt over smooth pulleys
pulley_teeth(type) ? pulley_teeth(type) * belt_pitch(belt) / 2 / PI
: pulley_ir(type) + belt_thickness(belt) - belt_pitch_height(belt);

View File

@@ -284,10 +284,10 @@ function screw_polysink_r(type, z) = //! Countersink hole profile corrected for
)
limit(head_rad + head_t - z + (sqrt(2) - 1) * layer_height / 2, screw_clearance_radius(type), head_rad);
module screw_polysink(type, h = 100, alt = false) { //! A countersink hole made from stacked polyholes for printed parts
module screw_polysink(type, h = 100, alt = false, sink = 0) { //! A countersink hole made from stacked polyholes for printed parts, default is flush, `sink` can be used to recess the head
head_depth = screw_head_depth(type);
assert(head_depth, "Not a countersunk screw");
layers = ceil(head_depth / layer_height);
layers = ceil((head_depth + sink) / layer_height);
rmin = screw_clearance_radius(type);
sides = sides(rmin);
lh = layer_height + eps;
@@ -295,7 +295,7 @@ module screw_polysink(type, h = 100, alt = false) { //! A countersink hole made
for(side = [0, 1]) mirror([0, 0, side]) {
for(i = [0 : layers - 1])
translate_z(i * layer_height) {
r = screw_polysink_r(type, i * layer_height + layer_height / 2);
r = screw_polysink_r(type, i * layer_height + layer_height / 2 - sink);
if(alt)
rotate(i % 2 == layers % 2 ? 180 / sides : 0)
poly_cylinder(r = r, h = lh, center = false, sides = sides);

View File

@@ -79,6 +79,7 @@ M2_cs_cap_screw = ["M2_cs_cap","M2 cs cap", hs_cs_cap,2, 3.8, 0, 0.65,1.3
M3_cs_cap_screw = ["M3_cs_cap","M3 cs cap", hs_cs_cap,3, 6.0, 0, 1.05,2.0, 18, M3_washer, M3_nut, M3_tap_radius, M3_clearance_radius];
M4_cs_cap_screw = ["M4_cs_cap","M4 cs cap", hs_cs_cap,4, 8.0, 0, 1.49,2.5, 20, M4_washer, M4_nut, M4_tap_radius, M4_clearance_radius];
M5_cs_cap_screw = ["M5_cs_cap","M5 cs cap", hs_cs_cap,5,10.0, 0, 3.00,3.0, 22, M5_washer, M5_nut, M5_tap_radius, M5_clearance_radius];
M6_cs_cap_screw = ["M6_cs_cap","M6 cs cap", hs_cs_cap,6,12.0, 0, 3.00,4.0, 24, M6_washer, M6_nut, M6_tap_radius, M6_clearance_radius];
M2_dome_screw = ["M2_dome", "M2 dome", hs_dome, 2, 3.5, 1.3, 0.6, 1.3, 16, M2_washer, M2_nut, M2_tap_radius, M2_clearance_radius];
M3_dome_screw = ["M3_dome", "M3 dome", hs_dome, 3, 5.7, 1.65, 1.04,2.0, 18, M3_washer, M3_nut, M3_tap_radius, M3_clearance_radius];
@@ -109,12 +110,12 @@ No6_screw = ["No6", "No6 pan wood", hs_pan, 3.5, 6.7, 2.2, 0, 0
No6_cs_screw = ["No6_cs", "No6 cs wood", hs_cs, 3.5, 7.0, 0, 0, 0, 0, M4_washer, false, No6_pilot_radius, No6_clearance_radius];
screw_lists = [
[ M2_cap_screw, M2p5_cap_screw, M3_cap_screw, M4_cap_screw, M5_cap_screw, M6_cap_screw, M8_cap_screw],
[ M2_cap_screw, M2p5_cap_screw, M3_cap_screw, M4_cap_screw, M5_cap_screw, M6_cap_screw, M8_cap_screw],
[ 0, 0, M3_low_cap_screw],
[ M2_cs_cap_screw, 0, M3_cs_cap_screw, M4_cs_cap_screw, M5_cs_cap_screw],
[ M2_cs_cap_screw, 0, M3_cs_cap_screw, M4_cs_cap_screw, M5_cs_cap_screw, M6_cs_cap_screw],
[ M2_dome_screw, 0, M3_dome_screw, M4_dome_screw, M5_dome_screw],
[ 0, 0, M3_hex_screw, M4_hex_screw, M5_hex_screw, M6_hex_screw, M8_hex_screw],
[ 0, M2p5_pan_screw, M3_pan_screw, M4_pan_screw, M5_pan_screw, M6_pan_screw, No632_pan_screw],
[ 0, 0, M3_hex_screw, M4_hex_screw, M5_hex_screw, M6_hex_screw, M8_hex_screw],
[ 0, M2p5_pan_screw, M3_pan_screw, M4_pan_screw, M5_pan_screw, M6_pan_screw, No632_pan_screw],
[ No2_screw, 0, No4_screw, No6_screw, No6_cs_screw],
[ 0, 0, M3_grub_screw, M4_grub_screw]
];