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.

Month: April 2021

  • Kicad-to-HAL: Charge Pump Driver

    Kicad-to-HAL: Charge Pump Driver

    Just to see if all the conversion machinery hung together, I added the PWM component for the Mesa 5I25 card to the Kicad-to-HAL library:

    PWM Charge Pump driver - schematic
    PWM Charge Pump driver – schematic

    The top symbol provides the reference stem for the per-group frequency controls and the second provides the stem for the per-PWM controls.

    It requires conjuring one PWM in the FPGA:

    PWM Charge Pump driver - LoadRT config
    PWM Charge Pump driver – LoadRT config

    The corresponding lines in the HAl file:

    setp hm2_5i25.0.pwmgen.00.output-type 1		# parameter.116
    setp hm2_5i25.0.pwmgen.00.value 0.5		# parameter.115
    setp hm2_5i25.0.pwmgen.pwm_frequency 10000		# parameter.114
    
    … snippage …
    
    net Machine-Is-On <= halui.machine.is-on => and2.13.in1 hm2_5i25.0.pwmgen.00.enable
    

    And then it just worked:

    Mesa 5I25 10 kHz PWM output waveform
    Mesa 5I25 10 kHz PWM output waveform

    It’s not useful with the Sherline driver box, but I find it much easier to contemplate simple schematics than to puzzle out HAL code.

  • Kicad-to-HAL: Mesa Electronics 5I25 FPGA Card

    Kicad-to-HAL: Mesa Electronics 5I25 FPGA Card

    The Mesa Electronics 5I25 FPGA card can implement a vast number of hardware I/O controllers, but I’ve only set up the few Kicad symbols required for my simple Sherline mill. The LinuxCNC hostmot2 doc gives the details.

    The hm2_5i25.0 component (upper right) carries the pins and functions pertaining to the card itself:

    Servo Thread Hookup schematic
    Servo Thread Hookup schematic

    If you have two such cards, you’ll also have an hm2_5i25.1 component. Kicad will annotate both with a zero, which Kicad-to-HAL then strips off before attaching the pin names.

    The read and write functions must attach to the first and last positions of the servo-thread component, respectively, to make the thing work correctly.

    The read_gpio and write_gpio functions are normally not connected; the * prefix suppresses a Kicad-to-HAL message about unconnected named pins. The code will strip the asterisk before connecting the pins, but that part is … lightly tested.

    Similarly, the schematic shows the watchdog output connected to one of the on-card LEDs. I’m not sure how to test that and wouldn’t see it inside the PC case; it might work as described.

    A hm2_5i25.0.gpio.000 Kicad symbol (middle) collects all of the HAL pins related to a single 5I25 GPIO pin; edit the three-digit pin identifier to match the hardware pin. Although the out and in names look backwards, they indicate the hardware direction: you write to the out pin and read from the in pin.

    The Sherline uses four stepgen blocks, so that’s the only other Kicad symbol on offer:

    X Axis Joint PID Stepgen schematic
    X Axis Joint PID Stepgen schematic

    The nets connecting those three components come directly from the LinuxCNC pncconf configuration utility. Fancier machines surely require more attention to the coefficient details.

    Connecting a true parameter to the step.invert_output and direction.invert_output pins flips the polarity of those signals. The pins are aliases of the corresponding GPIO invert_output pin, with the key advantage of not requiring you to figure out which GPIO pin corresponds to the FPGA’s output pin for each axis.

    The 5I25 card requires a pair of loadrt components to load the drivers and configure the FPGA:

    Kicad-to-HAL Demo Schematic
    Kicad-to-HAL Demo Schematic

    The one-page demo schematic uses the same 5I25 configuration as the Sherline, with the LEDs driven by gamepad buttons to provide something to look at:

    Mesa 5I25 card - LED activity
    Mesa 5I25 card – LED activity

    I should force-fit an LED into the Sherline driver box just to have something easier to see.

  • Soaker Hose Splices: End Of Life

    Soaker Hose Splices: End Of Life

    The soaker hoses from Mary’s garden all came from someone else and have now reached their second end of life:

    Soaker Hose Splices - end of life
    Soaker Hose Splices – end of life

    Those orange lumps kept them alive for a few more seasons:

    Soaker Hose Splices - harvested
    Soaker Hose Splices – harvested

    In the unlikely event I ever give another in-person presentation about 3D printing and what it’s good for, I’ll have some interesting show-n-tell samples. Might have to soak the dirt off, though.

  • Vultures Sunning

    Vultures Sunning

    Spotted after pre-season prep at Mary’s Vassar Farms garden:

    Vultures sunning
    Vultures sunning

    It must feel really good up there atop the old barn, even if they’re sunning themselves to kill off parasites.

    Taken with the Pixel 3a zoomed all the way in at 7× from a bit over 200 feet:

    Vultures sunning - photo range
    Vultures sunning – photo range

    Then cropped and sharpened just a smidge. Not a great picture, but good enough for practical purposes; the Good Camera + Big Glass takes better pix and is too awkward to carry in my pocket.

  • Kicad-to-HAL: HALUI Components

    Kicad-to-HAL: HALUI Components

    The LinuxCNC HALUI “component” has so many pins that I divided them among about 18 Kicad symbols, each collecting the pins related to one function:

    Gamepad Button logic - HALUI components
    Gamepad Button logic – HALUI components

    The Kicad references (halui.mode.100) use periods as separators, not dashes, because HALUI runs automagically and has no thread functions.

    The symbol name (HALUI_MODE) serves as a unique identifier that should match the reference stem. I used underscores just for pretty, but it doesn’t make any difference.

    All of the Kicad symbols include the StripAnno field to remove the Kicad annotation, as described earlier. The Kicad annotations now start from 100, because I’m in the midst of tinkering an automagic way to produce the proper start-from-zero HAL numbering with everything properly sorted; this is very much a work in progress.

    So the full name of the resume pin on the HALUI_PROGRAM component sporting Kicad reference halui.program.100 is just:

    halui.program.resume

    This corresponds to the description of that pin in the HALUI doc, without a numeric identifier: there is only one HALUI.

    The net connecting the gamepad button to that pin:

    net _Gamepad_Buttons_Program-Resume <= input.0.btn-base4 => halui.program.resume
    

    A few more examples from the nets near the AND2 gate:

    net _Gamepad_Buttons_E-Stop-A <= input.0.btn-top2 => and2.0.in0
    net _Gamepad_Buttons_E-Stop-B <= input.0.btn-base => and2.0.in1
    net _Gamepad_Buttons_E-Stop-Reset <= input.0.btn-base2 => halui.estop.reset
    net _Gamepad_Buttons_Machine-On <= input.0.btn-pinkie => halui.machine.on
    net _Gamepad_Buttons_Manual-Mode <= input.0.btn-base3 => halui.mode.manual
    
    

    Some HALUI component references include numbers and letters identifying specific joints / axes / spindles, all of which you must edit as needed and none of which should be subjected to Kicad’s renumbering whims:

    X Axis jogging schematic
    X Axis jogging schematic

    The HAL commands producing the nets connecting the AND2 gates to the HALUI pins:

    net N_065 <= and2.14.out => halui.axis.x.minus halui.joint.0.minus
    net N_066 <= and2.15.out => halui.axis.x.plus halui.joint.0.plus
    

    The nets lack any specific name, so Kicad-to-HAL replaces Kicad’s default gibberish with the next integer from an ascending series. If your HAL configuration requires more than three digits worth of anonymous nets, feel free to tweak the format string.

  • Kicad-to-HAL: LoadUsr

    Kicad-to-HAL: LoadUsr

    The Kicad LOADUSR symbol puts its text directly into a HAL loadusr command:

    Kicad symbol - LOADUSR
    Kicad symbol – LOADUSR

    Putting the same text in the LoadUsr field of a Kicad component may be tidier when there’s only one:

    Kicad Symbol Properties - Logitech gamepad
    Kicad Symbol Properties – Logitech gamepad

    The gamepad symbol in a schematic:

    Kicad-to-HAL Demo Schematic
    Kicad-to-HAL Demo Schematic

    Which produces this loadusr command in the HAL file:

    loadusr -W hal_input -KA Dual		# input.0.0
    

    You can edit the text after placing the Kicad component, so the symbol can contain placeholder text.