Last Autumn, I began the process of building a chicken coop and chicken run for about 4 chickens. One of the biggest concerns for me was making sure that the door to the coop is secure at night. There are plenty of expensive automatic coop doors available online, but I was more intent on building my own door because ... uh... well.... I like to build things.
Enough jibber jabber, let's get to it!
The Door
Mounting the motor
For opening and closing the door, I am using a 12 volt automobile antenna
. My original plan was to make the door open vertically, but after a few tests, I opted for a horizontal sliding door design.
In the vertical orientation, is was common for the door weight to make the gears jump in the motor and then the door would come crashing down. I want a door, not a guillotine!.
Push/Pull Mount for the antenna
Much like the mounting brackets for the motor itself, the antenna is connected to the door using plumber's tape. Yea, it looks rather janky, but it is solid and it works.
Opened and Closed
On the top left and right of the sliding door, are magnetic switches that are used to register when the door is finished opening or closing.
A bar of soap was rubbed in the channels where the door will slide, in order to make for a smooth operation.
There is a gap in the door track (visible in the bottom left). As the chickens go in and out of the coop, the track will accumulate straw and droppings that may cause problems with closing the door all the way. By leaving a gap in the track, accumulated gunk will get pushed out of the way when the door closes.
Making A Case For The Controller
The coop door is controlled by a BeagleBone Black running Debian Linux.
Gather some supplies
- a ceiling lamp for the recycling center
- some j-b weld
- a beaglebone black
- a DPDT 12 v relay
- a 2 channel relay
controllable via IO pins on the BeagleBone.
- some of those stand-off thingies I like so much
TAKE IT APART!
Sadly, this is the only part of this build where I get to take something apart.
All of the electronic internals were removed from the lamp.
Weld things in place
The relays and beaglebone black were mounted to stand-offs and then j-b welded in place.
The hole in the bottom of the lamp base will be used for routing wires and cables.
Route some wires.
There are 5 wires coming from the coop door that need to be routed into the shed where the controller will be mounted. One wire for each of the magnetic switches, the common ground for the switches, and two wires for the motor.
Mount it!
Here is the 'lamp' with the cover in place. Originally, I had hoped that I could use a USB WiFi adapter for the BeagleBone to access the network but the distance was too great. Instead, I configured a spare router running DD-WRT to act as a repeater bridge and the BeagleBone was networked to the repeater.
A 12v 6a power adapter was wired to the relays in order to send 12 volts of power to the antenna.
Platform and ramp
After the door was finished, a platform and ramp to the chicken run was added to the coop.
Now it is time to get some birdies! bok bok bok!
Why did I use GNU Linux when I could have used a microcontroller with a light sensor to control the door?
I used Linux as the basis for my door because I wanted to use skills and tools that I already know, and I like having choice when it comes to programming languages used in my projects... and the light sensor doors are all fine and dandy until those sneaky no-good raccoons get their hands on a flashlight!
Now quit reading, and go make something.
See also: http://www.jezra.net/blog/The_magic_starts_at_330AM_a_coop_story to see how the coop gets open and close times from the interwebs
Not too long about I built a tubular music thingy, and while it is nice and fun to play, I really wanted to automate the playing of some tunes as well as giving myself the ability to play certain tunes at certain times.
To be fair, this was the plan all along and I'm calling this thing "Spiel", which I guess is short for glockenspiel.
Before the tubular music thingy was built, I came up with a fairly plain-text music notation format that I call SMN: the Spiel Music Notation format. In a nutshell, SMN files start with "tNUMBER" where NUMBER is the number of beats per second, and then there will be a series of notes: G a b c d e f g, and rests: r. Both notes are rests will be considered whole notes unless followed by a number.
For example, Sudo Modprobe in SMN would be:
t30
a4 G8 a4 G8 a8
b8 c2 e4 d2 r8
e4 d8 c8 d8 c8
d8 c8 b8 a4 G8
a4 G8 a8 b8
c2-8 b8 G1-2
On To the Build
For the automation, I used the following:
- BeagleBone Black - for running the code, network access, etc
- 8 12V 1A solenoids with a 10mm stroke - for striking the tubular bells
- 12V 6A power adapter - for powering the solonoids
- 8 channel 5V Relay - for sending power to individual solonoids
- Cheapo USB wireless adapter
Stand Offs
What are these things called? I don't know.
What I do know, is that once the spiky bits are bent down, these things make amazing stand offs for just about any computer build.
Mount the computer and relay board
After the stand offs were put on the Beaglebone Black and the 8 channel relay, the stand offs were hot glued to the frame of the Tubular Music Thingy.
Place the solenoids
More hot glue was used to place the solenoid bell hammers.
When the solenoids are energized, they produce heat, and if they stay energized long enough, they get hot enough to melt the glue.
This led me to write a script called 'heat' that will heat up a solenoid so that I can realign the hammer for a better sound.
Wire it up!
The Beaglebone was wired to the relay (I later changed the beaglebone to relay wiring).
The relay is wired to the solenoids, and the 12V power adapter was spliced into the relay and common ground of the solenoids.
Plug it in and run some code
Here is the finished product, ready to be played, or automated over the network.
What about some code?
The code for controlling Spiel is available at https://gitorious.org/spiel/spiel The documentation is non-existent, but there are a few .smn files in the SMN directory. If you have any questions about the code, send me an email and I'll help as I can.
My last Linux Outlaws related script
The final episode of the Linux Outlaws is nearly upon us, and I needed a script that will check if the last episode has been released, and if so, trigger the Spiel device to play the Sudo Modprobe melody.
Basically, this is a Final Episode Alarm
import urllib, time
from xml.dom.minidom import parseString
url = "http://feeds.feedburner.com/linuxoutlaws-ogg?format=xml"
#we need to loop for a while
looping = True
while looping:
#read the URL
f = urllib.urlopen(url)
xml = f.read()
#parse the XML
obj = parseString(xml)
#get the first item
item = obj.getElementsByTagName("item")[0]
#get the title
title = item.getElementsByTagName("title")[0]
ttext = title.firstChild.nodeValue.encode('utf8')
#does the title contain 370?
if "370" in ttext:
f = open('play_smn','w')
f.write("sudo_modprobe.smn")
f.close()
looping = False
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
#sleep for 5 minutes
time.sleep(300)
So now, within 5 minutes of the final episode being released, my Spiel device will play:
Someone once said that I was 'addicted to noise', while I don't necessarily agree with the 'noise' part, I certainly like to listen to music... all the time. With that in mind, you can understand my desire to have a sweet sweet music player in my workshop, and now I have one (sort of). Say hello to Bonechop!
What's in a name?
Bonechop is a Beaglebone Black computer running Debian Linux and using MuttonChop for network controlled audio playing, and the whole system is put in an old AM Radio. Since the Beaglebone Black doesn't have audio out capabilities, I opted to use a hella cheapo USB audio card; and it works wonderfully.
Gather Some Supplies
- a nice big late 50s or early 60s Montgomery Ward Airline AM radio gifted by a friend (thanks buddy!)
- a screw driver
- some awesome glue
- white gorilla tape
- the beaglebone (and a USB audio card)
- a bunch of little wood screws
- a 1" x 1" piece of poplar to use a stand offs
OK, the Poplar Didn't Work
aside from having a hell of a time just cutting the poplar into little pieces, every piece I tried to put a screw into would split before the computer was securely fastened. bummer.
Fortunately, there were some pine shims in the workshop that were left over from when my buddy framed in a door. Thanks buddy!
Here we have 3 small pieces of pine secured to the Beaglebone with little wood screws. I would have used 4 pieces, but the 4th hole is located near the micro-SD card slot and my blocky stand-off wouldn't fit properly. That's OK because 3 points make a plane.
A New Adhesive!
This is the first time I've used Weldbond, and I must say that I'm quite pleased with the results. After tipping the radio onto its side, the 3 stand-offs were glued to the body of the radio.
The next day, I took my coffee picture with the finished product.
How about a video?
As an entry to a contest by Adafruit Industries, I made a video of Bonechop playing some music.
This project is definitely not finished, but it is in a damn fine usable state. Now I need to go find some switches to wire into the GPIO.
For some reason, I am drawn to Will-o'-the-wisp even though I have never seen them. Fortunately I have an inclination for breaking things and making things and it seemed obvious that I would need to make my own Will-o'-the-wisp with some hardware and software hacking.
In a nutshell, I wanted to put some LEDs in a lantern and randomize the LEDs brightness with a computer to emulate a flickering effect.
Hardware Used
- phone cord : because I have plenty of it
- tin candle lantern : because it was available
- beaglebone ( I used my wall mounted beaglebone ) : because it can have more than one PWM controlled pin
Will-o'-the-Wisp Hardware
The Lantern
This tin candle lantern was the obvious choice for this project because it has been at my home for a few years and I don't really use it. TAKE IT APART!!!
There was a small tin cylinder in the lantern that held candles. Some gentle twisting quickly removed the holder. This was followed by sanding the inside of the lantern to make it more reflective and then small hole was punched in the bottom of the lantern.
This was my first time working with tin.
Solder some LEDs
Three bright LEDs were soldered to a four wire phone cord. Three wires for power and one wire for ground. The phone line adapter was scavenged from a broken touch-tone phone.
pfffttt touch tone
Hack a Notch in the Box
While putting together this hack, I thought it would be a good idea to include a phone cord jack for the rotary input device as well as the lantern.
Why Cringe?
I have friends that are wood crafters, and whenever they see my wood working skills they cringe a little bit. The easiest solution to the problem is to not show them what I do, but that wouldn't be as much fun.
Two phone cord jacks hot glued into the notch. It looks fairly flush on the top... and functional (which is what I really want).
Move the Beaglebone
While I had the box disassembled, I move the stand-offs closer to the wall of the box so that the beaglebone's USB port can be accessed more easily. I don't know what I'll use the USB port for, but it's nice to know that it is ready when I need it.
Plugged In Phone Jacks
All glued up, the lid closes properly, and I'm happy.
On the left is the lantern cord and the rotary phone is on the right.
LEDs
The LEDs are mounted in the tin lantern with a heavy dollop of hot glue! RAD!
Will-O'-The-Wisp Code
For this project, I opted to use the Ruby programming language because... well... just because. For now, all I need is a bit of File IO to write data to files. One of the reasons that I'm such a fan of the beaglebone is that in most instances, controlling the pins can easily be done simply by writing to a file.
All I really need to do, is have 3 instances of PWM on the Beaglebone and set the value of the pins to a random number in order to emulate a flickering effect.
Enter the Ruby
#define the pins that will be used, and their muxing values
#these are:
# 9.14
# 9.16
# 8.13
pins = [
{:mux_value=>6, :mux_target=>"gpmc_a2", :pwm_dir=>"ehrpwm.1:0"},
{:mux_value=>6, :mux_target=>"gpmc_a3", :pwm_dir=>"ehrpwm.1:1"},
{:mux_value=>4, :mux_target=>"gpmc_ad9", :pwm_dir=>"ehrpwm.2:1"}
]
#a class to represent an LED
class Wisp
def initialize( pin )
@min_val = 0
@max_val = 100
#set the pwm_dir
pwm_dir = File.join("/sys/class/pwm",pin[:pwm_dir])
#set the pwm duty_percent file
@duty_percent = File.join(pwm_dir, "duty_percent")
@run = File.join(pwm_dir, "run" )
#mux the target
target = File.join("/sys/kernel/debug/omap_mux", pin[:mux_target])
set_file_value(target, pin[:mux_value] )
#set up the PWM
set_file_value(@duty_percent, 0)
set_file_value(File.join(pwm_dir,"period_freq"), 100)
set_file_value(@run, 1)
end
def clean_up()
set_percent(0)
set_file_value(@run,0)
end
def set_percent( value )
set_file_value(@duty_percent, value)
end
def random()
val = rand(@min_val..@max_val)
set_percent(val)
end
def set_min_val(value)
@min_val = value if value >=0 and value <=100
end
def set_max_val(value)
@max_val = value if value >=0 and value <=100
end
private
def set_file_value(file, value)
#puts "#{file} : #{value}"
File.open(file, 'w') do |f|
f.puts( value )
end
end
end
#make an array of wisps
wisps = pins.each.map {|p| Wisp.new(p)}
#we want to create a controllable loop
loop = true
#let Ctrl+c break the loop
trap "INT" do
loop = false
end
#start looping
while loop do
#give each wisp a random percent
wisps.each do |w|
w.random()
end
#take a bit of a nap
sleep 0.1
end
#when the loop is broken, clean up
wisps.each do |w|
w.clean_up()
end
For easy copy and paste, this code is available at http://hoof.jezra.net/snip/o6.
It should be noted that this code is running on a beaglebone Rev. 3 using Arch Linux.
If I had the hardware, I probably would have used an ethernet cable instead of a phone cord. That way, I could run 7 LEDs instead of 3. Well it works, and that's what really counts. Now I have to start writing the web UI that will allow me to control the LEDs from a web browser. In case you haven't noticed, I like internetted things.
Now quit reading, and go find a will-o'-the-wisps.
Earlier this month, I received a 3V Voltmeter that I purchased on Amazon. The reason for the purchase was so that I could write some code to control the voltmeter from my beaglebone. Well hey! Guess what I finally got around to doing?
Before I get to the code, let me explain how this works, and I'd like to give a big shout out to gigamegablog for being such a great resource.
Controlling the voltmeter with the beaglebone requires a bit of understanding of Pulse-Width Modulation (PWM). The pins on the beaglebone are capable of outputting 3.3V of power. By using PWM we can send the 3.3V of power in pulses, and when these pulses are spaced apart properly, we give the illusion of a lower voltage.
The Pin Layout
According to the beaglebone documentation, pins 14 and 16 of pin header P9 on the beaglebone are PWM pins. It should be possible to use other pins as PWM pins by "muxing" the pins, but for my needs, pin 14 will do just fine.
The positive probe of the voltmeter was connected to pin 14 on P9 and the ground was connected to pin 2 on P9.
The First Test
Since I am runnin Arch Linux on my beaglebone, PWM is not only supported in the kernel, it is also enabled. Rad, that is one less step to take. Thank you Arch Linux!
The test went like this :
- su to become root
- mux pin 14, just to be sure:
echo 6 > /sys/kernel/debug/omap_mux/gpmc_a2 - set the duty_percent to 0 (this is the percent of the 3.3V that we want to emit):
echo 0 > /sys/class/pwm/ehrpwm.1:0/duty_percent - set the period frequency to 100 (this is the 'pulse' ins Hz):
echo 100 > /sys/class/pwm/ehrpwm.1:0/period_freq - start the PWM pin running:
echo 1 > /sys/class/pwm/ehrpwm.1:0/run - start increasing the duty_percent until the voltmeter is at 3V. For me, this was when the duty_percent was 92
Sweet!
Getting Data To Process
Since I didn't want to do any web server configuration in order to get data, I decided to write a very small WSGI app in python and serve it up using the wsgiref.simple_server class.
Enter the Python
from wsgiref.simple_server import make_server
#define some stuff
max_val = 92
pin_path = "/sys/class/pwm/ehrpwm.1:0"
run = pin_path+"/run"
duty_percent = pin_path+"/duty_percent"
period_freq = pin_path+"/period_freq"
#mux the pin
try:
f = open("/sys/kernel/debug/omap_mux/gpmc_a2","w")
f.write("6")
f.close()
except Exception, e:
print e.message
def set_run( val ):
try:
f = open(run,"w")
f.write( str(val) )
f.close()
except Exception, e:
print e.message
def set_duty_percent(val):
try:
f = open(duty_percent,"w")
f.write( str(val) )
f.close()
except Exception, e:
print e.message
def set_period_frequency(val):
try:
f = open(period_freq,"w")
f.write( str(val) )
f.close()
except Exception, e:
print e.message
#set some PWM values
set_run(0)
set_duty_percent(0)
set_period_frequency(100)
set_run(1)
def got_value(val):
val = val.strip("/")
val = int(val,10)
percent = (max_val * val/100)
set_duty_percent(percent)
class my_wsgi_app:
def process_request(self,text):
got_value(text)
status = '200 OK' # HTTP Status
headers = [('Content-type', 'text/html')] # HTTP Headers
return status, headers, text
def run(self, environ, start_response):
path = environ['PATH_INFO']
status, headers, content = self.process_request( path )
#begin the response
start_response(status, headers)
#return the content
return content
app = my_wsgi_app()
httpd = make_server('', 8080, app.run)
print "Serving on port 8080..."
# Serve until process is killed
httpd.serve_forever()
For ease of copy, the code is also available at http://hoof.jezra.net/snip/o3
The code starts serving on port 8080 and sets the percent of the PWM based on the URL used to access the server. For example, to set the voltmeter to 25%, one would need to point a browser at http://NAME_BEAGLEBONE:8080/25. My beaglebone is mounted on the wall and is named "wallbone", yea original. Anyway, if I want to set the voltmeter to 77%, I would access http://wallbone:8080/77
Face to Face
It's a shame that the voltmeter as a big "V" on it, as well as 0, 1, 2, 3, and some useless text.
One would think that I could just take apart the voltmeter, make a compass from a pin and a twist-tie, draw a new face, and re-assemble the meter. Oh, don't mind if I do!
How about some video?
Well... it was far too dark and the pin isn't really visible. What a shame.
http://www.youtube.com/watch?v=ldcwMYj5AIc
http://www.youtube.com/watch?v=SdbBgiZn1UM
Now What?
There are plenty of uses for this meter.
- analog progress or volume meter for muttonchop
- add a few more meters and create a neat clock
With the pulse-width modulation, I could connect and control a fan from the beaglebone.
The possibilities are only limited by my imagination.
Now quit reading, and go send me some ideas.
After putting together the rotary phone beaglebone machine, I decided that I still needed to do something with the extra pinouts on the beaglebone. Since I had recently started using MyTinyTodo to keep track of my todo list, I thought it would be nice to have a quick visual display of how many things are still on my todo list.
To Accomplish this my goal, I would need to add some LEDs to the beagle bone and then hack some code to do what needs doing. First thing first: add the idea to the todo list.
Gather Some Components
In order to get this project going, a trip to the nearby electronics store was in order. After returning home with 10 green LEDs ( the plan was to use 6, but I figured buying extra would let me fry a few), I realized that there was a lack of 100 Ohm resistors in my home.
Fortunately, I had some 50 Ohms that I soldered in series to handle the job.
This is a very boring pictures; don't look at it.
Solder 6 of These
This is the basic circuit that get's wired to the BeagleBone. The extra length of wire will get cut off and the entire thing will be wrapped in a bit of electrical tape.
While I was at the electronics store, I bought some fans to replace the fans in the clock server because I think it runs too hot.
The Finished Circuit
Well looky looky! The circuit is finished. Six LEDs with a common ground, with a 100 Ohms of resistance for each LED.
Time to wrap these babies up with electrical tape and hot glue them into the BeagleBone's case.
Glued in Place
On the third attempt, I managed to almost get the LEDs glued into place where I wanted them. Yea, it took me a few time of gluing, and then prying the LEDs from the case a regluing before things were working properly.
As it is, one of the LEDs still doesn't let the box close very easily. Terrible terrible design. That's it! I'm firing myself.
Oh hey! This is probably the best picture that shows off the flowers etched in the glass.
7 Things On The ToDo List
At the time this picture was taken, there were 7 things on my todo list. But there are only 3 LEDs lit up. That's right, the LEDs need to be counted in binary from left to right.
With this setup, using 6 LEDs, the ToDo List will max out at 63 items; and I if I have that many things to do, something is very wrong.
Every 5 minutes, the LEDs run a simple animation sequence, parse the ToDo List RSS feed and then turn on or turn off LEDs as necessary.
Since there is still plenty of room in the box, I'm thinking of adding another something-or-other that is controlled by the BeagleBone pins. I'm not sure what it will be, but I can guarantee I'll have fun making it.
Hack on!
PS. I really want to have 15 things on my ToDo list, just so I can say "THERE...ARE...FOUR...LIGHTS" Ha hahahaha, I crack me up.
A few weeks ago I purchased a BeagleBone from Amazon. The BeagleBone is a small ARM based computer with programmable Input/Output pins developed by Texas Instruments and is part of their beagleboard line of ARM development boards. After finally deciding what to do with the computer, it was time to build a new computer case.
Where is it Going?
At the thrift store, I purchased a nice jewelry box with flowers etched in its glass. The small, solid box was $3.00.
The plan (play the A-Team theme), is as follows:
- Connect a rotary phone to the BeagleBone for input
- Do some other sweet shit (more on that later)
Alrighty! time to get crackin
Gutted
For some reason, whoever created the box thought it would be a good idea to put a bunch of stuff inside that I don't want or need.
Here is the box with the lid removed and the crap removed.
Making Some Standoffs
When I made the clock server case, I kept some of the wood bits that I needed to remove from the internals of the clock. A wood saw and some small screws made some sweet standoffs for the beaglebone.
A black marker was eventually used to color the light wood.
Mangle the Box
Any dreams I had about making an very clean access hole in the case was dashed upon the rocks of my poor power tool using skills.
Oh well, it doesn't get seen, and it works as it should. Why am I complaining?
Wall Hanging Mount
Some twisted baling wire and two wood screws will make it very easy to hang the box on the wall.
Time to warm up the hot glue gun.
So Far So Good
Once the glue gun was hot, the standoffs were glued into the box.
Look at all of that empty space! The BeagleBone has a USB port so I will be putting something in the box, but I don't know what it will be. So far, I'm thinking it could be:
- a nice laptop hard-drive for file storage
- a character LCD to display information
- or... I could ditch the case and put the BeagleBone in the phone itself
On The Wall
All plugged in a running sweet!
Currently, my BeagleBone is running Arch Linux.
Originally, the BeagleBone ships with Ångström Linux, but I couldn't find any documentation for configuring the opkg package manager that ships with Ångström, and since I was looking to eventually run Lighttpd and MySQL on the device, I switched to a distro with an extremely useful wiki.
The Computers in the Corner
The Phone
The Bone
The Router
The Clock Server
The DSL Modem
The Status Server (between the modem and the router)
Now What to Do?
Put some LEDs in the box and write a program to light up the LEDs when something happens. That something is to be decided
But what else?
Options include putting a hard drive in the box and use it as a federated status.net server or put a character LCD in the case and use LCDproc to display various bits of information.
Currently the machine is programmed to:
- Dial 666 : play random Iron Maiden track on my MuttonChop machine
- Dial 75337 (sleep) : shut down computers
- Dial 9253 (wake) : emit wake-on-lan signal to various computers
Now I need to write a bunch of little programs to be run when various numbers are dialed on the phone, and I need to find a way to get the cables out of the way.
Until next time, hack on!
The BeagleBone story continues at http://www.jezra.net/blog/LEDs_BeagleBone_and_my_ToDo_List