Monday, February 18, 2008

Blinkenlight

Overview: Basically this is a PIC based light flasher that uses temperature as input. It has several states it can drive the two lights(Power/HDD): Brightness/Random, Blink synchronously, Pulse synchronously, Blink Alternating, Pulse Alternating, Brightness Both, Pulse/Random, Trigger(1 light on if it's hot, 2 on if it's really hot). A state is picked psuedo-randomly at startup based on the last 3 LSBs computed from the analog input of the thermistor. The states can be cycled through by pressing the reset button on the computer, and every other one is off(So it's easy to stop the blinking).

Software:
The program is pretty simple. It has 2 threads, a main one to deal with the lights and convert analog values, the other is for monitoring switch presses(I didn't use button interrupts like I should have). There is some bit fiddling to guestimate a speed, and this would change significantly with a different thermistor. Also my alternating states suck, and I didn't feel like desoldering to fix them. The problem is the computer's LEDs are bigger than the ones I was testing with, so the alternating algorithm always makes one weaker looking. The random flashing patterns are made using some modulus magic and adding variations using the analog input. The MCC18 code can be downloaded here, and the hex can be obtained here.

Electronics:
Parts:
* PIC18F2550
* 4.7 Kohms Resistor
* 1 Kohm resistor
* 220 Ohm resistor -- should match close to the thermistor, give or take for adjustment
* 7.200 Oscillator(Could be about any, although speeds would need adjusted)
* 3 sets of pins to hook up connectors (Salvaged from an old computer)
* 300 Ohm Thermistor

Schematic:
I ended up using 2 boards, one that just held the thermisistor and could plug into a spare slot under the CPU, picture below:


Everything hooked up:



Running at a slightly warm temperature:

Friday, February 08, 2008

Solenoid Lock -- Overview

First let me preface this by saying if anyone stumbles upon this who isn't friends or family, this was my first attempt at a real hardware hack, so be gentle ;)

Overview:
  • Basically it locks a door using a pull type solenoid. Pretty simple, the only caveat is that I wanted to use the doorknob as a combo lock. So it works by turning the knob until you see the appropriate number, holding it on that number(The period next to it lights up when it's considered inputted), and keep doing this for all numbers in the combo. Once it's done correctly the lock opens.
  • I did make a much simpler version as an intermediary, that I think anyone could do in a couple hours.
Parts:
  • Electronics -- This consists mainly of the display, relay, power, solenoid, and a PIC to drive the whole thing.
  • Hardware -- This is a modification to the door handle to have it turn a trim-pot and an eye bolt used to catch the solenoid's piston.
The Good:
  • It works without any problems. Doorknob is responsive, locks solidly, and will allow you to unlock it twice in succession with a single correct password(So it can be shut again)
  • Minimal damage to the door, only required 2 small screws into the frame to hold up the solenoid.
The Bad:
  • Three power supplies! It could easily be done with 2, I just didn't find one lying around that matched what I needed. I'm sure there is a way to do just 1, but I didn't spend enough time get it.
  • The trim-pot is held on with hot glue, which I don't trust but hasn't given me trouble so far
The Ugly:
  • The wiring is horrendous, since it has wires sticking out from the door, to the wall, and too the door handle from the inside. I used a phone jack even to plug the PIC into the trim-pot, adding to the mess further. It's all tucked away fairly neatly now(Except the phone wire), but is still horrible.
Future Improvements:
  • Hook up the trim pot by using something that clamps to the sides, instead of keying a dowel and gluing it on.
  • Put everything inside the door itself so it looks much neater. This would mean swapping the positions of the solenoid and the eye screw. I didn't want to harm the door itself is why I didn't do this, since it is the 'correct' solution.
  • Use 2 solenoids so it could be defeated by simple removing the hinges
  • Use one power supply
There is a video of it running below, the password being used is 1B50. It is hard to tell what's going on unfortunately since the control box is on the ground :(


Thursday, February 07, 2008

Solenoid Lock -- Hardware

The bulk of the hardware construction is covered in the wireless lock writeup. I'll only cover the additional steps needed below:

New Parts:
> Square dowel that will fit into the door knob.
> Trim-pot(See electronics section)

New tools:
> Needle nosed pliers
> Hot glue gun
> Sanding drum for Dremel
  1. The door handle must be modified, since it only allows 90 degrees of freedom, and a standard trim pot is usually just shy of a full 180. It's 'simply' bending anything that hits the side upwards till it doesn't hit. This includes 2 spring ends and 2 metal tabs. I used normal needle nosed pliers and a flat tip screwdriver and got it with not too much effort. Pic below:
  2. Next a dowel needs to be cut to fit to the proper length. Should be enough to mount the trimpot inside the metal and then have it be snug against There is a picture further down when I discuss gluing that shows this better. Below is a picture of the dowel in the door(I was retarded and had to shape a circular one to work), it's sticking out a little just so I could feel how tight it was in the handle:
  3. This is the most difficult part IMO, since it's prone to screwing up, and helps if done correctly. The end of the dowel needs to be carved to fit into the trim pot. For example if your trim pot has a straight slit for a flat tip screwdriver then you need to carve something roughly resembling a flat tip head on the dowel. I used a Dremel sanding tool to to this. In the end you should be able to control the potentiometer with the dowel.
  4. Next glue the Dowel onto the trimpot, you'll have to take off the door handle assembly entirely for this to get it straight. I originally tried epoxy but it didn't stick to the trimpot plastic so I went with hot glue which worked well. Picture of it 'clamped' up below:
  5. Solder up wiring to the trim pot for later use since it will be hard to get to after it's in place.
  6. Finally put it all back on the door. You can no longer put in the latch(The middle section) since it also hinders rotation. The dowel should slide into the handle, and turning the handle should now turn the trim pot.

Workshop

I think I've about finished up my workshop for at least the short-term future(Still need to add some little sorting drawers for small ECE parts though). It's made from an Ikea storage shelving system(Cheaper and better material than buying the raw parts separately from a home improvement store). I made some simple mitered angles to attach it to the banister, so it's sturdy and extended the main table using a couple of old bed slats as legs(Cut a groove down the middle to snap them into the metal part of the shelf). Also added some pegs to the sides to hold stuff like wire, found a simple way of doing it by just taking a dowel and rotating a circular Dremel sanding bit over one end till it was thin enough to be hammered in.

Pics below:

Sunday, February 03, 2008

Wireless Solenoid Locked Door

A cheaper($20-35 depending on what's lying around) and simpler version of my solenoid locked closet door:

Parts:
  • Cheap pull type solenoid -- $2
  • Wireless Control -- $15
  • Scrap wood(I used furring boards) -- $2
  • Eye bolt, 2 nuts, and 2 lock washers-- $2
  • Small machine screw and nut -- $1
  • Spare wire(I used speaker wire) -- Hopefully free or about $2
  • A pair of 2 inch wood screws -- Hopfully free, since they are hard to find without getting a $5 box
  • Scrap metal(I used the casing of an old PSU) -- Free hopefully
  • 12-24V 1A Power supply -- Hopefully free, salvaged mine from an old printer, else $10
  • Extension cord(Only needed if what you are adding the lock to doesn't have a power plugin inside) -- $2
  • Electrical tape -- $1
Tools:
  • Powerful Hand Drill or Drill press
  • Soldering iron and solder
  • Assorted drill bits
  • Dremel with metal cutting blades
  • Philips screw driver
  • Some sort of saw(Hack, back, miter, band, table any will work)
  • Clamp
  • Pliers
  • Flashlight
  • Marker or pencil

Safety:
  • 1 Amp is more than enough current to kill a person. Thankfully the voltage is low so it shouldn't penetrate the skin. Don't be dumb and work with it while wet or jam it into your body.
  • Thin non-clamped metal + Powerful drill = Spinning razor blade of death. Seriously clamp it down before drilling or the drill(Especially with larger bits) will grab it and spin it around. Same goes for small pieces of wood, although they aren't nearly as dangerous. This is from experience.
  • Solenoids can get hot enough to partially melt themselves! Do not leave intermittent duty ones on, or repeatedly pump them. Also don't put them near anything flammable.


Process:
  • Electronics
    • Strip the ends of your speaker wire, and then solder it onto the solenoid's leads. Secure with electrical tape.
    • Strip the ends of your power supply and solder on the speaker wire. Secure with electrical tape.
    • Next cut a block of wood. It should be big enough to put your solenoid onto, but not much bigger.
    • Drill a large hole near the top, where you want the piston of the solenoid to stop. This should be big enough for your machine screw to fit completely through(Including the head).
    • Put the machine screw on the solenoid loosely.
    • Mount the solenoid through the wood onto the door frame, leave off the piston for now. Make sure you've already routed through the machine screw. There should be a total of three screws(2 into the wall and the machine screw to stop it). A finished picture of the mount is below:
    • Now put in the piston(You will probably have to loosen the machine screw). To tighten the machine screw, hold the tip of the thread with pliers and rotate the hex nut(Hand tight should be fine). You have to do this since you can't reach the back of the screw anymore.
    • Finally plug everything into the wireless control, which should be inside the closet one way or another. Turn it on and the solenoid should depress. Turn it off fairly shortly afterwards to
    • Video of the electronics working:



  • Hardware
    • First take apart the door knob in question. There should be three parts the inside handle, outside handle, and latch. Also 4 screws, 2 for the latch and 2 for the knob. We won't be needing the the inside door knob so store it away. Put the front and the latch back in place.
    • Take the scrap metal and bend it so it is across the doorknob hole and where the latch is. Mark where the 4 screw holes are.
    • Drill out the 4 holes, then screw on the plate to the door. Remember to clamp it down since it can easily spin around and cut you.
    • Next we need to figure out where to mount the eye screw. I found it easiest to put it on the solenoid piston, then go in and shut the closet(With the flashlight and a pencil) and then mark where the eye beam would hit the metal.
    • Take back off the metal and drill the new hole.
    • Put in the eye screw and lock it down with the bolts and lock washers. If you are like me and don't have lock washers, or just want to make sure it stays you can use epoxy instead.
    • Remount the metal piece. It may bend a bit due to the bolt sticking out a tad behind it. Picture of it mounted(Note: The large center hole isn't needed) :
    • Get inside the closet again to make any final adjustments so it will latch properly when shut.
    • After that you are finished. Simply hit On to open or close the door and Off to relock it.
    • Below is a video of everything working together:

Saturday, February 02, 2008

Solenoid Lock -- Electronics

The construction of the solenoid lock electronics. Cost under $10 with part of a bigger order(Unless you can't scrounge up your own power supplies). The most expensive part is the relay.

Parts:
Below is the basic schematic. One thing to note is constant power is given to light up a C(For closed) on the second display, and one of the output pins on the pic is shorted to several to create the O(For open) when needed.


The circuit was quite easy, although I did have to plus up my microcontroller power supply with a 9V, to get enough current to drive the relay(I originally had a smaller display that broke, and adding the larger one sucked just enough amps to stop the relay from reliably switching).

The code for the PIC is in MCC18 and was compiled in MPLab. Source code can be downloaded here. Also the hex file for PIC18F4520 is here.

It's a pretty simple analog to digital conversion, then chop off all but the upper bits to get the proper hex value. It uses a separate thread to monitor how long the number was held for. One issue that took me forever to debug is the conversion takes several cycles and the number you are storing to has no definite value at that time. Meaning if another thread interrupts in the middle and tries to read that value it will get garbage. This is easily mitigated with a temporary variable being used during the conversion.

Soldering it up was hassle free, although I had a lot of wires that were required. 2 Power supplies to the control box, then 4 wires of power to the solenoid and microcontroller, 9 wires from the microcontoller to the control box for the display, and then a phone cord was used to hook up the trim pot to the microcontroller. If I had been willing to, it would have been *much* nicer to have embedded everything into the door, control box and all, so there were only the power wires.

Picture of the spaghetti wiring:

Rehashed video from an earlier post of the electronics running(Note: I'm manipulating a potentiometer offscreen to scroll through the numbers):


Frankenbench

Finally finished up my Frankenbench, which took several weeks since I kind of just nailed on parts when I was bored. Basically a while back I put together a work desk(Which I'll put up when it's all done), but I didn't buy anything to sit on. Looking through my scraps of junk furring wood(From the failed rabbit pen, since they aren't straight at all), I decided to try to make a bench to sit on.

First I made a simple sawhorse design like this:

But it was uncomfortable due to the wood on top, and was like a teeter totter if you sat right on either edge since the legs are in the middle(They really are on upside down). So since it looked like crap anyway I decided to add more legs to make it sturdier and add some more ledges underneath to hold parts. Then I decided that those extra legs might as well hold some parts and drilled holes and added nails. Afterwards it looked like this:


Next I spray painted it black and then had my wife help me upholster(We screwed up a bit on one side with all the pliers). Some pics of the finished product: