Posts Tagged CNC
Arduino Leonardo + TC4 Thermocouple Shield + TC4 Server
Posted by Ed in Electronics Workbench, Machine Shop, Software on 16-May-2013
Because I want to measure several fairly high temperatures in and around the extruder with the LinuxCNC controller for the M2, I need a multi-channel thermocouple input. LinuxCNC’s hal_input interface module exposes the values produced by USB HID peripherals as HAL pins, which seems to be a nice way to add devices. A bit of searching revealed the TC4 Arduino Shield four-channel thermocouple + four-channel thermistor + assorted I/O board produced by the homeroasters.org folks as part of their DIY coffee roast controller.
The gotcha: ordinary Arduino boards cannot (without extraordinary effort) become USB HID peripherals, as their USB interface works only as a serial data device. The solution: the new-ish Arduino Leonardo has an on-chip USB interface that can act as a USB HID peripheral as well as the usual serial device.
Dan Newman, of Sailfish firmware fame, conjured up an a Arduino program (which, IMO, is far more complex than a mere sketch) that provides both a human-readable terminal interface and a LinuxCNC HAL-compatible USB HID interface using the Leonardo’s USB capabilities; the TC4Server project repository is on my GitHub account to keep it close to all the other stuff that should appear over the course of this project. His firmware builds on the libraries for the homeroaster’s tc4-shield Google Code project, but is intended for use with LinuxCNC, rather than as part of an Arduino controller.
It’s worth noting that the Leonardo has a mere 32 kB of program storage, so the extensive help documentation built into the program helped prevent feature creep.
Although I’m not yet using LinuxCNC with the M2, I can use TC4-Server’s serial terminal interface to read four channels of thermocouple data to help figure out what’s going on with the M2′s extruder thermistor. The TC4 shield has screw terminals for the thermocouples, but I also added a Proto ScrewShield board for thermistor resistors and easier connections:
The TC4 Shield PCB layout assumes it’s being used with the original Arduino series of boards that bring the I2C (aka I2C, IIC, etc) SDA and SCL signals out on the A4 and A5 analog input pins, respectively. The newer Leonardo board brings SDA and SCL out in a separate header, so you must hotwire them across the board. The green and blue wires (stripped from a ribbon cable) accomplish that purpose: they’re plugged into the new Leonardo header through bent male header pins and clamped into the ScrewShield terminals. This assumes the Leonardo’s A4 and A5 pins remain as inputs, which is true for Dan’s firmware. If you actually need those pins for analog inputs, then you must remove the header pins that interconnect the boards and hotwire directly to the TC4 headers.
The TC4 shield includes an on-board temperature sensor that serves as the thermocouple cold-junction compensation reference. In my simple tests, the board has about 1 °C of self-heating, so I also use it to report the ambient temperature.
With all that in hand, I connected the thermocouple epoxied to the M2′s nozzle to the TC4 and re-ran the previous test with the modified thermistor table:
The TC4 shield produces the same result as the Fluke meter with the same thermocouple, so we know those results will be consistent.
The modified thermistor table produces results that overlay thermocouple data. The questions come down to the accuracy of the thermocouple and whether bending the thermistor table actually represents an inherent property of the thermistor or just compensates for another problem.
Part of my motivation for using thermocouples, rather than thermistors, is that thermocouples avoid the whole dance of matching a given thermistor with a set of properties. Given the uncertain provenance of most thermistors, I have no reason to believe any of them match their alleged datasheets…
M2 vs. Marlin: Step/mm Calculations
Posted by Ed in Machine Shop, Science on 7-May-2013
After Dan Newman nudged me a bit in the comments to the Z axis calculations, I walked through the constants in Marlin’s Configuration.h file to see if they were all consistent. The earlier values sufficed to get going, but a bit of pondering suggested some tweaks.
The motor microstepping mode determines the number of (micro)steps per motor (single)step:
#define MICROSTEP16
That single constant implies all motors must run in the same microstepping mode. Typical stepper motors have 200 full step/rev = 1.8°/step, so 1/16 microstepping means 3200 step/rev.
However, each motor can have a different “gear” ratio that converts from motor rotation to linear distance, so you must measure or calculate the actual values.
For the X and Y axes, the motor pulleys have 18 teeth and the belt pitch is 2 mm/tooth, so one motor revolution drives the belt:
36 mm = 18 teeth * 2 mm/tooth
Each revolution requires 3200 steps, so the X and Y stages move at:
88.888 step/mm = 3200 step / 36 mm
Makergear uses 88.88 step/mm, rather than the rounded 88.89, but the difference across 250 mm amounts to 2.5 steps, so it doesn’t matter.
For the Z axis, the four-start leadscrew moves the stage 8 mm, so:
400 step/mm = 3200 step / 8 mm
The situation with the extruder drive isn’t quite so clear, because the actual filament movement depends on the effective diameter of the drive pulley’s teeth engaging the filament. Mechanically, the extruder motor runs a 5:1 gearbox, so each drive pulley rotation requires 16000 (micro)steps.
The filament drive pulley has 22 teeth and a 12.0 mm OD = 37.7 mm circumference:
424.4 step/mm = 16000 step / 37.7 mm
That’s measured at the tooth tip. If you think of the filament as being a belt, then you’d expect it to move precisely that distance… except that the teeth dig into the filament, so the effective diameter comes out a bit smaller and the step/mm value a bit higher.
Makergear’s default 471.5 step/mm is, indeed, larger, but the ratio of the two values seems both oddly familiar and eerily exact:
0.900 = 424.4 / 471.5
The “packing density” Fudge Factor (yclept extrusion multiplier by slic3r) that accounts for the difference between the drive gear OD and the actual filament motion runs around 0.9, with passionate arguments justifying more specific values. It looks like Makergear baked that number into the firmware, so the nominal slic3r extrusion multiplier should be pretty close to 1.0.
After a few quick measurements while getting the printer running, I settled on extrusion multiplier = 0.9, so the actual step/mm value in effect for the extruder works out to:
424.4 = (471.5 step/mm) * 0.9
Now, that would seem to imply that the filament skates along the top of teeth, but that’s not the case:
So, for whatever reason, the effective diameter of the drive pulley matches its actual OD. That will surely vary with a number of imponderables, including the setting for the clamp screw holding the bearing against the filament and drive pulley.
Being that type of guy, I favor baking the actual drive pulley OD into the firmware (because I can actually measure that value), then using the extrusion multiplier to account for the difference. I’ve heard cogent arguments to the contrary, but, for my purposes, the proper value for the extruder should 424.4 step/mm, with a corresponding extrusion multiplier change to 1.00 in slic3r’s configuration.
I wouldn’t be surprised in the least to discover:
- I’m multiplying where I should be dividing (or the other way around)
- There’s a squaring / rooting operation hidden somewhere in there (area vs length)
- Another obvious blunder has tripped me up
Selah.
Logitech Dual Action Gamepads: Mac vs. PC
Posted by Ed in Home Ec, Oddities, PC Tweakage, Software on 6-May-2013
Turns out that there’s no difference between the Mac and PC versions of the Logitech Dual Action Gamepad:
I picked up a Mac version cheap from the usual eBay seller and discovered that LinuxCNC / HAL was perfectly happy. That wasn’t too surprising; they have the same model and part numbers. Most likely, the only difference was the CD and maybe the Quick Start Guide that I didn’t get in the opened retail box…
So now I have either a hot backup for the Joggy Thing or one for a different box.
Most likely, it was cheap because nobody wants a blue-and-black peripheral next to their shiny white Mac…
Makergear M2: Z-minimum Switch
Posted by Ed in Machine Shop, Science on 29-April-2013
The best orientation for the Z-minimum switch seems to be slightly angled back:
I used an M4x0.7 socket head cap screw for the height adjustment, with a Nylock nut below the stage:
The assembly instructions show a hex head screw, but the item numbers don’t match the BOM listings. The SHCS lets me hold it firmly in position with the ball-end driver provided in the M2 tool kit while adjusting it:
- 1/4 turn (the handle is square-ish) = 0.7/4 = 0.175 mm
- 1/6 turn (the shaft is hex) = 0.12 mm
- 1/12 turn (you can do it!) = 0.06mm
- less than that is probably fooling yourself.
I printed a pair of tomlombardi’s 7 mm wrenches, which work well for adjusting the Nylock nut underneath the Z axis stage:
The left end of the top wrench didn’t adhere to the glass plate, but the business end of the wrench came out OK.
I adjusted the screw to trip the switch with the nozzle 1.0 mm above the platform, then feed that offset in using a G92 Z1.0 instruction in my customized Start G-Code.
However, the most accurate way to set the switch height involves measuring the as-printed thickness of the skirt extrusion around the object. The average value should be 0.25 mm (for my current slic3r settings, anyhow) and all sides should be equally thick: adjust the screw to change the average and adjust the platform screws to remove any tilt. You’ll quickly accumulate a pile of skirt threads, but they make good tchotchkes when you give a presentation on your new toy:
You could fiddle with the G92 value to make the average thickness come out right, but I favor making the machine as accurate as possible, so that the software begins from a known-good mechanical setting.
Makergear M2: Pronterface Configuration
Posted by Ed in Machine Shop, Software on 23-April-2013
I use Kliment’s Pronterface for printer control: simplicity with enough knobs.
The .pronsolerc file:
set port /dev/ttyACM0 set baudrate 115200 set build_dimensions 200x240x195-100-120+0 set temperature_abs 200 set last_bed_temperature 70.0 set last_temperature 155.0 set xy_feedrate 30000 set z_feedrate 2500 set e_feedrate 300 set last_file_path /mnt/bulkdata/Project Files/Thing-O-Matic/Calibration set temperature_pla 165 set preview_grid_step1 10 set preview_grid_step2 20.0 set preview_extrusion_width 0.4 set bedtemp_pla 70
Line 3 sizes the preview and offsets the XY=0 origin to the center of the plot.
The 200 mm X axis dimension is slightly larger than the actual 195 mm buildable area on the platform, but if the object gets that close to the maximum size, this isn’t the place to discover it.
The 240 mm Y axis dimension is slightly shorter than the actual 250 mm buildable area and slightly larger than the distance between the snouts of the bulldog clips holding the glass plate to the heater. In this case, the object can slightly exceed the preview size if it fits between the clips.
Lines 12 and 13 produce a relatively coarse grid that’s both meaningful and easy on the eyes, with the XY dimensions in Line 3 producing a major grid line crossing at the origin where it should be:
Makergear M2: Post and Hole Calibration Test Objects
Posted by Ed in Machine Shop, Science on 21-April-2013
Despite the profusion of surface-finish and print quality test objects, I really care about the dimensions of a 3D printed object, because I tend to build widgets rather than art objects. These two objects, from walter’s Hole and Column Test Print, produce calibrated holes and columns from 0.20 mm to 10.00 mm in diameter, incrementing by 0.20 mm, that should slip neatly together:
Of course, they didn’t, but they came surprisingly close for a first attempt.
The 0.20 and 0.40 posts simply aren’t there, because they’re too small to print with a 0.35 mm diameter nozzle. The 0.60 through 1.40 mm posts were present, albeit fugly, and posts larger than that looked increasingly better.
Although all the holes were present, in the sense that you could see a disturbance in the top and bottom infill pattern, the first visibly open hole appeared at the 0.80 mm spot… and it was immeasurably small. Some holes had misplaced perimeter strands stretching across the openings, which is probably due to excessive speed from my fiddling around with the numbers.
Measuring them with a digital caliper, with no effort at finding the best orientation, then slapping the data into a Libreoffice spreadsheet, produces an interesting graph:
Above about 3 mm diameter: posts are 0.1 mm too small and holes are 0.3 mm too small. Around 2 mm, posts are too big and holes are way too small. What’s important: above maybe 2.5 mm, the error is essentially constant and does not scale with diameter, so a simple Finagle Constant (or two) can solve (most of) the problem.
Some experiments involving slic3r’s small-perimeter speed seem in order; it was 25 mm/s for these pieces.
More care in measurement would produce better answers, but the real question is whether you can produce holes and columns with known sizes; the answer (as expected) remains “with some care”. That’s not surprising; I expect to have an M2 + PLA version of the small hole diameter Finagle Constant that I’ve been using with Skeinforge + Thing-O-Matic; the correction will certainly fall in the same ballpark.
The slic3r configuration:
; generated by Slic3r 0.9.8 on 2013-04-01 at 16:20:49 ; layer_height = 0.25 ; perimeters = 1 ; top_solid_layers = 3 ; bottom_solid_layers = 3 ; fill_density = 0.10 ; perimeter_speed = 100 ; infill_speed = 300 ; travel_speed = 500 ; scale = 1 ; nozzle_diameter = 0.35 ; filament_diameter = 1.70 ; extrusion_multiplier = 0.9 ; perimeters extrusion width = 0.40mm ; infill extrusion width = 0.40mm ; first layer extrusion width = 0.39mm
The source code comes from the Thingiverse customizer as bare G-Code, so there’s not much point in reproducing it here.
Makergear M2: Fundamental Test Object
Posted by Ed in Machine Shop, Software on 16-April-2013
Building these things seems to be the simplest and best way to figure out whether you have all the pieces flying in formation:
I took that picture after cracking them off the glass plate, then putting them back: the box really does line up with the skirt while printing. There’s another object visible in the background; that little box really was the first completely successful object.
It’s adapted from Coasterman’s classic calibration set, redone in OpenSCAD so it’s easy to modify. A pair of Minkowski sums produce two shapes that ensure the wall remains exactly one thread wide all the way around the perimeter.
When your printer can print one of these, then you can move on to more complex objects, secure in the knowledge that you’ve established:
- Proper bed leveling and height setting: measure the skirt thickness
- Both the layer thickness and width match your settings
- Extrusion temperature: not too hot, not too cold
- Printing speed / acceleration for all layers
- First layer adhesion to platform
- Minimum layer time to prevent melting / slumping
- Filament diameter
- Extrusion “packing density” multiplier: the fundamental fudge factor
- Accurate steps/mm for all axes to get exact XYZ dimensions
- Mechanical stability and rigidity
Basically, this object leaves no place for errors to hide. It doesn’t check infill, the various perimeter speeds, solid layers, and suchlike, but all the fundamentals must be correct or you’ll see painfully obvious flaws.
For example, there’s a bit of a zipper at the layer changes. It’s better than the Thing-O-Matic ever was, but it improved as I twiddled the Retraction settings on later objects.
No, the first few didn’t work quite that well:
For what it’s worth, the last problem turned out to be a loose setscrew in the X axis motor pulley that produced a layer shift that closely resembled a stepper motor losing steps. All of the setscrews now sport a dab of low-strength Loctite, so that problem shouldn’t happen again.
Yes, I did the happy dance…
The slic3r header:
; generated by Slic3r 0.9.8 on 2013-03-26 at 11:01:10 ; layer_height = 0.25 ; perimeters = 1 ; top_solid_layers = 3 ; bottom_solid_layers = 3 ; fill_density = 0.20 ; perimeter_speed = 100 ; infill_speed = 150 ; travel_speed = 500 ; scale = 1 ; nozzle_diameter = 0.35 ; filament_diameter = 1.70 ; extrusion_multiplier = 0.9 ; perimeters extrusion width = 0.40mm ; infill extrusion width = 0.40mm ; first layer extrusion width = 0.39mm
The solid model has no surprises:
The OpenSCAD source code:
// Thin wall open box calibration piece
// Adapted from Coasterman's Calibration set
// Ed Nisley - KE4ZNU - Dec 2011
// Adjust for Slic3r/M2 - March 2013
//-------
//- Extrusion parameters must match reality!
// None of the fill parameters matter
ThreadThick = 0.25;
ThreadWidth = 0.40;
Protrusion = 0.1; // make holes end cleanly
function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
//-------
// Dimensions
Height = IntegerMultiple(5.0,ThreadThick);
WallThick = ThreadWidth;
CornerRadius = 2.0;
CornerSides = 4*8;
SideLen = 20.0 - 2*CornerRadius;
Rotation = 45;
//-------
module ShowPegGrid(Space = 10.0,Size = 1.0) {
Range = floor(50 / Space);
for (x=[-Range:Range])
for (y=[-Range:Range])
translate([x*Space,y*Space,Size/2])
%cube(Size,center=true);
}
//-------
ShowPegGrid();
rotate(Rotation)
translate([0,0,Height/2])
intersection() {
difference() {
minkowski() {
cube([SideLen,SideLen,Height],center=true);
cylinder(r=CornerRadius,h=Protrusion,$fn=CornerSides);
}
minkowski() {
cube([(SideLen - 2*WallThick),(SideLen - 2*WallThick),2*Height],center=true);
cylinder(r=CornerRadius,h=Protrusion,$fn=CornerSides);
}
}
cube([2*SideLen,2*SideLen,Height],center=true);
}


















Blowback