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

  • Hall Effect Current Control PCB: First Light

    After winding the toroid the right direction, resoldering the ATmega2560, and fixing a scope probe, the brassboard PCB lit right up:

    VG 1193 mV - ID 50 mA-div - 1 ms PWM filter - overview
    VG 1193 mV – ID 50 mA-div – 1 ms PWM filter – overview

    The top trace is the gate drive at 200 mV/div, the bottom trace is the LED current at 50 mA/div. Expanding the timebase gives a closer look at the fuzz:

    VG 1193 mV - ID 50 mA-div - 1 ms PWM filter
    VG 1193 mV – ID 50 mA-div – 1 ms PWM filter

    Yup, that’s what deriving an analog voltage from a PWM output looks like. Verily, you’re seeing a 32 kHz PWM passed through a 1 ms = 160 Hz low-pass RC filter; the PWM frequency is 2 decades + 1 octave above the filter, so the 5 Vpp digital signal should be down 46 dB. Squinting at the ripple, it’s maybe 40 mV = -42 dB, which is certainly close enough, all things considered.

    The MOSFET controlling the LED current operates in its linear region (the whole point of this exercise!) and acts as a Class A amplifier. The datasheet says the forward transconductance is 21 S at VDS = 5 V and ID = 8 A, which certainly isn’t what we have here (about 1 V and 150 mA); you’d expect a 40 mV ripple to produce 840 mA of sawtooth. Under these conditions, the transconductance seems to be 2.5 S = 100 mA/40 mV.

    Anyhow, because the gate drive comes from an Arduino PWM output, it has 0.4% resolution and the voltage steps by a bit under 20 mV per PWM increment. Here’s what increasing the PWM output by one count looks like:

    VG 1213 mV - ID 50 mA-div - 1 ms PWM filter - overview
    VG 1213 mV – ID 50 mA-div – 1 ms PWM filter – overview

    Expanding the timebase:

    VG 1213 mV - ID 50 mA-div - 1 ms PWM filter
    VG 1213 mV – ID 50 mA-div – 1 ms PWM filter

    The gate drive is 20 mV higher and the current is 50 mA higher, so the transconductance again works out to 2.5 S.

    Note bene: The smallest gate voltage increment produces 50 mA more LED current. It works the same way in the other direction, too, putting a lower limit on the allowable LED current: when the ripple becomes larger than the nominal current, what’s the point?

    So, not surprisingly, precise LED current control isn’t possible with an Arduino’s PWM output, at least under these conditions. Using 16 bit PWM would increase the resolution (by a factor of 256), but the PWM ripple means the LED current varies by nearly 2/3 of the setpoint: 100 mApp for a 160 mA nominal LED current.

    You could apply a more drastic low-pass filter, but remember that the whole point is to blink the LEDs, not gradually turn them on and off. Eyeballometrically, the LED current risetime = 7 ms, which is very roughly what you’d expect from the 1 ms filter time constant: 5 τ = 99.3%. Doubling the filter time constant wouldn’t be a step in the right direction…

    To do this right, you need a real DAC with maybe 10 or 12 bit output (and careful attention to analog layout), which would be absurd in a circuit with an Arduino Pro Mini jammed on top.

    Given that it’s just blinking LEDs, none of this really matters: the LEDs are shatteringly bright and blink most satisfactorily. It’s a keeper, even with all that ripple…

  • HP Scope Probe Flange Repair

    Quite some time ago I manage to break the finger flange on one of my scope probes and, what with it being made of an un-glueable engineering plastic, a simple repair job failed quickly. It’s entirely round and a perfect lathe project, but … this is easier:

    HP Scope Probe Flange Repair
    HP Scope Probe Flange Repair

    You can see remnants of that failed repair just below the fracture:

    HP scope probe flanges - repair disk
    HP scope probe flanges – repair disk

    Some epoxy around the rim of the flange, plus filling the missing sector, looks about as grubby as you’d expect:

    HP Scope Probes - rear
    HP Scope Probes – rear

    That’s a tiny zit at about 1 o’clock which came off with fingernail pressure.

    From the business end, it actually looks pretty snappy:

    HP Scope Probes - front
    HP Scope Probes – front

    I’m mildly tempted to preemptively reinforce the other probes…

    The OpenSCAD source code joins two parts with coincident faces, but it worked out OK for once:

    // Tek Scope Probe Flange
    // Ed Nisley KE4ZNU November 2013
    
    //- Extrusion parameters must match reality!
    //  Print with 2 shells and 3 solid layers
    
    ThreadThick = 0.25;
    ThreadWidth = 0.40;
    
    HoleWindage = 0.2;
    
    Protrusion = 0.1;			// make holes end cleanly
    
    function IntegerMultiple(Size,Unit) = Unit * ceil(Size / Unit);
    
    //----------------------
    // Dimensions
    
    FlangeOD = 16.0;
    FlangeID = 8.75;
    FlangeThick = IntegerMultiple(1.25,ThreadThick);
    
    DiskOD = FlangeOD + 4*ThreadWidth;
    DiskThick = FlangeThick + 4*ThreadThick;
    
    NumSides = 8*4;
    
    //----------------------
    // 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) {
    
      Range = floor(50 / Space);
    
    	for (x=[-Range:Range])
    	  for (y=[-Range:Range])
    		translate([x*Space,y*Space,Size/2])
    		  %cube(Size,center=true);
    
    }
    
    //----------------------
    // Build it
    
    ShowPegGrid();
    
    	difference() {
    		union() {
    			translate([0,0,2*ThreadThick])
    				cylinder(r=DiskOD/2,h=DiskThick,$fn=NumSides);			// main repair part
    			cylinder(r1=(DiskOD - 2*ThreadWidth)/2,r2=DiskOD/2,h=2*ThreadThick,$fn=NumSides);
    		}
    		translate([0,0,(DiskThick - FlangeThick)])				// flange clearance
    			PolyCyl(FlangeOD,2*FlangeThick,NumSides);
    		translate([0,0,-DiskThick/2])
    			PolyCyl(FlangeID,2*DiskThick,NumSides);
    	}
    
  • Arduino Pro Mini Knockoff: Solder FAIL

    Although it’s not obvious, the two blue 2431 Ω resistors just above the toroid are a divider that scales the switched battery voltage (from the p-MOSFET on their left) by 50% and sends it to input A0 on the Arduino Pro Mini board:

    Hall effect sensor - toroid CCW field
    Hall effect sensor – toroid CCW field

    The firmware can use that input to dim the LEDs when the voltage drops below some preset threshold and, eventually, turn them off completely.

    Figuring the actual battery voltage is straightforward:

    • get 10 bit ADC value with analogRead()
    • multiply by actual VCC (measured at 4.96 V for this board)
    • divide by actual voltage divider ratio (measured at 3.78/7.57)

    Which, of course, reported the battery voltage was 4.116 V. Huh?

    After spending far too much time poking the code with a sharp stick, I wired the divider to the (previously unused) A6 and A7 inputs and dumped the raw ADC counts for all three. The answer should be somewhere near 763, but the three values came out around 215, 667, and 750. Huh?

    The A0 value is totally bogus, so I finally looked at the Arduino Pro Mini board:

    Arduino Pro Mini clone - chip overview
    Arduino Pro Mini clone – chip overview

    Hmmm. It turns out A0 is the second pin back on the left side:

    Arduino Pro Mini clone - unsoldered leads
    Arduino Pro Mini clone – unsoldered leads

    Double hmmm. An even closer look:

    Arduino Pro Mini clone - unsoldered A0 lead
    Arduino Pro Mini clone – unsoldered A0 lead

    Well, that was obvious after I figured out where to look

    I slathered flux on all the pins, touched each one with a soldering iron, and it’s all good.

    This is a knockoff Arduino Pro Mini board from eBay, of course, and the rest of the boards in that lot were OK. Their QC inspection almost certainly boils down to running the Blink sketch: if the LED blinks after the power goes on, ship it!

    Blink doesn’t verify the analog inputs, which turn out to be wrapped around that corner of the package.

  • Hall Effect Sensor: Toroid Winding Direction

    Pop Quiz!

    What’s the difference between the winding on this toroid:

    Hall effect sensor - toroid CW field
    Hall effect sensor – toroid CW field

    And the winding on this one:

    Hall effect sensor - toroid CCW field
    Hall effect sensor – toroid CCW field

    Very good!

    In the first picture, the top lead goes down the hole. In the second picture, the bottom lead goes down the hole.

    Bonus question 1: Why is this important?

    The winding’s chirality determines the direction of the magnetic field in the toroid by the right hand rule: grab the wire with your right hand, with your thumb pointed in the direction of (conventional) current flow, then your fingers wrap around the wire in the direction of the induced field.

    The Hall effect sensor snuggled in the toroid’s gap produces a bipolar output that depends on both the magnetic field’s direction and intensity, so reversing the field direction changes the phase of the sensor output: an increasing field can either increase or decrease the sensor’s output.

    Bonus question 2: For a given sensor orientation, what’s the probability of winding the toroid correctly on the first try?

    Yup: zero. Wound it backwards…

    It’s not practical to reverse the sensor orientation, the leads weren’t quite long enough to swap, and turning the toroid upside-down is effectively the same as swapping the too-short leads.

    The size of the solder blob at the end of the top lead tells you everything you need to know about the sequence of the picvtures.

  • LED Bug

    Our Larval Engineer has a bug report that blows away anything I’ve ever seen:

    Check out her post for the rest of the story…

    Forgot to mention this when she first told me about it; the discussion of LED and CFL lifetime brings it to mind.

  • Hard Drive Lifetime: Data Points

    Three years ago I installed a 1.5 TB WD Elements USB drive as an external backup for the “file server” in the Basement Laboratory. The log files show that the drive started spitting out “short reads” early in October, which means the rust has begun flaking off the platters.

    Repeated fsck -fyv /dev/sda1 runs produce repeated failures at various spots, so it’s not in good condition:

    e2fsck 1.41.14 (22-Dec-2010)
    Backup-1.5TB contains a file system with errors, check forced.
    Pass 1: Checking inodes, blocks, and sizes
    Error reading block 97649088 (Attempt to read block from filesystem resulted in short read) while getting next inode from scan.  Ignore error? yes
    ... snippage ...
    Pass 2: Checking directory structure
    Error reading block 104039017 (Attempt to read block from filesystem resulted in short read) while reading directory block.  Ignore error? yes
    Force rewrite? yes
    Directory inode 26009985, block #26, offset 0: directory corrupted
    Salvage? yes
    ... snippage ...
    Pass 4: Checking reference counts
    Inode 25903223 ref count is 41, should be 40.  Fix? yes
    ... snippage ...
    Backup-1.5TB: ***** FILE SYSTEM WAS MODIFIED *****
    
    736471 inodes used (0.80%)
    10173 non-contiguous files (1.4%)
    9367 non-contiguous directories (1.3%)
    # of inodes with ind/dind/tind blocks: 119655/12234/0
    142996292 blocks used (39.04%)
    0 bad blocks
    3 large files
    
    276772 regular files
    459614 directories
    0 character device files
    0 block device files
    0 fifos
    10377447 links
    76 symbolic links (72 fast symbolic links)
    0 sockets
    --------
    11113909 files
    

    Given that rsnapshot lashes the daily backups together with extensive hard links, so that there’s only one copy of a given file version on the drive, I don’t know what 76 symbolic links might mean.

    It’s been spinning up once a day, every day, for about 40 months; call it 1200 power cycles and you’ll be close. The usual runtime is about 10 minutes, giving the poor thing barely enough time to warm up.

    One data point does not a curve make.

    The warranty on new WD Element drives seems to be a year; I have no idea what it was slightly over three years ago, although I’m pretty sure it wasn’t more than three years…

    The various desktop boxes around here get powered up once a day, too, but I tend to replace them every few years and have never had a hard drive failure; a few system boards have crapped out, though. The boxes acting as controllers for the 3D printers and the Sherline CNC mill have a much lower duty cycle.

  • LED Bulb Lifespan vs. Warranty

    I picked up a $35 LED bulb that’s allegedly equivalent to a 75 W incandescent, replacing a 100 W equivalent compact fluorescent bulb that an X10 relay switch couldn’t turn off cleanly, for a torchiere floor lamp. ‘Nuff said about early CFL failures.

    It has both upward and downward facing LED chips that light up the diffuser and ceiling in equal measure. Both strings are visible from the side due to the heavy molded plastic lens around the chips:

    LED Bulb
    LED Bulb

    Some interesting bits from the package:

    Home Depot LED Bulb Warranty
    Home Depot LED Bulb Warranty

    A 22.8 year lifespan at three hours per day works out to 24.983×103 hours. I wish I could have heard the arguments about whether they could claim a 23 year lifespan…

    At the same duty cycle, the 5 year warranty covers 5.479×103 hours. Huh.

    The URL at the bottom leads to some general info, but nothing you didn’t know already.

    It works well enough, but at $35 it’s really a capital investment that I suspect will never actually pay for itself…