Author Archives: widgetNinja

CNC Upgrade :: z-axis (part 2)

Once the fixed back plate (3/4″ aluminum) and the movable front plate (1″ aluminum) were machined it was assembly time. Here you can see the parts laid out and ready to go. In the upper-right you’ll see two white brackets to mount the stepper motor and tension the belt. These were 3-d printed with the mindset that I’ll mill aluminum ones when the machine is up and running. I found out about the option to put brass screw inserts in the 3-d print too late, but it looks like an awesome procedure and is something I’d do in the future.

Assembly was pretty straight forward. I did have a little binding on the lead screw and had to shim it out a little bit using some folded aluminum foil. Shim stock isn’t something I have on hand!

Minor shimming required where the ball screw attaches to the moveable plate.

And some additional photos of the assembly and mounting to the y-axis.

Once it was on the machine I could locate the z-axis homing switch. I used a fairly inexpensive magnetic sensor from amazon. I mounted the sensor in the back plate, and then drilled/tapped and threaded a hex-cap bolt in the movable front plate. This bolt triggers the magnetic sensor when the z-axis is in the full-up position.

CNC Upgrade :: z-axis

Pro-Tip : Just buy a z-axis. It’s likely not worth the hassle, unless you don’t value your time. Or if this really and truly a hobby and you enjoy doing and redoing things.

That said I built a z-axis! I bought a bundle of parts off ebay and used that as a ground floor for measuring and designing. Having parts on hand provided a good starting point for scale and feasibility in Fusion 360.

From there it was quite a few iterations to draw up what would become the axis. During this process I learned a LOT about fusion, as I wanted all the movements to work so I could watch for clearance issues etc. Saunders Machine Works’ youTube channel was a huge help. The final drawing (looks like 42 edits) looked something like this.

Mounting the stepper that way was a little more work, but it keeps it from sticking out the top, and counter-balances the weight a little bit. Here is a zip file with the fusion model if you want to use it.

I started doing the manufacturing of the backplate the manual way. Lobbed off a piece of 3/4″ aluminum stock and started drilling, tapping, and cutting. Fusion allows you to print out 1:1 sized prints which worked super well. I just sprayed on contact adhesive and glued the template to the stock. It was a lot of holes, and a lot of tapping.

The studious observer may notice the two pockets where the bearing-blocks for the lead screw attach. Those I didn’t get done in my garage. At the high school they have a old cnc Haas mill that we have access to for working on the robotics team. They were kind enough to let me run the pocket operations I needed on that mill. Thank goodness! It would have been nice to mill the whole piece there, including the drill holes but I didn’t want to overstay my welcome.

Quick gratuitous Video of chips flying:

CNC Upgrade :: Need a table

How can we make this project harder and take longer? Oh yes, lets collect new skills in a very round-about path to the destination. In this case I wanted to learn how to TIG weld. I could haphazardly do MIG welding but wanted to learn TIG. This was primarily as aluminum is a key working material for the high school robotics team and being able to weld it would likely come in handy. With a welder in hand I knocked together a frame to hold the new CNC gantry as well as a few drawers.

One of the things that’s not super obvious is behind the drawers you’ll see a ‘divider’ that leaves about a foot of space in the back. That’s where the electronics will eventually go.

CNC Upgrade :: Out with the old in with the new (to me)

I have had this 2×4 cnc machine for 4 years now, and have outgrown it. Made of MDF with aluminum rails and skate bearings it won’t go down in history as a super sturdy machine. That said it served me well and together we made some awesome things. I have been volunteering at the high school robotics team, and having a machine that can mill aluminum with a reasonable amount of accuracy was my design goal.

Doing the slow troll on craiglist and facebook marketplace I came across this guy. Stout steel frame, and nice linear bearings. The z-axis on it was some sort of ink sprayer – not sure what exactly it’s previous life was but good bones for my build. Now I just needed a table, z-axis, electronics, mill.. the little things.

One thing that was interesting/concerning was this used belts instead of ball/lead screws to move the x/y axis. There is an included gearbox with a 2.5:1 ratio off the stepper motors, and my concern was if I could get and maintain the accuracy needed. Overall these rail systems were very well built, and even the belt-tightening mechanism was well done.

Toolbox show and tell

My dad spent a lifetime as an automotive mechanic, specializing in transmission repair. He recently retired and I spend a few days helping him clean out his shop as he sold the building. I took a few moments to take photos of his toolbox, as the years of wear and showcase of daily-driver tools was pretty cool.

Publishing IoT IP Addresses to MQTT

I have been playing around with using ESP8266’s as endpoints around the house for collecting temperature, turning the sprinkler pump on, texting me when the doorbell is pressed, etc.  One of the challenges when doing setup/testing is getting the IP address of them when they first come online.

I am running dnsmasq on a raspberry pi, which provides both local DNS and DHCP services.  This is in no way novel, as it is a pretty vanilla configuration.  What I wanted to share is a small script that monitors for updates to the dnsmasq log, watches for new client releases/renewals and then posts those to the MQTT service.  There are lots of things you can do with it from there, but I usually just subscribe to the topic via terminal or mqtttool on my iPhone.

#!/usr/bin/python
from pygtail import Pygtail
import sys
import re
import time
import paho.mqtt.client as mqtt

client = mqtt.Client()
client.username_pw_set("xxxxxx","xxxxxx")

while (1):
 for line in Pygtail("/var/log/dnsmasq.log"):
   isItACK = re.search(r'DHCPACK',line)                #see if its an ACK
   if isItACK:
     newInput = re.sub(r'^.*DHCPACK\(eth0\).', "", line) #strip everything before mac address
     newInput = newInput.rstrip()                        #strip newlines
     client.connect("xxxxxx.widgetninja.net",1883)       #connect to mqtt
     client.publish("/network/DHCP",newInput)            #publish to mqtt
     client.disconnect                                   #hang up
     #sys.stdout.write(newInput)                         #debugging
 time.sleep(10)

Hope this helps save you some time trying to find the ip address of that new device, be it something you made or otherwise just added to your network.

mqtt

Monitor your Garage Doors with MQTT

Its a nighttime ritual for me.  Usher kids to bed, pick up kitchen, turn out lights, and peek into the garage to ensure the overhead doors are closed.  Odds are they aren’t, as someone always seems to have left them open through the normal bustle of the day.

I have been dabbling with home automation, building sensors and devices to automate the mundane.  So to that end, I set out to build something for the garage.  Design goals were:

  • Provide a status of open/closed for the two overhead doors
  • Ability to open/close doors from my phone

The hub of my home system today is Home Assistant (running on raspberry pi) which is very versatile, and allows many integration points.  As many internet of things devices are using MQTT, I am using that as the primary means of communication to/from the hub.

The micro controller used is an esp8266 which has an amazing story in itself; rising from simple beginnings – being initially sold as a uart->wifi adapter and becoming a stand along micro controller thanks to a dedicated group of enthusiasts.  This device can be had for about $8.00, has WiFi, and can run code compiled on the Arduino IDE.

Parts:

This project was fairly straightforward as it stands on the shoulders of projects done by others, as well as some starts and stops I had with recent ESP8266 projects.  The device is powered by a 5v wall wart, which supplies power for the ESP as well as the relay breakout board used.  These components combined with the hall sensors on the doors are all that was needed.  An overview of the hardware connections are here..

In Fritzing:

Fritzing Diagram

In reality:

ESP_WiringCloseUp

Note that the relay outputs that connect to the door ‘buttons’ can actually be connected right at the opener, where the button’s wire comes in.  Thats the blue/white wires on the right side above.

The door sensors are installed on the wall, and triggered by magnets on the doors.  This means any position other than fully closed will register as open (good in my opinion).  Installed they look something like this:

 

On the software side what the ESP8266 is doing is watching for the digital reads of pins D5 (door 1) or D6 (door 2) to change state (open / closed) and when it sees this it’ll post a message on the MQTT server.

The home automation hub takes it from there.  The other thing the ESP8266 is doing is watching for updates on MQTT for requests to open or close the door.  Once a message is notified the ESP will close the relay for a second (simulating a button press) and the door will start moving.  The messages look like this (going from open to closed):

/esp/garageDoorTwo/set 0       #this is the request to close
/esp/garageDoorTwo/state 0    #this is confirming state changed to closed

The actual code on the ESP8266 is linked below.  The highlights are the WiFi join, enabling of over-the-air updates, and the management of the MQTT messaging.

garageDoor.ino code

And if you happen to use HomeAssistant here is the relevant parts of the configuration.yaml file.

config.yaml code

And to wrap things up, here is what the results look like on my iPhone.

IOS_HA_Homescreen

Let me know if you have any questions or clarifications and I’ll try to answer them.

 

Audio on the go

I’ll save you the long back story, but I recently came across a pretty amazing module, the USR-S12.

usrs12

This module seems to be built for integration in other devices, and has an impressive list of features.  The key ones (to me) are:

  • WiFi base station or bridge
  • Airplay

This website has a pretty good breakout of what the interface looks like.

I ordered mine directly from china, for about $35 – but it took about 2 weeks to arrive.  Sparkfun also carries them with a break-out board (including rj45 ethernet) but they want a bit of coin for it.

With module in hand I set about wiring it into my car.  My goal was to stream audio from my iPhone as my car didn’t support the proper bluetooth codecs to play music.  With airplay i could stream podcasts and pandora with a higher sound quality than bluetooth would give me anyways.

My Audi has an interesting interface (AMI) which supports different cables for iphone aux etc.  The ipod cable was interesting to me as it supported analog left/right, data (not used for this application) and power.  I was fortunate to find a wiring diagram for the audi connector on a blog (thanks w.ashcroft!).

audioConnector

The only other sticky-wicket on the Audi part is that there is a small resistor inside the connector housing that tells the car if you have the ipod or the aux cord connected.  I wanted it to think the aux cord was connected so it wouldn’t try to talk via the data lines.  There is a 18.7k resistor in the iPOD cable, and i had to swap that out for a 1k to emulate the AUX cable.

After a quick snip-snip with the wire-cutter the 30-pin ipod connector was removed and I was able to identify which wires were which with a the help of the multi-meter (diode test for the win!).  Soldered power, ground and analog to the USR-S12 and was pretty much ready to go.

20141204_032154925_iOS 20141204_032203288_iOS

Plugged it in and thankfully everything worked as expected.  Iphone joined the new WiFi hotspot in my glove compartment, and airplay sounded awesome!  I made a few small changes through the web interface (10.10.10.254), changing the network/ssid name.  This also changed the name of the airplay host.

Final change is to edit the network properties on the wireless network on your iPhone.  When joined to this hotspot you want to set a static IP (such as 10.10.10.200) and NO default gateway.  This way your phone will still use the cellular network to get to the internet instead of trying to use the hotspot.  This is critical if you want to stream content like Pandora.

Boo

Whipped up a yard sign for this Halloween.  My wife picked up some really neat orange bulb strings with over sized glass bulbs – no LED’s here!  Scaled up some letters to be about 2’x3′ and layed out a hole pattern so each letter used an entire string.  The holes had to be slightly recessed so the bulbs could screw into the sockets fully.

Painted them up with some exterior paint.  They look nice next to the yard ghosts I got years back from the father-in-law!

WP_20140927_006 WP_20140927_008 WP_20141020_002 WP_20141021_002

Here are the .dxf files.

New gear begets new gear

It was bound to happen.  I finally got tired of finding the appropriately-sized wall warts to power my workbench projects.  It was time for a new power supply.  I picked up a reasonably priced 30v 5a Korad KD3005D, which seemed to have the small number of features I needed.

Upon its arrival, and after the unpacking excitement waned, I noticed a small problem.  The voltage being produced was way off from the displayed amount.  This was troubling, and an email to the manufacturer brought about a new control board which I swapped out.  Bummer is, the same problem persisted.

Dumb cheap-ass supplies right?  My concern for the second service inquiry is them doubting my technical prowess, so i ordered a second multi-meter.  I wanted to be able to have two meters showing the output, which wouldn’t match the power supply.  So i got a TekPower TP4000ZC ordered (serial output!) off Amazon (thanks prime!).

Wired the new meter up with my old meter (acquired in 1993) and low-and-behold.  Problem on my end.

WP_20141108_004

My trusty old meter turns out to be not so trusty.  Sorry, Korad – sorry I ever doubted you.  Threw the old meter in the trash and picked up a second TekPower.  Nice to have two.