The default MPCNC configuration wires the two stepper motors on each axis in series, doubling the total resistance and inductance of a single motor. The stock Automation Technology motor presents 2.8 Ω and 4.8 mH in each winding to the driver, for an L/R time constant of τ = 1.7 ms. Doubling both doesn’t change the ratio, but including the harness wiring resistance gives 1.6 ms = 9.6 mH / 6 Ω.
The default DRV8825 driver configuration uses 1:32 microstepping, which I thought was excessive. I replaced the stock RAMPS setup with a Protoneer / GRBL setup using A4988 drivers in 1:16 microstepping mode, got it configured, and made a few measurements:
The current probe measures the winding current in the red wire. The voltage probe at the bottom isn’t doing anything, because I ran out of hands.
Here’s a 10 mm X axis move at 3600 mm/min = 60 mm/s:
The top trace shows the winding current at 500 mA/div. The bottom trace shows the voltage applied to the winding at the A4988 driver pin.
Basically, the +12 V supply doesn’t provide enough headroom to let the driver force the required current into the winding at full speed, which is why the peak current decreases as the step rate increases and the sinusoid becomes a square(-ish) wave. The applied voltage switches rapidly to maintain the proper winding current when the axis is stationary or moving slowly (where the driver’s PWM current control works fine), but turns into a square (well, rectangular) wave as the pace picks up (and the driver loses control of the current).
The motor drives a 16 tooth pulley with a 2 mm belt pitch, so each revolution moves 32 mm of belt. With 1:16 microstepping, each revolution requires 3200 = 200 full step × 16 microstep/step pulses, which works out to 100 step/mm = (3200 step/rev) / (32 mm/rev). At the commanded speed near the middle of the trace, the driver must produce 6000 step/s = 60 mm/s × 100 step/mm, so each step lasts 167 μs, about τ/10.
In round numbers, the first full cycle on the left has a 20 ms period. Each full cycle = 4 full steps = 64 microsteps, so the belt moved (60 step) / (100 step/mm) = 0.6 mm, at an (average) speed of 30 mm/s = 1800 mm/min. The current begins to fall off by the third cycle with a 12 ms period, a pace of 50 mm/s = 3000 mm/s, and pretty much falls off a cliff by 60 mm/s in the middle.
To be fair, those are aggressive speeds for milling, but lasers and 3D printers tick along pretty quickly, so they’re not unreasonable.
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:
Now, to be fair, the MPCNC hasn’t yet done any useful work, but it moves.
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 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=6000 seem aggressive, although they actually work so far.
The accelerations in $12 may push the motors too hard with anything installed in the toolholder.
The travel limits in $13 depend on the rail lengths you used.
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:
The solution / workaround requires a tweak to /boot/config.txt:
#-- boost USB current for Arduino CNC
# 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.
A reader (you know who you are!) proposed an interesting project that will involve measuring audio passbands and suggested using white noise to show the entire shape on a spectrum analyzer. He pointed me at the NOISE 1B Noise Generator based on a PIC microcontroller, which led to trying out the same idea on an Arduino.
The first pass used the low bit from the Arduino runtime’s built-in random() function:
Well, that’s a tad pokey for audio: 54 μs/bit = 18.5 kHz. Turns out they use an algorithm based on multiplication and division to produce nice-looking numbers, but doing that to 32 bit quantities takes quite a while on an 8 bit microcontroller teleported from the mid 1990s.
The general idea is to send a bit from the end of a linear feedback shift register to an output to produce arandomly switching binary signal. Because successive values involve only shifts and XORs, it should trundle along at a pretty good clip and, indeed, it does:
I used the Galois optimization, rather than a traditional LFSR, because I only need one random bit and don’t care about the actual sequence of values. In round numbers, it spits out bits an order of magnitude faster at 6 μs/bit = 160 kHz.
The spectrum looks pretty good, particularly if you’re only interested in the audio range way over on the left side:
It’s down 3 dB at 76 kHz, about half the 160 kHz bit flipping pace.
If you were fussy, you’d turn off the 1 ms timer interrupt to remove a slight jitter in the output.
It’s built with an old Arduino Pro Mini wired up to a counterfeit FTDI USB converter. Maybe this is the best thing I can do with it: put it in a box with a few audio filters for various noise colors and be done with it.
It occurs to me I could fire it into the 60 kHz preamp’s snout to measure the response over a fairly broad range while I’m waiting for better RF reception across the continent.
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:
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.
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.
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:
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:
After perusing the geometric / triangle solution, this came closer: