GRBL 3d wire bender, Part 6 : What does it really do?

So I’m finally getting back to updating and using the GRBL wire bender, so I have to actually use it for something. I had built it to be able to bend various springs, when I can’t get ahold of exactly the right spring, so let’s go though a basic spring design. The other use is for bending copper wire into antenna shapes, but that’s further down the spiral…

Types of springs

Each type works a little differently in the code so let’s start with some definitions:

Types of springs for the machine

The bender really only can do springs made of wire, so disc / Belleville springs, and leaf springs don’t even enter into this conversation, so the types I’m targeting is:

  1. Tension Springs
  2. Compression Springs
  3. Conical Springs
  4. Spiral Springs
  5. Torsional Springs
  6. Compound variations of above

Spring construction

The spring body

All of these types start with a coil of some sort, as the base and then some sort of legs, The coil could be flat, as such as a spiral spring, close together like a tension spring, spread apart like a compression spring, or a lofted spiral like a conical spring. The wire diameter, the number of coils and the spacing between the coils changes how the spring responds

The legs

The leg styles are basically three different styles, there is a straight wire, a straight wire with a hook, a loop, or a bunch of coils together. For example a tension spring typically has a loop or a hook, whereas a compression spring typically has coils together as the end, and a torsion spring, or a spiral has two straight wires.

Spring rates

The spring body basically is a spiral, where the spring rate is controlled by the spacing of the coils. Given that we can control the machine, we can change the spacing on the fly resulting in being able to create differing spring rates using the same wire, in the same spring. If the spring spacing is consistent, the spring will have a constant rate of compression, if we slowly change the spring spacing we can generate a spring that changes spring rate when it compresses, and if we put two springs together we can have a dual rate.

Cool springs are coming!

Now let’s make some cool springs. The next one will breakdown the Gcode for making a fairly standard coil spring.

NeoPixels (WS2812) and a Raspberry Pi Zero W

So I wanted a cool LED controllable light up thingy… Because

  1. It lights up.
  2. I needed a status for my camera for the Teams stuff when I’m at home, so my Wife does not accidentally walk though the camera
  3. It’s a big bright light.

So I first looked at the unicorn hat, but this is discontinued, so then I went to my favorite electronics store, Adafruit.com, and they did not have what I wanted in stock, so I found a cheap knockoff on amazon (azin #B081BCBQ6B if you are interested) and wired it up.

I’m working off of port 18, and pulling power from the usb port for the PI, and it seems to work well, and it’s a simple 3 wire hookup, +5v, Gnd, and Data (GPIO18).

First thing is to wire up the circuit. This is the pinout for the header on a Rasbery Pi Zero W, Directly from https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/rpi_SCH_ZeroW_1p1_reduced.pdf The even pins are on the outside of the board.

Now for software, I’m going to use Python, because, well, it’s easy. Make sure you are running Python v3, and then add the Adafruit libraries in.


    sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
    sudo python3 -m pip install --force-reinstall adafruit-blinka

Now we need a tester, so let’s also use Adafruit’s tester as well. I’ve modified it for 64 pixels, but nothing else yet. The code is mirrored here if you want to try it.

# Simple test for NeoPixels on Raspberry Pi
import time
import board
import neopixel


# Choose an open pin connected to the Data In of the NeoPixel strip, i.e. board.D18
# NeoPixels must be connected to D10, D12, D18 or D21 to work.
pixel_pin = board.D18

# The number of NeoPixels
num_pixels = 64

# The order of the pixel colors - RGB or GRB. Some NeoPixels have red and green reversed!
# For RGBW NeoPixels, simply change the ORDER to RGBW or GRBW.
ORDER = neopixel.GRB

pixels = neopixel.NeoPixel(
    pixel_pin, num_pixels, brightness=0.2, auto_write=False, pixel_order=ORDER
)


def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if pos < 0 or pos > 255:
        r = g = b = 0
    elif pos < 85:
        r = int(pos * 3)
        g = int(255 - pos * 3)
        b = 0
    elif pos < 170:
        pos -= 85
        r = int(255 - pos * 3)
        g = 0
        b = int(pos * 3)
    else:
        pos -= 170
        r = 0
        g = int(pos * 3)
        b = int(255 - pos * 3)
    return (r, g, b) if ORDER in (neopixel.RGB, neopixel.GRB) else (r, g, b, 0)


def rainbow_cycle(wait):
    for j in range(255):
        for i in range(num_pixels):
            pixel_index = (i * 256 // num_pixels) + j
            pixels[i] = wheel(pixel_index & 255)
        pixels.show()
        time.sleep(wait)


while True:
    # Comment this line out if you have RGBW/GRBW NeoPixels
    pixels.fill((255, 0, 0))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    # pixels.fill((255, 0, 0, 0))
    pixels.show()
    time.sleep(1)

    # Comment this line out if you have RGBW/GRBW NeoPixels
    pixels.fill((0, 255, 0))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    # pixels.fill((0, 255, 0, 0))
    pixels.show()
    time.sleep(1)

    # Comment this line out if you have RGBW/GRBW NeoPixels
    pixels.fill((0, 0, 255))
    # Uncomment this line if you have RGBW/GRBW NeoPixels
    # pixels.fill((0, 0, 255, 0))
    pixels.show()
    time.sleep(1)

    rainbow_cycle(0.001)  # rainbow cycle with 1ms delay per step

The result is awesome.

Raspberry Pi Zero W – Backup USB Terminal

I often get lazy and don’t want to look up the IP of some PI that I just installed the OS on, nor do I want to go find the monitor.. This is where the USB SSH terminal comes in super handy.

This is a Linux thing, so if you have windows, I’m sorry. Google it more.

So step one is to install the ISO of your choice. I used the Raspberry Pi OS Lite version from the official source at: https://www.raspberrypi.org/software/operating-systems/, even though I don’t like Debian. The configuration files are all in the wrong place… anyways.. it’s stable and runs well.

Install is fairly straight forward. Unzip the download, and run dd. Replace the img with your image, and sdX is your SD card.

dd bs=1M if=2021-01-11-raspios-buster-armhf.img of=/dev/sdX conv=fsync

This will create two drives on your device, The first being boot, and the 2nd being root. Let’s start in boot. Touch the SSH file, and edit the config.txt to add the dtoverlay line.

touch /Volumes/boot/ssh
echo 'dtoverlay=dwc2' >> /Volumes/boot/config.txt

Now open cmdline.txt using your favorite text editor, which of course is Vim.

vi /Volumes/boot/cmdline.txt

add

modules-load=dwc2,g_ether

after “rootwait”, and before anything else. make sure there is only one space between all of them otherwise it will get borked. Now I’m going to be lazy and hook up both Wifi and USB Networking, so I’m going to configure the USB on a static IP address

vi /etc/dhcpcd.conf

Skip down to the bottom and add a USB configuration. In this example, I’m not specifiying the DNS entry for the USB, because I want it to pull data though the wifi when possible.

interface usb0
static ip_address=192.168.7.2
static routers=192.168.7.1
#static domain_name_servers=192.168.7.1

I don’t have a 192.168.7.xxx network anywhere, so I’m using that. Now I just go and configure my USB network on my PC to be a Static of 192.168.7.1, and I’m done. Plug the USB cable into the center USB connection, and wait for the light to turn on. Now I can SSH into the board without issue.

  ssh pi@192.168.7.2

GRBL 3d wire bender, Part 4 : The Controller software

Although you can use the Serial Monitor in the Arduino IDE for testing the install of GRBL by opening the serial port at 115200 baud, I wanted something a little cooler to do that with, so here’s some software we can use to make it a lot easier to use. I have DSL still, as I live out in the middle of nowhere, so I’m not going to use something online like Fusion360, or ChilliPepper.

Manually doing stuff

The best lookup document I found is here: http://www.diymachining.com/downloads/GRBL_Settings_Pocket_Guide_Rev_B.pdf

The basic commands are found here: https://github.com/gnea/grbl/wiki/Grbl-v1.1-Commands

You can choose to manually type a bunch of stuff in, and run it… good luck with that.

Controller programs

I’ve so far used GrblPanel, and Universal Gcode Sender. Both have their flaws, but both sorta work.

GrblPanel

GrblPanel has one major flaw. It runs on Windows. I had to borrow a laptop from work to get a copy of windows. It spins the motors, and seems to be pretty good for just moving the motors manually.

You can get your very own copy here: https://github.com/gerritv/Grbl-Panel/releases

Universal Gcode Sender

This is the standard for GRBL that is not too bad. Fairly short learning curve, but you do have to install Java.

You can get your very own copy here: https://winder.github.io/ugs_website/

Raspberry PI CNC

There is one other option which seems like a better one in the long term.. add wifi to the bender using a Raspberry PI. Not sure I’m going to go down this road on this project,, maybe on my 3040 refit, but the link to do it is here: https://wiki.protoneer.co.nz/Raspberry_Pi_CNC_-_Quick_Start_Guide

GRBL 3d wire bender, Part 3 – Embedded software

Being a software programmer, I always want to reuse code, so GRBL makes it easy to do motor control programming, which I’ll cover later.

For our application, we need to rework the PWM pin on the arduino UNO we are using to output the stuff the servo needs to see. Standard GRBL uses this pin for the Z limit switch, so let’s liberate it.

Fortunately someone else has the same issue that we have had, when they were making a pen plotter. Their solution was to create MIGRBL.

Here’s the installation instructions onto our Arduino UNO

  1. download a copy of MIGRBL
  2. Add the library using Sketch -> Include Library -> Add .ZIP Libary
  3. run File->Examples>MIGRBL->grblUpload
  4. compile and upload the code to arduino.

Now we can test it.

GRBL 3d wire bender, Part 2: Generic wiring

For the wire bender project I’m using a standard GRBL cnc shield on an Arduino Uno, Fairly standard stuff, that I had around.

GRBL CNC Shield

The servo motors are pretty simple hookup, with them plugging directly into the CNC, and adjusting the voltage similar to the instructions on http://www.zyltech.com/arduino-cnc-shield-instructions/.

1) Double check the power input polarity (“+” and “-“)

2) Be aware of the orientation of stepper drivers. Please note the potentiometer (pot) on A4988 and DRV8825 are at the opposite side​. If you are using the DRV8825 like I am, the pot goes next to the “CNC SHIELD” writing.

3) Adjust the max current, by adjusting the Vref

Max current = Vref x 2

Reference voltage is adjusted with a small screwdriver at the point indicated with the white arrow in the picture to the right. We suggest adjusting the reference voltage in small increments – no more than a quarter turn at a time. For a starting point, you may set the max current to 1A. If the motor over heats, reduce the Vref. If the motor does not move or miss steps, increase the Vref.

4) Plug in the X, Y and Z axis.

remember X is the rotation, Z is the feeder, and Y centrifugal motor. If you are rotating in the wrong direction, flip them around.

5) connect the limit switches, these are used to set the rotation of the X and Y axis. There is no Z limit switch

6) Connect the Servo Motor. Split the connector apart using a pocket knife or something similar, and put the yellow wire in the Z+, the red goes to the +5v, and the black to GND.

YAY… all of the wiring is done, onto the software to test things…

GRBL 3d wire bender, Part 1 Overview

I’ve been working on a 3d wire bender to make some springs, as I need them to be right, the first time, and every time after that.

First thing I did is look at a bunch of tutorials. So far not a one is perfect, but it’s got enough stuff to make a go at it.

My idea is to set the device as a GCode unit, with the X being the rotation, the Y being the 2nd rotation axis, and the Z being the feed, similar to a Lathe.

Typical Lathe axis

in my case, it’s going to be a bit different as the machine has to look like this.

Image is courtesy of https://howtomechatronics.com/projects/arduino-3d-wire-bending-machine/

The Z axis rotates the bender unit around the wire, and the bender unit puts a crimp in it, which is running on the X axis. This leaves the feeder unit, which is basically a MIG wire welder feeder, but tied to a stepper motor so it can be moved out a specific distance as the Y axis.

The only odd thing is the pin at the end has to be able to push on both sides of the wire, so it has to be able to be raised and lowered on ether side of the existing bend. I’m going to use a servo to do this.