The Smell of Molten Projects in the Morning

Ed Nisley's Blog: Shop notes, electronics, firmware, machinery, 3D printing, laser cuttery, and curiosities. Contents: 100% human thinking, 0% AI slop.

Category: Software

General-purpose computers doing something specific

  • Creating a Curvelicious Cookie Cutter

    So, for reasons I need not go into, I needed an OpenSCAD solid model of a custom cookie cutter produced on an Afinia 3D printer from a Trimble Sketchup model:

    Afinia Robot Cutter - on raft
    Afinia Robot Cutter – on raft

    The cutter is still attached to the raft that, it seems, is required for passable results on the Afinia’s platform.

    Having already figured out how to wrap a cutter around a shape, the most straightforward procedure starts by extracting the cutter’s shape. So, lay the cutter face down on the scanner and pull an image into GIMP:

    Afinia Robot - scan
    Afinia Robot – scan

    Blow out the contrast to eliminate the background clutter, then posterize to eliminate shadings:

    Afinia Robot - scan enhanced
    Afinia Robot – scan enhanced

    Select the black interior region, grow the selection by a pixel or two, then shrink it back to eliminate (most of) the edge granularity, plunk it into a new image, and fill with black:

    Afinia Robot - scan filled
    Afinia Robot – scan filled

    Now the magic happens…

    Import the bitmap image into Inkscape. In principle, you can auto-trace the bitmap outline and clean it up manually, but a few iterations of that convinced me that it wasn’t worth the effort. Instead, I used Inkscape’s Bézier Curve tool to drop nodes (a.k.a. control points) at all the inflection points around the image, then warped the curves to match the outline:

    Afinia Robot - Bezier spline fitting
    Afinia Robot – Bezier spline fitting

    If you’re doing that by hand, you could start with the original scanned image, but the auto-trace function works best with a high-contrast image and, after you give up on auto-tracing, you’ll find it’s easier to hand-trace a high-contrast image.

    Anyhow, the end result of all that is a smooth path around the outline of the shape, without all the gritty details of the pixelated version. Save it as an Inkscape SVG file for later reference.

    OpenSCAD can import a painfully limited subset of DXF files that, it seems, the most recent versions of Inkscape cannot produce (that formerly helpful tutorial being long out of date). Instead, I exported (using “Save as”) the path from Inkscape to an Encapsulated Postscript file (this is a PNG, as WordPress doesn’t show EPS files):

    Afinia Robot - Bezier Curves.eps
    Afinia Robot – Bezier Curves.eps

    It’s not clear what the EPS file contains; I think it’s just a list of points around the path that doesn’t include the smooth Bézier goodness. That may account for the grittiness of the next step, wherein the pstoedit utility converts the EPS file into a usable DXF file:

    pstoedit dxf:-polyaslines Afinia\ Robot\ -\ Bezier\ Curves.eps Afinia\ Robot\ -\ outline.dxf
    

    Unfortunately, either the EPS file doesn’t have enough points on each curve or pstoedit automatically sets the number of points and doesn’t provide an override: contrary to what you (well, I) might think, the -splineprecision option doesn’t apply to whatever is in the EPS file. In any event, the resulting DXF file has rather low-res curves, but they were good enough for my purposes and OpenSCAD inhaled the DXF and emitted a suitable STL file:

    Afinia Robot - shape slab
    Afinia Robot – shape slab

    To do that, you set the Layout variable to “Slab”, compile the model, and export the STL.

    Being interested only in the process and its results, not actually cutting and baking cookies, I tweaked the OpenSCAD parameters to produce stumpy “cutters”:

    Afinia Robot - solid model
    Afinia Robot – solid model

    You do that by setting the Layout variable to “Build”, compile the model, and export yet another STL. In the past, this seemed to be a less fragile route than directly importing and converting the DXF at each stage, but that may not be relevant these days. In any event, having an STL model of the cookie may be useful in other contexts, so it’s not entirely wasted effort.

    Run the STL through Slic3r to get the G-Code as usual.

    The resulting model printed in about 20 minutes apiece on the M2:

    Robot Cutter - stumpy version
    Robot Cutter – stumpy version

    As it turns out, the fact that the M2 can produce ready-to-use cutters, minus the raft, is a strong selling point.

    Given a workable model, the next step was to figure out the smallest possible two-thread-wide cutter blade, then run variations of the Extrusion Factor to see how that affected surface finish. More on that in a while.

    The OpenSCAD source isn’t much changed from the original Tux Cutter; the DXF import required different scale factors:

    // Robot cookie cutter using Minkowski sum
    // Ed Nisley KE4ZNU - Sept 2011
    // August 2013 adapted from the Tux Cutter
    
    Layout = "Build";				// Build Slab
    
    //- Extrusion parameters - must match reality!
    
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    MaxSize = 150;				// larger than any possible dimension ...
    
    Protrusion = 0.1;
    
    //- Cookie cutter parameters
    
    Size = 95;
    
    TipHeight = IntegerMultiple(3.0,ThreadThick);
    TipThick = 1.5*ThreadWidth;			// 1.5* = thinnest 2-thread wall, 1.0* thread has gaps
    
    WallHeight = IntegerMultiple(1.0,ThreadThick);
    WallThick = 4.5*ThreadWidth;
    
    LipHeight = IntegerMultiple(1.0,ThreadWidth);
    LipThick = IntegerMultiple(5,ThreadWidth);
    
    //- Wrapper for the shape of your choice
    
    module Shape(Size) {
      Robot(Size);
    }
    
    //- A solid slab of Tux goodness in simple STL format
    // Choose magic values to:
    //		center it in XY
    //		reversed across Y axis (prints with handle on bottom)
    //		bottom on Z=0
    //		make it MaxSize from head to feet
    
    module Tux(Scale) {
      STLscale = 250;
      scale(Scale/STLscale)
    	translate([105,-145,0])
    	  scale([-1,1,24])
    		import(
    		  file = "/mnt/bulkdata/Project Files/Thing-O-Matic/Tux Cookie Cutter/Tux Plate.stl",
    		  convexity=5);
    }
    
    module Robot(Scale) {
        STLscale = 100.0;
        scale(Scale / STLscale)
    			scale([-1,1,10])
    				import("/mnt/bulkdata/Project Files/Thing-O-Matic/Pinkie/M2 Challenge/Afinia Robot.stl",
    					convexity=10);
    }
    
    //- Given a Shape(), return enlarged slab of given thickness
    
    module EnlargeSlab(Scale, WallThick, SlabThick) {
    
    	intersection() {
    	  translate([0,0,SlabThick/2])
    		cube([MaxSize,MaxSize,SlabThick],center=true);
    	  minkowski(convexity=5) {
    		Shape(Scale);
    		cylinder(r=WallThick,h=MaxSize,$fn=16);
    	  }
    	}
    
    }
    
    //- Put peg grid on build surface
    
    module ShowPegGrid(Space = 10.0,Size = 1.0) {
    
      RangeX = floor(100 / Space);
      RangeY = floor(125 / Space);
    
    	for (x=[-RangeX:RangeX])
    	  for (y=[-RangeY:RangeY])
    		translate([x*Space,y*Space,Size/2])
    		  %cube(Size,center=true);
    
    }
    
    //- Build it
    
    ShowPegGrid();
    
    if (Layout == "Slab")
    	Shape(Size);
    
    if (Layout == "Build")
    	difference() {
    	union() {
    		translate([0,0,(WallHeight + LipHeight - Protrusion)])
    		EnlargeSlab(Size,TipThick,TipHeight + Protrusion);
    		translate([0,0,(LipHeight - Protrusion)])
    		EnlargeSlab(Size,WallThick,(WallHeight + Protrusion));
    		EnlargeSlab(Size,LipThick,LipHeight);
    	}
    	Shape(Size);					// punch out cookie hole
    	}
    
  • Hall Effect LED Current Control: Measurements and Firmware

    With that hardware in hand, a dab of firmware produces this result:

    Hall Current Sense - 120 mA 25 ms 250 ms
    Hall Current Sense – 120 mA 25 ms 250 ms

    A detailed look at one pulse:

    Hall Current Sense - 120 mA 25 ms 250 ms - detail
    Hall Current Sense – 120 mA 25 ms 250 ms – detail

    The top trace is the total LED current, nominally 120 mA, at 50 mA/div. The ripple (which is a nice triangle waveform at a faster sweep) comes from the 32 kHz PWM pulse train, despite passing through a 1 ms RC filter; the MOSFET runs in the linear region and makes a great amplifier.

    The middle trace is the MOSFET drain voltage at 1 V/div. The on-state voltage runs around 1.6 V, so the LEDs see about 5.9 V at 120 mA, about what you’d expect, with the little bit of PWM ripple accounting for the current sawtooth in the top trace. The off-state voltage is only 3.8 V, because the LEDs soak up the rest; it’s about 1.2 V per LED.

    The bottom trace is the current-sense amp output. The 1 nF cap in the op amp feedback loop rolls it off at 600 Hz, so there’s not much ripple at all in there. That goes directly to the Arduino’s ADC, where it’s further averaged over 10 samples.The LEDs take a couple of milliseconds to get up to full intensity, but it’s much faster than an incandescent filament: this thing blinks rather than flashes.

    The current in each LED string runs from about 15 mA to 25 mA, with all the “old” LEDs at the low end and the “new” LED strings at the high end. Using unsorted LEDs from the same batch will probably be OK, although I’ll measure them just to see what they’re like.

    The LEDs dissipate 700 mW and the MOSFET wastes 192 mW, so the efficiency is around 79%. Not too shabby for a linear regulator and it only gets better as the battery discharges. The toroid winding burns maybe 300 μW, so it’s not in the running; to be fair, a 1 Ω sense resistor would account for only 14 mW, but it would drop 120 mV instead of 3 mV, which is what matters more when the battery voltage drops.

    That’s during the pulse, which should have a duty cycle under 25% or so, which means 175 mW and 48 mW on the average. Obviously, no heatsinks needed: each LED runs at 7 mW average under those conditions.

    The firmware steps the gate voltage by the smallest possible increment, about 20 mV = 5 V / 256. The feedback loop adjusts the gate voltage in single steps to avoid goosing the LEDs with too much current; a binary search wouldn’t work very well at all. I think it’d be a good idea to build a table of transconductance (gate voltage to LED current) by ramping the gate voltage during startup, then fine-tune the coefficients during each pulse.

    The console log tells the tale:

    Hall effect Current Regulator
    Ed Nisley - KE4ZNU - August 2013
    Given Vcc: 5010 mV
    Given VBatt divider ratio: 0.500
    Bandgap reference voltage: 1105 mV
    Battery voltage: 7551 mV
    Nulling Hall sensor offset: 0 PWM
    Final Hall sensor offset: 209 PWM
    Gate voltage: 1947 mV  LED Current: 5 mA
    Gate voltage: 1966 mV  LED Current: 6 mA
    Gate voltage: 1986 mV  LED Current: 6 mA
    Gate voltage: 2005 mV  LED Current: 7 mA
    Gate voltage: 2025 mV  LED Current: 8 mA
    Gate voltage: 2040 mV  LED Current: 8 mA
    Gate voltage: 2064 mV  LED Current: 10 mA
    Gate voltage: 2084 mV  LED Current: 11 mA
    Gate voltage: 2103 mV  LED Current: 13 mA
    Gate voltage: 2123 mV  LED Current: 14 mA
    Gate voltage: 2142 mV  LED Current: 17 mA
    Gate voltage: 2162 mV  LED Current: 19 mA
    Gate voltage: 2177 mV  LED Current: 22 mA
    Gate voltage: 2201 mV  LED Current: 25 mA
    Gate voltage: 2221 mV  LED Current: 29 mA
    Gate voltage: 2240 mV  LED Current: 33 mA
    Gate voltage: 2255 mV  LED Current: 38 mA
    Gate voltage: 2275 mV  LED Current: 44 mA
    Gate voltage: 2294 mV  LED Current: 49 mA
    Gate voltage: 2314 mV  LED Current: 56 mA
    Gate voltage: 2333 mV  LED Current: 63 mA
    Gate voltage: 2353 mV  LED Current: 70 mA
    Gate voltage: 2372 mV  LED Current: 79 mA
    Gate voltage: 2392 mV  LED Current: 89 mA
    Gate voltage: 2412 mV  LED Current: 99 mA
    Gate voltage: 2431 mV  LED Current: 110 mA
    Gate voltage: 2451 mV  LED Current: 122 mA
    Gate voltage: 2431 mV  LED Current: 110 mA
    Gate voltage: 2451 mV  LED Current: 121 mA
    Gate voltage: 2431 mV  LED Current: 110 mA
    Gate voltage: 2451 mV  LED Current: 122 mA
    Gate voltage: 2431 mV  LED Current: 110 mA
    Gate voltage: 2451 mV  LED Current: 121 mA
    

    The current feedback tweaks the gate voltage by one PWM increment on each loop, so the LED current pulses alternate between 110 and 122 mA when the loop finally reaches the setpoint. This doesn’t make any practical difference, as each LED string’s current varies by a few mA, at most, but maybe there should be a deadband of a bit more than ±1/2 PWM increment around the actual current.

    The Arduino source code:

    // LED Curve Tracer
    // Ed Nisley - KE4ANU - August 2013
    
    #include <stdio.h>
    
    //----------
    // Pin assignments
    
    const byte PIN_READ_VBATT = 0;		// AI - battery voltage from divider
    const byte PIN_READ_CURRENT = 1;	// AI - current sense amp
    const byte PIN_READ_VGATE = 2;		// AI - actual gate voltage
    const byte PIN_READ_HALL = 3;		// AI - raw Hall sensor voltage
    
    const byte PIN_SET_BIAS = 11;		// PWM - VCC/2 bias voltage
    const byte PIN_SET_VGATE = 3;		// PWM - MOSFET gate voltage
    
    const byte PIN_HEARTBEAT = 13;		// DO - Arduino LED
    const byte PIN_SYNC = 2;			// DO - scope sync output
    
    //----------
    // Constants
    
    const float MaxLEDCurrent = 0.120;		// maximum LED current
    
    const float Vcc = 5.01; 				// Arduino supply -- must be measured!
    
    const float VBattRatio = 3.03/6.05;		// measured division ratio for battery divider
    
    const float VStep = Vcc/256;			// minimum PWM voltage increment = 5 V / 256
    
    const float IGain = 0.100;				// Hall sense voltage to LED current
    
    const byte PWM_Settle = 10;				// PWM settling time ms
    
    // Timer prescaler = 1:1 for 32 kHz PWM
    #define TCCRxB 0x01
    
    #define MK_UL(fl,sc) ((unsigned long)((fl)*(sc)))
    #define MK_U(fl,sc) ((unsigned int)((fl)*(sc)))
    #define MK_I(fl,sc) ((int)((fl)*(sc)))
    
    //----------
    // Globals
    
    float AVRef1V1;					// 1.1 V bandgap reference - calculated from Vcc
    
    float VBatt;					// battery voltage - calculated from divider
    float VGateSense;				// actual gate voltage - measured after PWM filter
    float ILEDSense;				// LED current from Hall effect sensor
    
    float VGateDrive;				// gate drive voltage
    
    byte PWMHallOffset;				// zero-field Hall effect sensor bias
    
    long unsigned long MillisNow, MillisThen;	// sampled millis() value
    
    //-- Read AI channel
    //      averages several readings to improve noise performance
    //		returns value in volts assuming known VCC ref voltage
    
    #define NUM_T_SAMPLES    10
    
    float ReadAI(byte PinNum) {
    
      word RawAverage;
    
      digitalWrite(PIN_SYNC,HIGH);					// scope sync
    
      RawAverage = (word)analogRead(PinNum);		// prime the averaging pump
    
      for (int i=2; i <= NUM_T_SAMPLES; i++) {
        RawAverage += (word)analogRead(PinNum);
      }
    
      digitalWrite(PIN_SYNC,LOW);
    
      RawAverage /= NUM_T_SAMPLES;
    
      return Vcc * (float)RawAverage / 1024.0;
    
    }
    
    //-- Set PWM output
    
    void SetPWMVoltage(byte PinNum,float PWMVolt) {
    
    byte PWM;
    
      PWM = constrain((byte)(255.0 * PWMVolt / Vcc),0,255);
    
      analogWrite(PinNum,PWM);
      delay(PWM_Settle);
    
    }
    
    //-- compute actual 1.1 V bandgap reference based on known VCC = AVcc (more or less)
    //		adapted from http://code.google.com/p/tinkerit/wiki/SecretVoltmeter
    
    float ReadBandGap(void) {
    
      word ADCBits;
      float VBandGap;
    
      ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);	// select 1.1 V input
      delay(2); // Wait for Vref to settle
    
      ADCSRA |= _BV(ADSC);										// Convert
      while (bit_is_set(ADCSRA,ADSC));
    
      ADCBits = ADCL;
      ADCBits |= ADCH<<8;
    
      VBandGap = Vcc * (float)ADCBits / 1024.0;
      return VBandGap;
    }
    
    //-- Helper routine for printf()
    
    int s_putc(char c, FILE *t) {
      Serial.write(c);
    }
    
    //------------------
    // Set things up
    
    void setup() {
    
    float AVRef1V1;
    
      pinMode(PIN_HEARTBEAT,OUTPUT);
      digitalWrite(PIN_HEARTBEAT,LOW);	// show we arrived
    
      pinMode(PIN_SYNC,OUTPUT);
      digitalWrite(PIN_SYNC,LOW);		// show we arrived
    
      TCCR1B = TCCRxB;					// set frequency for PWM 9 & 10
      TCCR2B = TCCRxB;					// set frequency for PWM 3 & 11
    
      analogWrite(PIN_SET_VGATE,0);		// force gate voltage = 0
    
      Serial.begin(57600);
      fdevopen(&s_putc,0);				// set up serial output for printf()
    
      printf("Hall effect Current Regulator\r\nEd Nisley - KE4ZNU - August 2013\r\n");
    
      printf("Given Vcc: %d mV\r\n",MK_I(Vcc,1000.0));
      printf("Given VBatt divider ratio: 0.%d\r\n",MK_I(VBattRatio,1000.0));
    
      AVRef1V1 = ReadBandGap();			// compute actual bandgap reference voltage
      printf("Bandgap reference voltage: %d mV\r\n",MK_I(AVRef1V1,1000.0));
    
      VBatt = ReadAI(PIN_READ_VBATT) / VBattRatio;
      printf("Battery voltage: %d mV\r\n",MK_I(VBatt,1000.0));
    
      SetPWMVoltage(PIN_SET_VGATE,0.0);		// zero LED current
      PWMHallOffset = 0;
      analogWrite(PIN_SET_BIAS,PWMHallOffset);
      printf("Nulling Hall sensor offset: %d PWM\r\n",PWMHallOffset);
    
      do {
    	ILEDSense = IGain * ReadAI(PIN_READ_CURRENT);
    //	printf("Current Sense: %d mA - ",MK_I(ILEDSense,1000.0));
    	if (ILEDSense > 0.005) {
    		PWMHallOffset += 1;
    		analogWrite(PIN_SET_BIAS,PWMHallOffset);
            delay(PWM_Settle);
    //		printf("Step offset: %d PWM\r\n",PWMHallOffset);
    	}
      } while (ILEDSense > 0.005);
      printf("Final Hall sensor offset: %d PWM\r\n",PWMHallOffset);
    
      VGateDrive = 2.0;					// reasonable starting point
    
      MillisThen = millis();
    }
    
    //------------------
    // Run the test loop
    
    void loop() {
    
    	if ((millis() - MillisThen) > 250) {
    		MillisThen = millis();
    
    		if (ILEDSense < MaxLEDCurrent) {
    			VGateDrive += VStep;
    		}
    		else if (ILEDSense > MaxLEDCurrent) {
    			VGateDrive -= VStep;
    		}
    
    		SetPWMVoltage(PIN_SET_VGATE,VGateDrive);
    
    		VGateSense = ReadAI(PIN_READ_VGATE);
    		printf("Gate voltage: %d mV  ",MK_I(VGateSense,1000.0));
    
    		ILEDSense = IGain * ReadAI(PIN_READ_CURRENT);
    		printf("LED Current: %d mA\r\n",MK_I(ILEDSense,1000.0));
    
    		delay(50 - PWM_Settle - 3);
    		SetPWMVoltage(PIN_SET_VGATE,0.0);
    
    		digitalWrite(PIN_HEARTBEAT,!digitalRead(PIN_HEARTBEAT));
    		digitalWrite(PIN_HEARTBEAT,!digitalRead(PIN_HEARTBEAT));
    	}
    }
    
  • Why Friends Don’t Let Friends Run Windows: Product Pictures? Really?

    This email worked its way through the filters:

    Dear Business Partner,

    We are very much interested in some of your product. We try to contact you online but you are not online so we decided to attach the picture of the product we need to dropbox and put it in your offline. Open the bellow link and download the attachment to preview the product we need:

    ... dropbox url snippage ... /Product%20Pics.rar

    Let me know if the product is still available for sale and how much it costs, also tell us the product details.

    Regards,
    Allen Moore,
    Procurement Officer,
    International Product Buyers

    Well, I don’t generally rebuff the humble, but I don’t have any “product” for sale. Also pulling the suspicion trigger:

    • To: Recipients <Procurement@Officer.com>
    • Subject: Open Attachment For Product Picture

    It’s not clear what “attach the picture of the product we need to dropbox and put it in your offline” might mean. Despite the Dropbox URL, the email sported an attachment named Product\ Pics.rar, showing they come from a different universe wherein every operating system has a native RAR extraction program.

    Being a dutiful citizen of the Interwebs, I did what the nice man asked:

    unrar e Product\ Pics.rar

    That produced a single file which RAR described thusly:

    Extracting Product Picjpg.SCR

    At least that’s what it looked like on the command line. I think they were trying to overwrite the SCR with the jpg, as the file name was really Product Pic<U+202E>RCS.gpj, but the Unicode U+20E bidirectional text control character seems to be in the wrong place. I think they wanted Product Pic.SCR<U+202E>gpj, but I also confess to having no experience with sixth-level Unicode direction reversal rendering.

    Anyhow, handing the entire RAR archive to VirusTotal produces the expected result:

    VirusTotal - Product Pics malware file
    VirusTotal – Product Pics malware file

    It’s disconcerting to see ClamAV asleep at the switch on this one, but signature detection has become decreasingly relevant these days.

    I opted to not respond to the request..

  • MAKE: Mistake

    MAKE - address blooper
    MAKE – address blooper

    I expect the blooper isn’t reciprocal; Dr Darwish probably didn’t get my “Dear Ed” salutation.

    Sorry, that title was just too good to pass up…

  • Making Finger Grip Dents: The Chord Equation

    The handle of that quilting circle template has a pair of finger grip dents, which, while they aren’t strictly necessary, seemed like a nice touch:

    Quilting circle template - solid model
    Quilting circle template – solid model

    They’re the result of subtracting a pair of spheres from the flat handle:

    Quilting circle template - handle dent spheres - solid model
    Quilting circle template – handle dent spheres – solid model

    Given:

    • m = the depth of the dent
    • c = its diameter on the surface of the handle

    There’s an easy way to compute R = the radius of the sphere that excavates the dent:

    Circle chord vs depth sketch
    Circle chord vs depth sketch

    Thusly:

    R = (m2 + c2/4) / (2 m)

    In OpenSCAD, that goes a little something like this:

    DentDepth = HandleThick/4;
    DentDia = 15.0;
    DentSphereRadius = (pow(DentDepth,2) + pow(DentDia,2)/4)/(2*DentDepth);
    

    Then generate the sphere (well, two spheres, one for each dent) and offset it to scoop out the dent:

    for (i=[-1,1]) {
    	translate([i*(DentSphereRadius + HandleThick/2 - DentDepth),0,StringHeight])
    		sphere(r=DentSphereRadius);
    

    HandleThick controls exactly what you’d expect. StringHeight sets the location of the hole punched through the handle for a string, which is also the center of the dents.

    The spheres have many facets, but only a few show up in the dent. I like the way the model looks, even if the facets don’t come through clearly in the plastic:

    Quilting circle template - handle dent closeup - solid model
    Quilting circle template – handle dent closeup – solid model

    It Just Works and the exact math produces a better result than by-guess-and-by-gosh positioning.

    The sphere radius will come out crazy large for very shallow dents. Here’s the helmet plate for my Bicycle Helmet Mirror Mount, which has an indentation (roughly) matching the curve on the side of my bike helmet:

    Helmet mirror mount - plate
    Helmet mirror mount – plate

    Here’s the sphere that makes the dent, at a somewhat different zoom scale:

    Helmet mirror mount - plate with sphere
    Helmet mirror mount – plate with sphere

    Don’t worry: trust the math, because It Just Works.

    You find equations like that in Thomas Glover’s invaluable Pocket Ref. If you don’t have a copy, fix that problem right now; I don’t get a cut from the purchase, but you’ll decide you owe me anyway. Small, unmarked bills. Lots and lots of small unmarked bills…

  • Quilting Circle Template: Why I Loves Me My 3D Printer(s)

    Mary just started an ambitious pieced quilt that requires 50-some-odd precisely sized 1-1/2 inch circles, with marks to locate a 1 inch circle in the middle. She started using a drafting template to mark the smaller circle on freezer paper (don’t ask, it’s complicated), but we couldn’t find the template I know I have with the larger circles.

    [Update: It’s a Bittersweet Briar traditional quilt. See all those little dots-for-berries?]

    So I says to my wife, I sez, “Hey, we have the technology. What would really simplify what you’re doing?” After a bit of doodling, we came up with a ring having the proper ID and OD, plus a flat handle of some sort.

    Half an hour later, I had a solid model:

    Quilting circle template - solid model
    Quilting circle template – solid model

    An hour after that I handed her a warm piece of plastic:

    Quilting circle template
    Quilting circle template

    The bottom ring is exactly 1-1/2 inch OD, 1 inch ID, and thin enough to draw around. The handle keeps her fingers out of the way and even has grips and a hole for a string.

    The print quality near the hole isn’t as good as I’d like, because the slicer turned that entire volume into a solid slab of plastic. I can fix that in the second version, but right now she has something to work with, evaluate, and figure out what would improve it.

    3D printing isn’t for everybody, but it’s a vital part of my shop!

    The OpenSCAD source code has parameters for everything, so we can crank out more templates without fuss:

    // Quilting - Circle Template
    // Ed Nisley KE4ZNU - July 2013
    
    Layout = "Show";                    // Show Build Circle Handle
    
    //-------
    //- Extrusion parameters must match reality!
    //  Print with 2 shells
    
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    
    HoleFinagle = 0.2;
    HoleFudge = 1.00;
    
    function HoleAdjust(Diameter) = HoleFudge*Diameter + HoleFinagle;
    
    Protrusion = 0.1;           // make holes end cleanly
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    function IntegerMultipleMin(Size,Unit) = Unit * floor(Size / Unit);
    
    inch = 25.4;
    
    //-------
    // Dimensions
    
    CircleID = (1) * inch;
    
    SeamAllowance = (1/4) * inch;
    
    CircleOD = CircleID + 2*SeamAllowance;
    
    CircleThick = 6*ThreadThick;
    
    CircleSides = 12*4;
    
    HandleHeight = (2) * inch;
    HandleThick = IntegerMultiple(5.0,ThreadWidth);
    HandleSides = 12*4;
    
    StringDia = 4.0;
    StringSides = 8;
    StringHeight = 0.75*HandleHeight;
    
    DentDepth = HandleThick/4;
    DentDia = 15.0;
    DentSphereRadius = (pow(DentDepth,2) + pow(DentDia,2)/4)/(2*DentDepth);
    
    //-------
    
    module PolyCyl(Dia,Height,ForceSides=0) {           // based on nophead's polyholes
      Sides = (ForceSides != 0) ? ForceSides : (ceil(Dia) + 2);
      FixDia = Dia / cos(180/Sides);
      cylinder(r=HoleAdjust(FixDia)/2,h=Height,$fn=Sides);
    }
    
    module ShowPegGrid(Space = 10.0,Size = 1.0) {
    
      RangeX = floor(100 / Space);
      RangeY = floor(125 / Space);
    
    	for (x=[-RangeX:RangeX])
    	  for (y=[-RangeY:RangeY])
    		translate([x*Space,y*Space,Size/2])
    		  %cube(Size,center=true);
    
    }
    
    //-------
    // Circle ring plate
    
    module CircleRing() {
    
    	rotate(180/CircleSides)
    		difference() {
    			cylinder(r=CircleOD/2,h=CircleThick,$fn=CircleSides);
    			translate([0,0,-Protrusion])
    				cylinder(r=CircleID/2,h=(CircleThick + 2*Protrusion),$fn=CircleSides);
    		}
    }
    
    //-------
    // Handle
    
    module Handle() {
    
    	difference() {
    		rotate([0,90,0])
    			scale([HandleHeight/(CircleOD/2),0.9,1])
    				rotate(180/HandleSides)
    					cylinder(r=CircleOD/2,h=HandleThick,center=true,$fn=HandleSides);
    		translate([0,0,-HandleHeight])
    			cube([2*CircleOD,2*CircleOD,2*HandleHeight],center=true);
    		translate([-HandleThick,0,StringHeight])
    			rotate([0,90,0])
    				rotate(180/StringSides)
    					PolyCyl(StringDia,2*HandleThick,StringSides);
    #		for (i=[-1,1]) {
    			translate([i*(DentSphereRadius + HandleThick/2 - DentDepth),0,StringHeight])
    				sphere(r=DentSphereRadius);
    		}
    	}
    
    }
    
    module Template() {
    	CircleRing();
    	Handle();
    }
    
    //-------
    // Build it!
    
    ShowPegGrid();
    
    if (Layout == "Circle")
    	CircleRing();
    
    if (Layout == "Handle")
    	Handle();
    
    if (Layout == "Show")
    	Template();
    
  • Makergear M2: Mechanical Setup

    That Slic3r configuration presumes a somewhat nonstandard mechanical setup for my M2…

    I put the XY coordinate origin in the middle of the platform, so that laying objects out for printing doesn’t require knowing how large the platform will be: as long as the printer is Big Enough, you (well, I) can print without further attention.

    The RepRap world puts the XY coordinate origin in the front left corner of the platform, so that the platform size sets the maximum printable coordinates and all printing happens in Quadrant I.  This has the (major, to some folks) advantage of using only positive coordinates, while requiring an offset for each different platform.

    Yes, depending on which printer software you use, you can (automagically) center objects on your platform; this is often the only way to find objects created with Trimble (formerly Google) Sketchup. I am a huge fan of knowing exactly what’s going to happen before the printing starts, so I position my solid models exactly where I want them, right from the start. For example, this OpenSCAD model of the bike helmet mirror parts laid out for printing:

    Helmet mirror mount - 3D model - Show layout
    Helmet mirror mount – 3D model – Show layout

    … exactly matches the plastic on the Thing-O-Matic’s platform, with the XY origin right down the middle of the platform:

    Helmet mirror mount on build platform - smaller mirror shaft
    Helmet mirror mount on build platform – smaller mirror shaft

    It’d print exactly the same, albeit with more space around the edges, on the M2’s platform.

    Similarly, the Z axis origin sits exactly on the surface of the platform. That way, the Z axis coordinate equals the actual height of the current thread extrusion in a measurable way: when you set the Z axis to, say, 2.0 mm, you can measure that exact distance between the extruder nozzle and the platform:

    Taper gauge below nozzle
    Taper gauge below nozzle

    Now, admittedly, I fine-tune that distance by measuring the height of the skirt thread around the printed object, but the principle remains: a thread printed  on the platform with Z=0.25 should be exactly 0.25 mm thick.

    The start.gcode file handles all that:

    ;-- Slic3r Start G-Code for M2 starts --
    ;  Ed Nisley KE4NZU - 15 April 2013
    M140 S[first_layer_bed_temperature]	; start bed heating
    G90				; absolute coordinates
    G21				; millimeters
    M83				; relative extrusion distance
    M84				; disable stepper current
    G4 S3			; allow Z stage to freefall to the floor
    G28 X0			; home X
    G92 X-95			; set origin to 0 = center of plate
    G1 X0 F30000		; origin = clear clamps on Y
    G28 Y0			; home Y
    G92 Y-127 		; set origin to 0 = center of plate
    G1 Y-125 F30000	; set up for prime at front edge
    G28 Z0			; home Z
    G92 Z1.0			; set origin to measured z offset
    M190 S[first_layer_bed_temperature]	; wait for bed to finish heating
    M109 S[first_layer_temperature]	; set extruder temperature and wait
    G1 Z0.0 F2000		; plug extruder on plate
    G1 E10 F300		; prime to get pressure
    G1 Z5 F2000		; rise above blob
    G1 X5 Y-122 F30000	; move away from blob
    G1 Z0.0 F2000		; dab nozzle to remove outer snot
    G4 P1			; pause to clear
    G1 Z0.5 F2000		; clear bed for travel
    ;-- Slic3r Start G-Code ends --
    

    The wipe sequence, down near the bottom, positions the extruder at the front center edge of the glass plate, waits for it to reach the extrusion temperature, then extrudes 10 mm of filament to build up pressure behind the nozzle. The blob generally hangs over the edge of the platform and usually doesn’t follow the nozzle during the next short move and dab to clear the mess:

    M2 - Wipe blobs on glass platform
    M2 – Wipe blobs on glass platform

    I’ve also configured Slic3r to extrude at least 25 mm of filament in at least three passes around the object. After that, the extruder pressure has stabilized and the first layer of the object begins properly.

    Which brings up another difference: the first layer printed on the platform is exactly like all the others. It’s not smooshed to get better adhesion or overfilled to make the threads stick together:

    Robot cookie cutter - printing first layer
    Robot cookie cutter – printing first layer

    I print the first layer at 25 mm/s to give the plastic time to bond to the platform and use hairspray to make PLA stick to glass like it’s glued down.

    After that, it’s just ordinary 3D printing…