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: Electronics Workbench

Electrical & Electronic gadgets

  • Kenmore 158: Pedal Recalibration

    With the Crash Test Dummy in place, Mary reports that the pedal required too much motion to reach the full speed position. The graph from the last time around shows the output as a function of pedal position:

    Hall sensor output vs pedal depression
    Hall sensor output vs pedal depression

    I’d done some fiddling around after recording that data, but it remained pretty close to the truth.

    A new scale, not quite in the same spot as the previous one:

    Kenmore 158 - Foot Pedal - motion recalibration
    Kenmore 158 – Foot Pedal – motion recalibration

    The two long lines mark the active region after I finished the mechanical tweaking described below; the pedal now produces nearly full output just beyond the 12 mm mark and has about that much overtravel. Measuring those values requires squeezing the pedal by hand, holding its position, and recording the ADC output dumped by the motor control program in the Arduino, a process that could be improved, but to not much benefit.

    The original pedal writeup goes into the gory details, but the bottom line is that the mechanical motion producing that output range depends on the length of the rod from the actuator bar to the magnet.

    The original version had a thin nut securing a screw inside the brass shaft to the actuator:

    Kenmore 158 - Hall speed control - prototype interior
    Kenmore 158 – Hall speed control – prototype interior

    I later swapped the nut for three washers, after observing that the nut wasn’t actually necessary, but that produced too much dead travel at the beginning of motion.

    We discovered that the actuator bar could slip off the end of the ramp cast into the pedal cover, jamming the end of the ramp, making the case extremely difficult to disassemble, and causing heartache & confusion. Affixing a pair of rubber feet to the rear wall of the pedal case with tapeless sticky keeps the bar about half a millimeter further forward and eliminates that problem:

    Kenmore 158 - foot pedal - short actuation
    Kenmore 158 – foot pedal – short actuation

    A second nut moved the brass rod forward, but that turned out to be a bit too much, so it now has a single, slightly thicker, nut. The 3D printed frame allows for far more travel in each direction than is strictly necessary, specifically to allow this fine tuning; it’s possible to make the rod’s resting position too close to the Hall effect sensor and have them collide at full travel, but I managed to avoid that.

    It’s impossible to measure anything with the case disassembled: each change requires reassembling everything, measuring, and iterating.

    After some of this & that, this graph shows the final output curve, with the Y axis in raw ADC counts at 100/div:

    Foot Pedal - ADC vs position - graph detail
    Foot Pedal – ADC vs position – graph detail

    The first 3 mm doesn’t produce much change in the output, it smoothly changes to the more-or-less linear ramp up to 12 mm, then tapers off to full output beyond 14 mm. That’s pretty close to the original graph, with full throttle occurring a bit more than 2 mm earlier; the difference between the two scales may have some effect. In any event, Mary reports it feels much better.

    Trust me: that matters.

    The original data from the first and second mods, plus a teeny version of that graph:

    Foot Pedal - ADC vs position
    Foot Pedal – ADC vs position
  • Incandescent Bulb Lifetime

    One of the four 40 W bulbs in the classic 1955 fixture over the front bathroom mirror burned out, leading to this discovery:

    40 W bulb - lifetime
    40 W bulb – lifetime

    Yup, I installed that bulb in late September 1998, when we repainted that bathroom (for the first time since the original owners painted it in 1955). Getting a decade and a half from an incandescent bulb in regular use ain’t all that bad, sez I. Two other bulbs appeared in mid 2014, replacing bulbs with barely 6 years of service. Inexplicably, the third bulb has no date; I must be slipping.

    Having burned through the 40 W bulb stash, I put two 60 W incandescents in the center sockets, leaving me with four new-old-stock bulbs on the shelf. Might be a lifetime supply for this house…

  • Kenmore 158: Crash Test Dummy Installation

    The Crash Test Dummy’s double-walled and somewhat crushed base turns out to be slightly larger front-to-back than the one on Mary’s original Kenmore 158 (which has a later serial number), but it still fits into the cutout in the insulating board we’re using in lieu of a Real Sewing Surface:

    Kenmore 158 Controller - First Quilting
    Kenmore 158 Controller – First Quilting

    Lashing the UI data/power cable to the motor & LED / sensor cables from the sewing machine keeps the Arduino Mega + TFT from falling off the tabletop, but the arrangement reeks of impromptu.

    Early reports indicate that the pedal doesn’t feel quite right, with faster speeds requiring too much travel. Given that I worked hard to get more travel with slower transitions into that thing, differences shouldn’t come as any surprise, but … this will require some tweaking.

  • Kenmore 158 Motor Controller: Button Command Decoder

    Now that the sewing machine motor controller receives commands from the UI (or typed in on a console), it must decode them. The “parser” doesn’t amount to much, because the commands consist of exactly two characters wrapped in square brackets. For simplicity, if the format doesn’t match or the command isn’t exactly right, the decoder simply tosses it on the floor and moves on:

    void ParseCmd(char *pBuff) {
    
    	if ((CmdBuffer[0] != '[') || (CmdBuffer[3] != ']')) {
    		printf("** Bad cmd format: %s\r\n",CmdBuffer);
    		return;	
    	}
    
    	switch (CmdBuffer[1]) {
    	case 'N':							// needle park position
    		switch (CmdBuffer[2]) {
    		case 'u':
    			MotorDrive.ParkPosition = NS_UP;
    //			ParkNeedle(NS_UP);
    			break;
    		case 'a':
    			MotorDrive.ParkPosition = NS_NONE;
    			break;
    		case 'd':
    			MotorDrive.ParkPosition = NS_DOWN;
    //			ParkNeedle(NS_DOWN);
    			break;
    		default:
    			printf("** Bad Needle cmd: %s\r\n",CmdBuffer);
    		}
    		break;
    	case 'P':							// pedal mode
    		switch (CmdBuffer[2]) {
    		case 'r':
    			MotorDrive.PedalMode = PD_RUN;
    			break;
    		case '1':
    			MotorDrive.PedalMode = PD_SINGLE;
    			break;
    		case 'f':
    			MotorDrive.PedalMode = PD_FOLLOW;
    			break;
    		default:
    			printf("** Bad Pedal cmd: %s\r\n",CmdBuffer);
    		}
    		break;
    	case 'S':							// motor speed range
    		switch (CmdBuffer[2]) {
    		case 'h':
    			MotorDrive.SpeedRange = SPEED_HIGH;
    			PedalMaxClamp = PEDALMAX;
    			break;
    		case 'm':
    			MotorDrive.SpeedRange = SPEED_MEDIUM;
    			PedalMaxClamp = (3 * PEDALMAX) / 4;
    			break;
    		case 'l':
    			MotorDrive.SpeedRange = SPEED_LOW;
    			PedalMaxClamp = PEDALMAX / 2;
    			break;
    		default:
    			printf("** Bad Speed cmd: %s\r\n",CmdBuffer);
    		}
    		break;
    	default:
    		printf("** Bad command string: %s\r\n",CmdBuffer);
    	}
    	
    	return;
    }
    

    So much for recursive descent parser design theory, eh?

  • Kenmore 158 UI: Power & Data Cable

    The Arduino Mega behind the LCD panel communicates serially through the Serial1 hardware, leaving the USB connection available for its usual console + program loading functions. The cable also carries +7 VDC for the Mega’s on-board regulator, plus a few bits that might prove useful, and enough grounds to be meaningful.

    The pinout on the DE-9 female back-panel connector:

    1. TX (Mini -> Mega)
    2. RX (Mini <- Mega)
    3. Current sense amp
    4. D4 Enable ATX
    5. Gnd
    6. +7V regulator
    7. Gnd
    8. Gnd
    9. Gnd

    Which looks like this:

    Kenmore 158 UI - cable at motor controller
    Kenmore 158 UI – cable at motor controller

    One could argue that I should use insulation-displacement connectors and pin headers, but there’s something to be said for a bit of meditative hand-soldering.

    The 7 V supply drops about 90 mV through its slightly too thin wire. With current around 100 mA, that works out to 900 mΩ, including all the connectors and gimcrackery along the way. Close enough.

    More cogently, one could argue that I should have used a DE-9 male connector, so as to remove the possibility of swapping the cables. So it goes. The pinout attempts to minimize damage, but ya never know.

    The green jumper on the Mini’s serial pins reminds me to unplug the UI cable, lest I plug the USB adapter into it and put the serial drivers in parallel.

    The 7 V regulator stands over on the left, powering both the Arduino Pro Mini and the Mega + LCD panel. My thumb tells me that piddly little heatsink isn’t quite up to its new responsibilities, unlike the now vastly overqualified heatsink on the ET227. On the other paw, that’s why I used a pre-regulator: so that same heat isn’t burning up the SMD regulators on the Arduino PCBs. Time to rummage in the Big Box o’ Heatsinks again.

  • Adafruit Touch-screen TFT LCD Rotation

    The alert reader will have noted that the Kenmore 158 UI twisted around to a new orientation atop its fancy holder, with the USB port now poking out from the right side:

    Kenmore 158 UI - PCB holder
    Kenmore 158 UI – PCB holder

    That lets me position the whole affair to the right of the sewing machine, in what seems to be its natural position, without having the cable form a loop that would push it off the platform. It’s not entirely clear how we’ll keep a straight cable from pulling it off, but that’s in the nature of fine tuning.

    Anyhow, rotating the LCD isn’t a big deal, because the Adafruit library does all the heavy lifting:

    // LCD orientation: always landscape, 1=USB upper left / 3=USB lower right
    #define LCDROTATION 3
    
    ... snippage ...
    tft.begin();
    tft.setRotation(LCDROTATION);	// landscape, 1=USB upper left / 3=USB lower right
    

    Flipping the touch screen coordinates required just interchanging the “to” bounds of the map() functions, with a conditional serving as institutional memory in the not-so-unlikely event I must undo this:

    #if LCDROTATION == 1
    	p->x = map(t.y, TS_Min.y, TS_Max.y, 0, tft.width());	// rotate & scale to TFT boundaries
    	p->y = map(t.x, TS_Min.x, TS_Max.x, tft.height(), 0);	//   ... USB port at upper left
    #elif LCDROTATION == 3
    	p->x = map(t.y, TS_Min.y, TS_Max.y, tft.width(), 0);	// rotate & scale to TFT boundaries
    	p->y = map(t.x, TS_Min.x, TS_Max.x, 0, tft.height());	//   ... USB port at lower right
    #endif
    

    And then It Just Worked.

  • Arduino Mega PCB Holder

    Flushed with success from making the boost power supply mount, here’s a holder for the Arduino Mega that’s supporting the Kenmore 158 sewing machine UI:

    Kenmore 158 UI - PCB holder
    Kenmore 158 UI – PCB holder

    The solid model shows two screws holding the PCB in place:

    Arduino Mega PCB Mount
    Arduino Mega PCB Mount

    I decided to edge-clamp the board, rather than fuss with the built-in screws, just because 3D printing makes it so easy.

    Of course, the UI needs a real case that will hold it at an angle, so as to make the LCD and touch screen more visible and convenient; this mount just keeps the PCB up off the conductive surface of the insulating board we’re using in lieu of a Real Sewing Platform.

    This sewing machine project involves a lot of parts…

    The OpenSCAD source code:

    // PCB mounting bracket for Arduino Mega
    // Ed Nisley - KE4ZNU - January 2015
    
    Layout = "Build";			// PCB Block Mount Build
    
    //- Extrusion parameters must match reality!
    //  Print with 4 shells and 3 solid layers
    
    ThreadThick = 0.20;
    ThreadWidth = 0.40;
    
    HoleWindage = 0.2;			// extra clearance
    
    Protrusion = 0.1;			// make holes end cleanly
    
    AlignPinOD = 1.70;			// assembly alignment pins: filament dia
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    X = 0;						// useful subscripts
    Y = 1;
    Z = 2;
    
    //----------------------
    // Dimensions
    
    inch = 25.4;
    
    Tap4_40 = 0.089 * inch;
    Clear4_40 = 0.110 * inch;
    Head4_40 = 0.211 * inch;
    Head4_40Thick = 0.065 * inch;
    Nut4_40Dia = 0.228 * inch;
    Nut4_40Thick = 0.086 * inch;
    Washer4_40OD = 0.270 * inch;
    Washer4_40ID = 0.123 * inch;
    
    PCBoard = [102,54,IntegerMultiple(1.8,ThreadThick)];
    
    BottomParts = [[2.5,-5.0,0,0],				// xyz offset of part envelope
    				[96,80,IntegerMultiple(5.0,ThreadThick)]];			// xyz envelope size (z should be generous)
    
    Margin = IntegerMultiple(Washer4_40OD,ThreadWidth);
    
    MountBase = [PCBoard[X] + 2*Margin,
    			PCBoard[Y] + 2*Margin,
    			IntegerMultiple(5.0,ThreadThick) + PCBoard[Z] + BottomParts[1][Z]
    			];
    echo("Mount base: ",MountBase);
    
    ScrewOffset = Clear4_40/2;
    
    Holes = [									// PCB mounting screw holes: XY + rotation
    		[Margin - ScrewOffset,MountBase[Y]/2,180/6],
    		[MountBase[X] - Margin + ScrewOffset,MountBase[Y]/2,180/6],
    		];
    
    CornerRadius = Washer4_40OD / 2;
    
    //----------------------
    // Useful routines
    
    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=(FixDia + HoleWindage)/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);
    
    }
    
    //----------------------
    // Build things
    
    module PCB() {
    
    	union() {
    		cube(PCBoard);
    		translate(BottomParts[X] - [0,0,BottomParts[1][Z]])
    			cube(BottomParts[Y] + [0,0,Protrusion]);
    	}
    
    }
    
    module Block() {
    	translate([MountBase[X]/2,MountBase[Y]/2,0])
    		hull()
    			for (i = [-1,1], j = [-1,1])
    				translate([i*(MountBase[X]/2 - CornerRadius),j*(MountBase[Y]/2 - CornerRadius)],0)
    					cylinder(r=CornerRadius,h=MountBase[Z] - Protrusion,$fn=8*4);
    }
    
    module Mount() {
    
    	difference() {
    		Block();
    
    		translate([MountBase[X]/2 - PCBoard[X]/2 + BottomParts[0][X] - Protrusion,
    					-MountBase[Y]/2,
    					MountBase[Z] - PCBoard[Z] - BottomParts[1][Z]])
    			cube([BottomParts[1][X] + 2*Protrusion,
    					2*MountBase[Y],
    					2*BottomParts[1][Z]]);
    
    		translate([MountBase[X]/2 - PCBoard[X]/2,		// PCB recess
    					MountBase[Y]/2 - PCBoard[Y]/2,
    					MountBase[Z] - PCBoard[Z]])
    			PCB();
    		for (h = Holes) {
    			translate([h[X],h[Y],-Protrusion]) rotate(h[Z])
    				PolyCyl(Tap4_40,MountBase[Z] + 2*Protrusion,6);
    		}
    	}
    
    }
    
    ShowPegGrid();
    
    if (Layout == "PCB")
    	PCB();
    
    if (Layout == "Block")
    	Block();
    
    if (Layout == "Mount")
    	Mount();
    
    if (Layout == "Build")
    	translate([-MountBase[X]/2,-MountBase[Y]/2,0])
    	Mount();