Advertisements

Posts Tagged CNC

MPCNC: GRBL Configuration

This collection of GRBL settings gets the MPCNC hardware up and running:

Conveniently, the $$ command (in the first line) produces output in exactly the format it will accept as input, so just pour the captured file into GRBL’s snout. I used ascii-xfr with a 250 ms line delay:

ascii-xfr -s -v -l 250 MPCNC-GRBL.cfg > /dev/ttyACM0

Now, to be fair, the MPCNC hasn’t yet done any useful work, but it moves.

Notes:

Setting $22=1 requires home switches to be installed and working, with $23=7 putting them on the negative end of the axes, which may not work well in practice. In particular, having the Z axis homing downward is just plain dumb.

The step/mm values in $10[012] require 1/16 microstepping with 2 mm belts on 16 tooth motor pulleys. The MPCNC’s Marlin config uses 1/32 microstepping, which doubles the step frequencies and (IMO) doesn’t provide any tangible benefit.

The speeds in $11[012]=6000 seem aggressive, although they actually work so far.

The accelerations in $12[012] may push the motors too hard with anything installed in the toolholder.

The travel limits in $13[012] depend on the rail lengths you used.

Advertisements

, ,

4 Comments

Makerbot-style Endstop Power Adapter for Protoneer Arduino CNC Shield

The Protoneer Arduino CNC shield (*) has a row of 2-pin headers for bare endstop switches. Being a big fan of LED Blinkiness, I have a stock of 3-pin Makerbot-style mechanical endstops that require a +5 V connection in addition to ground and the output.

A crude-but-effective adapter consists of half a dozen header pins soldered to a length of stout copper wire, with a pigtail to a +5 V pin elsewhere on the board:

3-pin to 2-pin Endstop Power Adapter

3-pin to 2-pin Endstop Power Adapter

A closer look:

3-pin to 2-pin Endstop Power Adapter - detail

3-pin to 2-pin Endstop Power Adapter – detail

The pins get trimmed on the other side of the bus wire, because they don’t go through the PCB.

Installed on the board, it doesn’t look like much:

3-pin endstop adapter on Prontoneer board

3-pin endstop adapter on Prontoneer board

Looks like it needs either Kapton tape or epoxy, doesn’t it?

Three more endstops at the far end of the MPCNC rails (for hard limits) will fill the unused header pins.

(*) It’s significantly more expensive than the Chinese knockoffs, but in this case I cheerfully pay to support the guy: good stuff, direct from the source.

, , ,

5 Comments

Raspberry Pi USB vs. Arduino

Plugging an Arduino with GRBL into a USB port on a Raspberry Pi 3 with bCNC causes an immediate crash: the Arduino doesn’t power up and the Raspberry Pi stops responding. A hardware reset / power cycle with the Arduino plugged in doesn’t improve the situation, so it seems the Arduino draws more current from the USB port than the default setup will allow.

Most likely, the Arduino’s 47 μF power supply caps draw too much current while charging, as the steady-state current seems to be around 40 mA:

RPi vs Arduino - USB current

RPi vs Arduino – USB current

The solution / workaround requires a tweak to /boot/config.txt:

#-- boost USB current for Arduino CNC

max_usb_current=1

# blank line above to reveal underscores

Update: As mentioned in the comments, the max_usb_current option doesn’t apply to the Pi 3 you see in the picture and, thus, shouldn’t have changed anything. Your guess is as good as mine.

I’d be more comfortable with a separate power supply plugged into the Arduino’s coaxial power jack, but that’s just me.

, , ,

2 Comments

Mostly Printed CNC: Endstop Mount

Being a big fan of having a CNC machine know where it is, adding endstops (pronounded “home switches” in CNC parlance) to the Mostly Printed CNC axes seemed like a good idea:

MPCNC - X min endstop - actuator view

MPCNC – X min endstop – actuator view

All the mounts I could find fit bare microswitches of various sizes or seemed overly complex & bulky for what they accomplished. Rather than fiddle with screws and nut traps / inserts, a simple cable tie works just fine and makes the whole affair much smaller. Should you think cable ties aren’t secure enough, a strip of double stick tape will assuage your doubts.

A snippet of aluminum sheet moves the switch trip point out beyond the roller’s ball bearing:

MPCNC - X min endstop

MPCNC – X min endstop

I’m not convinced homing the Z axis at the bottom of its travel is the right thing to do, but it’s a start:

MPCNC - Z min endstop

MPCNC – Z min endstop

Unlike the stationary X and Y axes, the MPCNC’s Z axis rails move vertically in the middle block assembly; the switch moves downward on the rail until the actuator hits the block.

Perforce, the tooling mounted on the Z axis must stick out below the bottom of the tool carrier, which means the tool will hit the table before the switch hits the block. There should also be a probe input to support tool height setting.

The first mount fit perfectly, so I printed four more in one pass:

MPCNC MB Endstop Mounts - Slic3r preview

MPCNC MB Endstop Mounts – Slic3r preview

All three endstops plug into the RAMPS board, leaving the maximum endstop connections vacant:

MPCNC - RAMPS min endstop positions

MPCNC – RAMPS min endstop positions

Obviously, bare PCBs attached to the rails in mid-air aren’t compatible with milling metal, which I won’t be doing for quite a while. The electronic parts long to be inside enclosures with ventilation and maybe dust filtering, but …

The switches operate in normally open mode, closing when tripped. That’s backwards, of course, and defined to be completely irrelevant in the current context.

Seen from a high level, these switches set the absolute “machine coordinate system” origin, so the firmware travel limits can take effect. Marlin knows nothing about coordinate systems, but GRBL does: it can touch off to a fixture origin and generally do the right thing.

The OpenSCAD source code as a GitHub Gist:

, ,

4 Comments

Mostly Printed CNC: Mechanical Build

A Mostly Printed CNC machine from Vicious1 provides an easily configured platform for low-force CNC activities like plotting, vinyl cutting, PCB milling, and maybe wood / plastic / wax routing with a suitable dust vacuum / downdraft table / enclosure. Despite many videos, the notion of open-air laser cutting remains a non-starter around here.

I opted for the Parts Bundle (all the “vitamins” required, from RAMPS controller to locknuts, to assemble the machine) and the Printed Parts Bundle (all the printed components), then picked up four 10 foot lengths of 3/4 inch ID = 23.5 mm OD galvanized steel conduit locally. Yes, I have a 3D printer, but the notion of feeding two spools of plastic through it over the course of 100++ printing hours, plus figuring out how to get the tolerances right, convinced me to regard this as a kit project, not a design-and-build project.

The first trial assembly atop a new workbench went reasonably smoothly:

Mostly Printed CNC - construction overview

Mostly Printed CNC – construction overview

I missed the step where you must put the high rails parallel to the X axis, which I want along the length of the table, and had to disassemble and rebuilt the frame to rotate the Middle Assembly a quarter turn clockwise. It’s always easier the second (or third) time and, if you regard the first few passes as dry runs / learning experiences, the process can be soothing, rather than annoying.

A laser rangefinder dramatically simplifies squaring and de-skewing the rails:

MPCNC - Laser rail measurement

MPCNC – Laser rail measurement

I wanted 24+ inches along the X axis and  18+ inches along the Y, so as to handle stock sizes with hard-inch measurements.The current MPCNC design adds about 11 inches to each axis outside the work area, which makes the footprint 35 × 29 (-ish) inches overall. The bench measures 30 inches front-to-back, I allowed an inch along the front to recess the moving parts, and the final frame measures 37+ × 30+ inches to the outside of all the gadgetry.

Within that footprint, the laser says the rails are 845  × 674 mm = 33 × 26+ inch apart, giving a work area of 640 × 475 mm = 25+ × 19- inch.

After some careful surveying, I marked / punched / drilled holes for each mounting foot, then counterdrilled brass inserts on the bottom for that nice clean look:

MPCNC - Table anchors

MPCNC – Table anchors

The screws came out flush when mounted atop washers:

MPCNC - Corner Assembly

MPCNC – Corner Assembly

My “careful surveying” produced a 1 mm error over the internal 1 meter diagonal, but a bit of judicious hole filing let me squash the long diagonal and stretch the short one by Just Enough to make the answer come out right, at least according to the laser rangefinder.

Setting the rail height goes more easily with a height gauge:

MPCNC - Rail height measurement

MPCNC – Rail height measurement

Stipulated: the absurdity of a height gauge on a plywood tabletop. On the other paw, the corner posts rest on that same plywood, so it actually works pretty well. I slowly pried the three lowest caps upward with the Big Screwdriver, levered on a wood block, to set all the rails to the same height as the highest one.

The X axis rails may need mid-rail supports, although I don’t see any meaningful deflection right now.

One could mount a T-nut atop the table inside each foot (and the center brace, as needed), with a long-ish bolt (head below the table) pushing the corner joint upward, which might be more stable than the current plastic-on-steel compression grip.

The steppers mount on rollers gripping the rail with six bearings, plus two more bending the GT2 drive belt (not installed yet) upward to the motor drive pulley:

MPCNC - Stepper on Roller

MPCNC – Stepper on Roller

I devoted a few quiet hours to threading four-wire cables through 6 mm PET braided sleeves, in hope of protecting the PVC insulation from the usual abrasion & bending stresses. I have some drag chains which may come in handy, although they seem overly klunky for the purpose.

I’m not entirely convinced a PLA stepper mount is a Good Thing, given the warmth of steppers and PLA’s 60 °C glass transition temperature. We’ll see how it goes; obviously, one should not leave PLA parts in one’s car during a hot summer afternoon, either.

The neatly sheathed stepper cable vanishes into the center rail held firmly by the stepper mount. An identical stepper mount grips the other end of the rail, with the motors wired in series. The conduits provide a tidy way to pass wires along the length and width of the frame.

After you install and tension the belts, tweak the pulley location so the 6 mm belt tracks more-or-less in the middle of the 9 mm tooth width:

MPCNC - Stepper belt alignment

MPCNC – Stepper belt alignment

The hulking Middle Assembly grips the X and Y cross bars:

MPCNC - Middle Assembly

MPCNC – Middle Assembly

It has six printed parts, three each in two matching pairs, 24 bearings in eight triples, and plenty of 5/16 inch bolts + locknuts holding it together: all the metal bits make it weigh a lot more than you’d expect.

The Z axis rails fit into the two pairs of three bearings facing you:

MPCNC - Correct Mid-Assembly orientation

MPCNC – Correct Mid-Assembly orientation

You’ll note the correct Middle Assembly orientation, after I rearranged the frame with the high rails along the X axis. Home switches will eventually fit neatly on the untraveled rail sections near the front-left corner post.

I built the Z using the default 12 inch rails called out by the Cut Calculator (metric version), which left an inch of the leadscrew sticking out beyond the bottom of the rails:

MPCNC - Z leadscrew - 12 inch rails

MPCNC – Z leadscrew – 12 inch rails

I left the work height at the default 4 inches, which specifies a minimum 7 inch = 175 mm leadscrew. The actual leadscrew is 300 mm = 8 inch, which completely explains the situation. I’ll rebuilt the Z axis with longer rails, but this suffices for now.

The concave silvery part joining the Z axis struts is the tool mount, to which you screw a tool holder:

MPCNC - Pen Holder Detail

MPCNC – Pen Holder Detail

That’s the Official Drag Knife / Pen Holder, generally seen with a Sharpie ziptied in place, but I have Real Plotter Pens, dammit, and I’m going to use them! The holder has one hole dangling to put the pen nib below the end of the leadscrew.

All in all, I like it …

 

,

2 Comments

RAMPS 1.4: Simulated Heater

Epoxying a 100 kΩ thermistor to a 909 Ω resistor (because I have a bunch of them) serves as a simple heater tester:

Simulated heater - thermistor bonding

Simulated heater – thermistor bonding

It dissipates 450 mW, raising the temperature enough to let the PWM control kick in, but not enough to get scary hot.

Some heatstink tubing prevents reduces the likelihood of horrible accidents involving the 20 V motor / heater power supply:

RAMPS 1.4 - Simulated heaters

RAMPS 1.4 – Simulated heaters

Keeping it under 50 °C seems like a Good Idea:

RAMPS 1.4 - Simulated heater - LCD

RAMPS 1.4 – Simulated heater – LCD

Not that I have a need to heat anything, but the MOSFETs work!

 

 

, ,

4 Comments

Two-Wheel Plotter

While contemplating all the hocus-pocus and precision alignment involved in the DIY plotter project, it occurred to me you could conjure a plotter from a pair of steppers, two disks, a lifting mechanism, and not much else. The general idea resembles an Rθ plotter, with the paper glued to a turntable for the “theta” motion, but with the “radius” motion produced by pen(s) on another turntable:

Rotary Plotter - geometry 4

Rotary Plotter – geometry 4

The big circle is the turntable with radius R1, which might be a touch over 4.5 inches to fit an 8.5 inch octagon cut from ordinary Letter paper. The arc with radius R2 over on the right shows the pen path from the turntable’s center to its perimeter, centered at (R1/2,-R1) for convenience.

The grid paper represents the overall Cartesian grid containing the XY points you’d like to plot, like, for example, point Pxy in the upper right corner. The object of the game is to figure out how to rotate the turntable and pen holder to put Pxy directly under the pen at Ixy over near the right side, after which one might make a dot by lowering the pen. Drawing a continuous figure requires making very small motions between closely spaced points, using something like Bresenham’s line algorithm to generate the incremental coordinates or, for parametric curves like the SuperFormula, choosing a small parameter step size.

After flailing around for a while, I realized this requires finding the intersections of two circles after some coordinate transformations.

The offset between the two centers is (ΔX,ΔY) and the distance is R2 = sqrt(ΔX² + ΔY²).  The angle between the +X axis and the pen wheel is α = atan2(ΔY,ΔX), which will be negative for this layout.

Start by transforming Pxy to polar coordinates PRθ, which produces the circle containing both Pxy and Ixy. A pen positioned at radius R from the center of the turntable will trace that circle and Ixy sits at the intersection of that circle with the pen rotating around its wheel.

The small rectangle with sides a and b has R as its diagonal, which means a² + b² = R² and the pointy angle γ = atan a/b.

The large triangle below that has base (R2 – a), height b, and hypotenuse R2, so (R2 – a)² + b² = R2².

Some plug-and-chug action produces a quadratic equation that you can solve for a as shown, solve for b using the first equation, find γ from atan a/b, then subtract γ from θ to get β, the angle spearing point Ixy. You can convert Rβ back to the original grid coordinates with the usual x = R cos β and y = R sin β.

Rotate the turntable by (θ – β) to put Pxy on the arc of the pen at Ixy.

The angle δ lies between the center-to-center line and Ixy. Knowing all the sides of that triangle, find δ = arccos (R2 – a) / R2 and turn the pen wheel by δ to put the pen at Ixy.

Lower the pen to make a dot.

Done!

Some marginal thinking …

I’m sure there’s a fancy way to do this with, surely, matrices or quaternions, but I can handle trig.

You could drive the steppers with a Marlin / RAMPS controller mapping between angles and linear G-Code coordinates, perhaps by choosing suitable steps-per-unit values to make the degrees (or some convenient decimal multiple / fraction thereof) correspond directly to linear distances.

You could generate points from an equation in, say, Python on a Raspberry Pi, apply all the transformations, convert the angles to G-Code, and fire them at a Marlin controller over USB.

Applying 16:1 microstepping to a stock 200 step/rev motor gives 0.113°/step, so at a 5 inch radius each step covers 0.01 inch. However, not all microsteps are moved equally and I expect the absolute per-step accuracy would be somewhere between OK and marginal. Most likely, given the application, even marginal accuracy wouldn’t matter in the least.

The pen wheel uses only 60-ish degrees of the motor’s rotation, but you could mount four-ish pens around a complete wheel, apply suitable pen lift-and-lower action and get multicolor plots.

You could gear down the steppers to get more steps per turntable revolution and way more steps per pen arc, perhaps using cheap & readily available RepRap printer GT2 pulleys / belts / shafts / bearings from the usual eBay sellers. A 16 tooth motor pulley driving a 60 tooth turntable pulley would improve the resolution by a factor of 3.75: more microsteps per commanded motion should make the actual motion come out better.

Tucking the paper atop the turntable and under the pen wheel could be a challenge. Perhaps mounting the whole pen assembly on a tilting plate would help?

Make all the workings visible FTW!

Some doodles leading up to the top diagram, complete with Bad Ideas and goofs …

Centering the pen wheel at a corner makes R2 = R1 * sqrt(2), which seems attractive, but seems overly large in retrospect:

Rotary Plotter - geometry 1

Rotary Plotter – geometry 1

Centering the pen wheel at (-R1,R1/2) with a radius of R1 obviously doesn’t work out, because the arc doesn’t reach the turntable pivot, so you can’t draw anything close to the center. At least I got to work out some step sizes.

A first attempt at coordinate transformation went nowhere:

Rotary Plotter - geometry 2

Rotary Plotter – geometry 2

After perusing the geometric / triangle solution, this came closer:

Rotary Plotter - geometry 3

Rotary Plotter – geometry 3

, ,

7 Comments