Browsed by
Author: john

Electronics technician
Slotting/shaping/keyway attachment for Atlas 618 lathe

Slotting/shaping/keyway attachment for Atlas 618 lathe

I have a recurring need to make splines, keyways, and other linear features, and while in some cases I could do this on my mill, using an indexing head on the bed, it’s a pain to set up and align. In many cases, the stuff I want to make, the mill can’t manage, like broaching keyways in pulleys.
In the past, I’ve ground a custom toolbit and clamped it in the lathe toolpost and then used the carriage traverse to run it along a workpiece in the lathe spindle. This has a couple of advantages: the workpiece is automatically centered and colinear with the cutting tool, and I can cut a slot the length of the lathe bed. However, it’s slow and it puts a lot of strain on the carriage rack, because that’s how the carriage traverses the bed: me twirling a wheel that runs a pinion that runs on the rack, and I have to take very fine cuts in steel or risk damaging the traverse mechanism.
I recently made a new cross slide for my lathe, that allows me to bolt workpieces to the cross slide, and was thinking about bolting a linear way onto it to make a nice smooth shaper mechanism, but then I realized that I already have a linear way: the stock lathe compound slide.
I’d seen pictures online of arm-powered shapers, using a long lever arm that the user pulls to power the shaper ram, and realized I could do the same as a bolt-on to the Atlas 618, without permanently modifying the lathe.

This is a really crude implementation, to see if it works.

I cut a piece of 1/2″ steel tubing the length of the compound slide plus its travel, welded a couple of nubs onto the bottom of the tubing so it fits on the cross-slide carriage between the edge of the compound swivel and the apron the Atlas 618 uses to protect the cross slide screw from chips, and slotted and drilled the tailstock end of the tubing. Then I made a bracket out of angle iron, that bolts into the end of the compound slide, after removing the compound screw and bracket. The angle iron bracket has a hole in it, parallel to the hole in the slotted tube clamped onto the cross-slide. Another piece of 1/2″ steel tubing, with matching holes, is bolted to both of those (with a short idler to prevent over-constrained movement.)  Assembled but not on the machine, it looks like this:

Shaper bracket components (quarter inch bolts throughout.)

Here it is on the lathe.

618 shaper attachment

A top view

618 shaper attachment top view

and a view of the idler and the compound attachment point.

618 shaper attachment, bracket detail

The result is that I can traverse the compound slide rapidly with one hand, while advancing the tool into the workpiece with the cross slide screw, after tightening the cross slide way clamp. That way there’s no force on anything that can’t handle it. Traversing is quite quick (especially with a dab of oil on the cutting tool.)

Here’s a video me operating it.


One interesting side-effect of using the compound slide is that I can set the compound slide at a slight angle (slight, because it runs into the lever arm fulcrum clamped to the cross slide body.) That means I can cut tapered splines (I’m not sure why I would ever want that) or more usefully cut square tapers. Those used to be pretty common on bicycles, for instance.

Because of the geometry of the tool contact point and the lever arm contact point on the compound slide, my first attempt using a tool clamped in the quick change toolpost was unsuccessful: the leverage exerted by the tool point twisted the toolpost, and that resulted in the tool digging in even more, a feedback loop that made the whole attempt unsuccessful. Instead I milled a toolholder that mounts the tool tip directly in line with the axis of rotation of the compound slide, and now it works very well.

A picture of a random demo internal spline cut in 6061-T6.  I was cutting about 0.010″ per traverse, using the Atlas 618’s locating pin and index holes on the headstock bull gear to accomplish the workpiece indexing.

demo spline in aluminum

A better solution will be to replace the outboard headstock bearing tensioning nut with a nut that has a keyway on it (gee, I wonder how I can make a keyway?) so I can stick index plates onto it, and then clamp the headstock rotation by an arm that goes down to the threading banjo bracket.  That’s next.


AS5040 on Beaglebone Black, using Python: preliminary

AS5040 on Beaglebone Black, using Python: preliminary

After waaaaaaay too long, I finally got around to porting the Arduino AS5040 code to python. This is very preliminary, but it does work.

As self-hosted versions of wordpress appear to do a lousy job of formatting, and python is formatting-specific, I’ll put the code on github where I can guarantee that it looks the way it should:



import Adafruit_BBIO.GPIO as GPIO
import time

def read_raw_val(data, chip_select, clock):
GPIO.setup(data, GPIO.IN)
GPIO.setup(chip_select, GPIO.OUT)
GPIO.setup(clock, GPIO.OUT)

a = 0
output = 0
readbit = 0
GPIO.output(chip_select, GPIO.HIGH)
GPIO.output(clock, GPIO.HIGH)
GPIO.output(chip_select, GPIO.LOW)
GPIO.output(clock, GPIO.LOW)
while a < 16:
GPIO.output(clock, GPIO.HIGH)
readbit = GPIO.input(data)
output = ((output << 1) + readbit)
GPIO.output(clock, GPIO.LOW)
a += 1
return output

while 1:
rawval = read_raw_val(“P9_15”, “P9_11”, “P9_12”)
print “read: ” + str(rawval)
print “raw rotation: ” + str(rawval >> 6)


I still need to strip and decode errors, extend it another two bits for the AS5045, and make the whole thing into an importable library.


Note that on the Beaglebone, the Adafruit GPIO library doesn’t yet fully support setting pull-up or pull-down resistors on pins.  As such, you may have trouble with some pins not working.  I know these three pins work, because I’ve tested them.  The code should work for Raspberry Pi without any problem, and at some point I’ll port this to Bonescript, where I do have control over setting the internal pull-up and pull-down resistors, so any set of I/O pins can be used.

Adding streaming internet radio to an old cabinet radio/phono/eight-track

Adding streaming internet radio to an old cabinet radio/phono/eight-track

So this came home with us.

giant phono cabinet
giant phono cabinet

It’s a 1970’s phonograph, AM/FM radio, and eight track tape player.  The tape player can record eight-track tapes.

Well, in theory it can.  In practice, the radio worked, the phono sounded terrible, and the tape player didn’t work at all.

A new needle fixed the phono.  Awesome.  Three out of four functions.  But the eight-track was in awful shape.  It doesn’t switch tracks, it doesn’t play.  The capstan is entirely missing the rubber friction drive that moves the tape.

So I did what any good geek would do: I operated and spliced in a Beaglebone, so it plays streaming internet radio.


First hurdle.  It’s cold, and my basement, where the only ethernet cable lives, is really cold.  I’m also lazy.  So I used a cat5 cable from the beaglebone to my laptop, set up port forwarding on my laptop, and then I could ssh into the beaglebone via the usb cable, and do software upgrades via apt-get through the cat5 and then across the wireless network.

On bbb:
ifconfig eth0
ifconfig add default gw
On laptop, start with an ifconfig and look at the output. There should be two eth[x] entries, one of which will include the entry. That’s actually the usb. So you want to configure the other one, which is the hardware associated with the port where the cat5 cable lives. For this example I’m presuming it’s eth1, and your wireless connection is wlan0.
sudo ifconfig eth1
sudo iptables –table nat –append POSTROUTING –out-interface eth1 -j MASQUERADE
sudo iptables –append FORWARD –in-interface wlan0 -j ACCEPT
sudo echo 1 > /proc/sys/net/ipv4/ip_forward

If you’re using xubuntu (or apparently a few other distros) that last line won’t work because for whatever reason ‘>’ doesn’t inherit sudo permissions. So you have to punt:

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

Now you can start work on the bbb.
apt-get update
apt-get upgrade
apt-get install alsa-base alsa-utils

Mine already had all the alsa stuff installed. A bunch of programs didn’t successfully upgrade, like apache and dbus, which I need to look into later, but I don’t actually use any of those for this project so I don’t care. [note 1]


Second hurdle: setting up audio.

I’m using a USB soundcard.  This requires disabling HDMI, which I’m not using at all, so the soundcard can manage the sound.

Go to /boot/uboot and edit uEnv.txt to remove the comment status from the line disabling hdmi. It’ll be optargs=capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
Then go to /etc/modprobe.d/alsa-base.conf and edit it to change the index on snd-usb-audio from -2 to 0.
Reboot the bbb with your usb soundcard plugged in.
For me, this resulted in being able to play music. I needed some music to play and a player.

apt-get install mpg321

(you might want to change your working directory to /home/debian before doing that, rather than sticking an mp3 in /etc/modprobe.d)
and then you can mpg321 1456.mp3 and hear some noise.
mpg321 will also accept url’s, so:

(If you download a .pls, it’s just text and will have the correct URL embedded in it.)
I used a Syba usb soundcard. It works beautifully.

[note 1]
For some reason, on current beaglebones is a screwed-up file, and prevents apt-get update from working correctly on half a dozen packages.
From here:!topic/beagleboard/LPjCn4LEY2I
do this:
Replace the existing /etc/init.d/ script with:

#!/bin/sh -e
# Provides:
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start LED aging
# Description: Starts LED aging (whatever that is)

x=$(/bin/ps -ef | /bin/grep “[l]ed_acc”)
if [ ! -n “$x” -a -x /usr/bin/led_acc ]; then
/usr/bin/led_acc &

Third hurdle: getting something to run automatically every time the beaglebone boots, aka the dreaded systemd.
In /lib/systemd/system/ make a file (programname).service
So for this example, blinker.service

It should look like this:




Then go to /etc/systemd/system/ and make a symlink to that file.

ln -s /lib/systemd/system/blinker.service /etc/systemd/system/

The file itself, if it’s python, must begin with #!/usr/bin/python (or wherever you have python installed) and be executable.

Then, systemctl –system daemon-reload
and systemctl start blinker.service

and your program should start immediately and also start every time you boot the beaglebone.

If your program is dependent on other services before it starts, you can add those under the [unit] group, like:

That way it will wait until the network is up before running — which, in the case of what I’m building, is nice, because it’s streaming internet radio.

I set up an Asus router as a repeater, that the Beaglebone plugs into.  I chose this because I had the router, and because I’d rather have USB just handling sound, and the network port just handling internet.
This required giving the Beaglebone a fixed IP, and registering that with the router, which also has a fixed IP, and registering the router with the house router.  Normal network stuff.  By adding port forwarding on the house router, I can ssh into the beaglebone and do any software shenanigans, like restarting it if it hiccups.

Back to hardware.  The eight-track player has nine wires leading to it: two pairs of two wires bundled inside coax grounds, and three other wires.  The unit claims to be quadraphonic.  There’s a switch at the top that says ‘stereo’ and ‘quadraphonic’.  As far as I can tell, this is bogus.  It has two sets of speakers (woofer, two tweeters) and the phono is stereo.  Given the four wires from the eight-track to the main amp board, there was at least a possibility that it was, in fact, quadraphonic.  After screwing around injecting signals into the four wires using a function generator:
debugging audio
debugging audio
I have convinced myself that two of the wires are outputs through the power amp to the speakers, and the other two are inputs for recording, that come from the speakers to the eight-track.  If there’s a microphone in this cabinet they hid it very well.
detail of eight track audio
detail of eight track audio
You can see a red wire that brings 20V to the eight-track, plus the gray and blue bundles that bring the input and output from the eight-track to the main cabinet.
At some point I have to get the eight-track working.
Alan Martin, aka The Most Interesting Engineer In The World:
has told me that it is a Moral Imperative that I repair the eight-track and get it working.  He has promised, or threatened, depending on how you look at it, to send me a suitcase full of brand new still in their plastic wrappers eight-track tapes when I get it working.
I promise I will, Alan.
But for right now, I cut the output from the eight-track, and spliced into the wiring with the Beaglebone’s soundcard output.

At this point, the software and electronics were complete.  The system played streaming radio when started, and I could switch stations remotely.
But what I wanted was to have the old control work.  There were five lights, one that lit up a ‘power’ indicator, and the other four telling you which track it was currently on, plus there was a button that allowed you to skip to the next track.
So I fired up KiCAD.  At work I use Altium and Cadence, and at home, in the past, I’ve used gEDA, but I am growing to like KiCAD.
It came out nicely.
So from there, it’s off to the LPKF circuit board plotter.
phono circuit
phono circuit
That came out nicely, too.
KiCAD’s default settings do something weird that I have to explore more: the board is essentially double insulated with a thin line of copper running between two adjacent isolation cuts.  It works fine.  It’s just more work for the poor LPKF plotter to cut away all that material.
So here’s the original board, with incandescent lights, and my replacement board, with LED’s.
phono control board replacement
phono control board replacement
I pretty much eyeballed the dimensions, by holding calipers up above the bulbs.  I was more careful with the screw mounting points.
The tactile switch on the board is triggered by a press-button I machined out of a bit of hex aluminum.
phono control panel and button
phono control panel and button
It works reasonably well.  It’s awfully sensitive.  I should have gotten a button with a much higher press force.  The narrower round part goes through the hole in the control panel, with the hex slightly larger in diameter so you can’t pull it out.
At this point it’s down to buttoning up.  Screw new control board in place, attach old control board to a bit of convenient metal with tape, rainbow jumper wires from the control board to the beaglebone.
phono all wired up
phono all wired up
Then the Asus and the Beaglebone go inside the cabinet, where I’ve wired in a spare outlet (seen at bottom) and the faceplate goes back on the machine.
phono closed up
phono closed up
It worked pretty well.
The program I’m using to run everything chooses a random URL from a list I compile.  As such, it lights a random track light, rather than incrementing them.  In part, that’s because incrementing stateful variables in a callback in python is trickier than I’d expected.  But as I have that working now, I’ll ssh into it and upgrade the software at some point.
Here’s an odd thing: different streams have different volumes.  I can set the gain of mpg321, but for the same gain, some streams are really loud and have a good volume match with the dynamic range of the amp, while others are so quiet that I have to crank the amp up to max to hear them well.  It’s just ones and zeros, right?  Weird.
update on arduino class d amplifier

update on arduino class d amplifier

Changing the ADC prescalar to 128 helps enormously with the sound quality.

ADCSRA = 0b10101111;           // AD-converter on, interrupt enabled, prescaler = 128


Now it sounds like a 1970’s AM radio.  If you had a really bad radio in the 1970’s.  But, it is clearly playing music, and some of it is even intelligible.